gprof: functions vs lines behaviour of inlined code

Richard Allen rsaxvc@gmail.com
Sat Apr 4 01:59:35 GMT 2026


gprof treats inlined functions differently in line vs
function(default) mode. In function-mode, inlined code counts toward
the caller. In line-mode, inline code counts toward the line in the
inlined callee.

//Ex: line-mode credits most time here
static inline uint32_t xorshift32(uint32_t x) {
  x ^= x << 13;
  x ^= x >> 17;
  x ^= x << 5;
  return x;
}

//But function-mode credits most time here
int main(){
  uint32_t x = 1;
  while(x) x = xorshift32(x);
  return x;
}

I sometimes find this confusing when I start with function-mode for an
overview, but some of the functions disappear from the top page in
line-mode. Any opposition to aligning function-mode to bill the
inlined code line line-mode does?

-Richard


More information about the Binutils mailing list