hotspot icon indicating copy to clipboard operation
hotspot copied to clipboard

Disassembly: per-instruction cost is not shown for inlined code

Open arvidfm opened this issue 1 year ago • 0 comments
trafficstars

Describe the bug When disassembling functions containing inlined code, the disassembly view does not show per-line/instruction costs for code inlined from other functions.

To Reproduce Steps to reproduce the behavior:

Compile this program with gcc -g -O2 -o fib main.c :

#include <stdio.h>

unsigned long fib(unsigned long n) {
  unsigned long a = 0, b = 1;
  for (unsigned long i = 0; i < n; i++) {
    unsigned long tmp = a;
    a = a + b;
    b = tmp;
  }
  return a;
}

int main() {
  printf("%d\n", fib(10000000000));
}

Then profile the binary using Hotspot and open the disassembly view for main.

Expected behavior The disassembly view should show per-line/instruction costs even for inlined code.

Screenshots The profile in perf report: image

The same profile in Hotspot's disassembly view:

image

If I compile with -fno-inline and disassemble fib instead, the costs show as expected:

image

Version Info (please complete the following information):

  • Linux Kernel version: 6.9.10
  • perf version: 6.9
  • hotspot version: 1.5.1 (tested both AppImage and compiled from AUR)

Additional context Originally found while profiling Go code, but it seems Go and C binaries behave the same here.

arvidfm avatar Aug 28 '24 19:08 arvidfm