fix: subtract 1 from call chain addresses other than the first one#43
fix: subtract 1 from call chain addresses other than the first one#43milianw merged 1 commit intoKDAB:hotspotfrom
Conversation
For stack frames other than the first one, ip is a return address, so it points to the instruction after the call instruction. By using the return address as is, we were incorrectly attributing these call chain samples to the instruction following the call. Therefore, subtract 1 from the return address so that it gets correctly attributed to the call instruction.
|
Reproducer: Without this change: With this change: |
|
Interesting. I do wonder if/how it would adjust the flame graphs in general and if this is only clang/mold related... I think that sample could be added to the tests as well, no? |
Ideally this could get turned into an auto test, i.e. compile this reproducer into a static binary then record it with perf and then write a test that tries to analyze the now-portable results. we have some test code that stringifies the results and that should nicely show the before/after too |
|
that said, I'm fine with merging this as-is and trusting your judgement on this front, so thanks a lot for your contribution! considering my lack of time, I don't want to block you on writing the tests, but it would be great to have. for now I'll create a task out of this. |
|
PS: the test would live in hotspot btw |
For stack frames other than the first one, ip is a return address, so it points to the instruction after the call instruction. By using the return address as is, we were incorrectly attributing these call chain samples to the instruction following the call. Therefore, subtract 1 from the return address so that it gets correctly attributed to the call instruction.