Issue |
135937
|
Summary |
[DebugInfo] Misleading debug location at O1/2/3/g/s in inlined code
|
Labels |
debuginfo
|
Assignees |
|
Reporter |
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
```
lldb version 21.0.0
```
Bug-triggering program
```c
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.
```llvm ir
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:
```
Process 37755 stopped
* thread #1, name = 'origin', stop reason = step in
frame #0: 0x0000555555555165 origin`main at origin.proc.c:7:5
4 int d() {
5 if (b)
6 return b;
-> 7 c = 8;
8 }
9 int main() {
10 d();
```
I suspect that this bug is caused by function inlining. cc @SLTozer @jryans
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs