Skip to content

Commit 068b6a4

Browse files
Zecheng Linamhyung
authored andcommitted
perf annotate: Skip annotating data types to lea instructions
Introduce a helper function is_address_gen_insn() to check arch-dependent address generation instructions like lea in x86. Remove type annotation on these instructions since they are not accessing memory. It should be counted as `no_mem_ops`. Signed-off-by: Zecheng Li <zecheng@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent f1204e5 commit 068b6a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/perf/util/annotate.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,6 +2698,20 @@ static bool is_stack_canary(struct arch *arch, struct annotated_op_loc *loc)
26982698
return false;
26992699
}
27002700

2701+
/**
2702+
* Returns true if the instruction has a memory operand without
2703+
* performing a load/store
2704+
*/
2705+
static bool is_address_gen_insn(struct arch *arch, struct disasm_line *dl)
2706+
{
2707+
if (arch__is(arch, "x86")) {
2708+
if (!strncmp(dl->ins.name, "lea", 3))
2709+
return true;
2710+
}
2711+
2712+
return false;
2713+
}
2714+
27012715
static struct disasm_line *
27022716
annotation__prev_asm_line(struct annotation *notes, struct disasm_line *curr)
27032717
{
@@ -2806,6 +2820,12 @@ __hist_entry__get_data_type(struct hist_entry *he, struct arch *arch,
28062820
return &stackop_type;
28072821
}
28082822

2823+
if (is_address_gen_insn(arch, dl)) {
2824+
istat->bad++;
2825+
ann_data_stat.no_mem_ops++;
2826+
return NO_TYPE;
2827+
}
2828+
28092829
for_each_insn_op_loc(&loc, i, op_loc) {
28102830
struct data_loc_info dloc = {
28112831
.arch = arch,

0 commit comments

Comments
 (0)