]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf annotate-data: Use DWARF location ranges to preserve reg state
authorZecheng Li <zli94@ncsu.edu>
Mon, 9 Mar 2026 17:55:23 +0000 (13:55 -0400)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 19 Mar 2026 21:42:29 +0000 (14:42 -0700)
commit4fb7eefe6c539840fa8854d67d00af35331b8843
tree2ae4b65548a23a8aec9cd941b95e37efb2eba889
parentd35b0d5877109ecca106cc3835d4d23ac2cdc33c
perf annotate-data: Use DWARF location ranges to preserve reg state

When a function call occurs, caller-saved registers are typically
invalidated since the callee may clobber them. However, DWARF debug info
provides location ranges that indicate exactly where a variable is valid
in a register.

Track the DWARF location range end address in type_state_reg and use it
to determine if a caller-saved register should be preserved across a
call. If the current call address is within the DWARF-specified lifetime
of the variable, keep the register state valid instead of invalidating
it.

This improves type annotation for code where the compiler knows a
register value survives across calls (e.g., when the callee is known not
to clobber certain registers or when the value is reloaded after the
call at the same logical location).

Changes:
- Add `end` and `has_range` fields to die_var_type to capture DWARF
  location range information
- Add `lifetime_active` and `lifetime_end` fields to type_state_reg
- Check location lifetime before invalidating caller-saved registers

Signed-off-by: Zecheng Li <zli94@ncsu.edu>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/annotate-arch/annotate-x86.c
tools/perf/util/annotate-data.c
tools/perf/util/annotate-data.h
tools/perf/util/dwarf-aux.c
tools/perf/util/dwarf-aux.h