diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c index 23a09bf58f86..6fe2efd48a83 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1629,7 +1629,9 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) pr_debug_dtp("type_offset=%#x\n", type_offset); } - if (!found || is_better_type(type_die, &mem_die)) { + if (!found || dloc->type_offset < type_offset || + (dloc->type_offset == type_offset && + !is_better_type(&mem_die, type_die))) { *type_die = mem_die; dloc->type_offset = type_offset; found = true;