linux-stable/tools/perf/ui
Ravi Bangoria 7efbcc8c07 perf annotate: Fix fused instr logic for assembly functions
Some x86 microarchitectures fuse a subset of cmp/test/ALU instructions
with branch instructions, and thus perf annotate highlight such valid
pairs as fused.

When annotated with source, perf uses struct disasm_line to contain
either source or instruction line from objdump output. Usually, a C
statement generates multiple instructions which include such
cmp/test/ALU + branch instruction pairs. But in case of assembly
function, each individual assembly source line generate one
instruction.

The 'perf annotate' instruction fusion logic assumes the previous
disasm_line as the previous instruction line, which is wrong because,
for assembly function, previous disasm_line contains source line.  And
thus perf fails to highlight valid fused instruction pairs for assembly
functions.

Fix it by searching backward until we find an instruction line and
consider that disasm_line as fused with current branch instruction.

Before:
         │    cmpq    %rcx, RIP+8(%rsp)
    0.00 │      cmp    %rcx,0x88(%rsp)
         │    je      .Lerror_bad_iret      <--- Source line
    0.14 │   ┌──je     b4                   <--- Instruction line
         │   │movl    %ecx, %eax

After:
         │    cmpq    %rcx, RIP+8(%rsp)
    0.00 │   ┌──cmp    %rcx,0x88(%rsp)
         │   │je      .Lerror_bad_iret
    0.14 │   ├──je     b4
         │   │movl    %ecx, %eax

Reviewed-by: Jin Yao <yao.jin@linux.intel.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https //lore.kernel.org/r/20210911043854.8373-1-ravi.bangoria@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-09-18 17:43:05 -03:00
..
browsers perf annotate: Fix fused instr logic for assembly functions 2021-09-18 17:43:05 -03:00
gtk perf annotate: Re-add annotate_warned functionality 2021-08-03 17:04:04 -03:00
stdio perf report: Print percentage of each event statistics 2021-04-29 10:30:59 -03:00
tui tools ui popup: Allow returning hotkeys 2020-01-06 11:46:10 -03:00
browser.c perf annotate: Fix fused instr logic for assembly functions 2021-09-18 17:43:05 -03:00
browser.h perf annotate: Fix fused instr logic for assembly functions 2021-09-18 17:43:05 -03:00
Build perf tools: Rename build libperf to perf 2019-02-14 15:18:08 -03:00
helpline.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
helpline.h perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
hist.c perf evsel: Rename perf_evsel__group_idx() to evsel__group_idx() 2020-05-05 16:35:31 -03:00
keysyms.h perf report: Support a new key to reload the browser 2020-03-24 09:37:27 -03:00
libslang.h perf build: Handle slang being in /usr/include and in /usr/include/slang/ 2019-06-18 17:48:12 -03:00
progress.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
progress.h Merge branch 'linus' into perf/core, to fix conflicts 2017-11-07 10:30:18 +01:00
setup.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
ui.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
util.c perf debug: Remove needless include directives from debug.h 2019-08-31 19:10:19 -03:00
util.h tools ui popup: Allow returning hotkeys 2020-01-06 11:46:10 -03:00