-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[DebugInfo] Misleading debug location at O1/2/3/g/s in inlined code #135937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-debuginfo Author: Shan Huang (Apochens)
Clang version
```
Ubuntu clang version 21.0.0 (++20250415033808+d0e4af8a88dc-1~exp1~20250415153924.2354)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
```
LLDB version
Bug-triggering program 1 int printf(const char *, ...);
2 int a, c;
3 unsigned b = 5;
4 int d() {
5 if (b)
6 return b;
7 c = 8; // Dead code here
8 }
9 int main() {
10 d();
11 printf("%X\n", a);
12 } Here is the optimized LLVM IR with the misleading debug location: https://godbolt.org/z/f6e1qbdaM. define dso_local noundef i32 @<!-- -->main() local_unnamed_addr #<!-- -->1 !dbg !36 {
...
3: ; preds = %0
store i32 8, ptr @<!-- -->c, align 4, !dbg !39, !tbaa !30 ; c = 8;
br label %4, !dbg !40
4: ; preds = %0, %3
...
}
!39 = !DILocation(line: 7, column: 5, scope: !25, inlinedAt: !38) When debugging, LLDB stops at the dead line:
I suspect that this bug is caused by function inlining. cc @SLTozer @jryans |
I think the LLVM IR looks fine here. Seems like it might be down in codegen: https://godbolt.org/z/Ec1MraPMq
That |
@dwblaikie Thanks for your correction! Through my investigation, I found that the // Add prologue to the function...
for (MachineBasicBlock *SaveBlock : SaveBlocks)
TFI.emitPrologue(MF, *SaveBlock);
|
Usually prologue/epilog would be fine to have no location info, since you don't usually break/step there (breakpoints on thefunction should break after the prologue) - perhaps some kind of shrink wrapping or other thing is being done to this function & that's not accounted for by the zero-location-at-start-of-basic-block logic? |
Uh oh!
There was an error while loading. Please reload this page.
Clang version
LLDB version
Bug-triggering program
After the mid-end optimizations, the debug locations are fine: https://godbolt.org/z/f6e1qbdaM.
When debugging, LLDB stops at the dead line:
I suspect that this bug is caused by function inlining. cc @SLTozer @jryans
The text was updated successfully, but these errors were encountered: