| Issue |
84435
|
| Summary |
[DebugInfo][GVN] Misleading single-stepping caused by presering old debug location to hoisted LoadInst
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Apochens
|
Hi, It seems I found another misleading debug location caused by the conflict btw proper debug location updates and backtrace quality. The newly created LoadInst `NewLoad` is inserted into the predecessor of the old LoadInst `Load`, however `NewLoad` preserves the debug location of `Load`. The debug location update site is here. According to the comments in my previous PR, I think this is the same situation as the StoreInst in the loop. The load should drop the location, but we need to keep a location for memory access instruction to track it.
So, I just report this issue and leave it as a reminder (or a reference) for future improvement. @jmorse @SLTozer
The source code:
```C
int func(int *a, int b) {
if (b) {
} else {
*a = 0;
}
b = 1;
return *a;
}
int main() {
int a;
func(&a, 1);
return 0;
}
```
The compilation command:
```Bash
$ clang -S -emit-llvm -Xclang -disable-O0-optnone main.c -o main.ll -g
$ opt -S -passes=mem2reg,gvn -enable-load-pre main.ll -o main_opt.ll && clang main_opt.ll -o main
```
The misleading single-stepping behavior:
```Bash
$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/linuxbrew/llvm-debug/a.out' (x86_64).
(lldb) b func
Breakpoint 1: where = a.out`func + 8 at main.c:2:9, address = 0x0000000000001138
(lldb) r
Process 6323 launched: '/home/linuxbrew/llvm-debug/a.out' (x86_64)
Process 6323 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555138 a.out`func(a=0x00007fffffffe07c, b=1) at main.c:2:9
1 int func(int *a, int b) {
-> 2 if (b) {
3 } else {
4 *a = 0;
5 }
6 b = 1;
7 return *a;
(lldb) s
Process 6323 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x0000555555555145 a.out`func(a=0x00007fffffffe07c, b=1) at main.c:7:12
4 *a = 0;
5 }
6 b = 1;
-> 7 return *a;
8 }
9
10 int main() {
(lldb) s
Process 6323 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x000055555555514a a.out`func(a=0x00007fffffffe07c, b=1) at main.c:3:5
1 int func(int *a, int b) {
2 if (b) {
-> 3 } else {
4 *a = 0;
5 }
6 b = 1;
7 return *a;
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs