Issue 172873
Summary [SPGO] Incorrect profile counts for tail call
Labels new issue
Assignees
Reporter Heath123
    When using SPGO, sometimes a single instruction correlates to multiple lines of the original program, but debug information can only represent one location. For example, a tail call represents both a call and a return, so in this example:

```c
#include <stdio.h>
#include <stdint.h>

void func(uint64_t i) {
    if (i % 2 != 0) return;
    
 printf("Hello\n");
}
```
compiled with `-O3 -fdebug-info-for-profiling` ([Compiler Explorer link](https://godbolt.org/z/GcsoW3GE3))

the exit block at line 8 is only recorded when the early return is taken, which executes an explicit return instruction pointing to line 8. When the tail call is executed, it also implicitly returns but the instruction is associated with the printf call. This leads to the exit block being undercounted by 50% when a profile is collected and loaded.

This is similar to #172872 but more difficult to solve, since that issue can be resolved using a copy ID, but in this case there is no place to store the association at all without extending debug info or affecting codegen.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to