[llvm] [DebugInfo] Fix incorrect debug attribution for inlined allocas (PR #144345)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 17 11:22:13 PDT 2025
https://github.com/SLTozer commented:
I have some small code comments, but mostly interested in the big picture stuff following what @dwblaikie has said:
> On the one hand, I'm not sure any allocas should have source locations?
Most allocas don't have source locations, some allocas do - one example seems to be instructions generated for `__builtin_alloca` and similar intrinsics. I think I agree that in principle, we do not want to arbitrarily/unconditionally erase these source locations.
On the other hand, we may have a valid case for dropping them. If there are any conditional branches between the entry block and the inlined call, then [we should drop](https://llvm.org/docs/HowToUpdateDebugInfo.html#when-to-drop-an-instruction-location) the debug locations. It may be that as a matter of practicality, it's easier to simply unconditionally drop locations rather than traversing the CFG to determine this fact.
Finally, it may be a separate issue altogether that the location of allocas in the entry block leaks onto stack protection instructions - dropping the locations on inlined allocas may fix that, but it may also be worth addressing directly. I suspect that directly applying a function-entry location to such instructions may be correct, but I'm not sure yet - would have to look into it a bit more.
https://github.com/llvm/llvm-project/pull/144345
More information about the llvm-commits
mailing list