LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 32123 - No debuginfo location for second basic block in the same line
Summary: No debuginfo location for second basic block in the same line
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: DebugInfo (show other bugs)
Version: 3.9
Hardware: PC Linux
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-02 16:14 PST by Ariel Ben-Yehuda
Modified: 2019-06-06 03:51 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
IR with bad codegen (1.76 KB, text/plain)
2017-03-02 16:14 PST, Ariel Ben-Yehuda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ariel Ben-Yehuda 2017-03-02 16:14:41 PST
Created attachment 18046 [details]
IR with bad codegen

When there are 2 consecutive basic blocks (even if they don't branch to one another at all) on the same DI code line, no .loc debuginfo is emitted on the second basic block, so breakpoints into it get missed and step-over jumps over it

## Meta
$ dpkg -S `which llc-3.9`
llvm-3.9: /usr/bin/llc-3.9
$ dpkg-query -W -f='${Version}\n' llvm-3.9
1:3.9.1-4

## STR & actual result

$ llc-3.9 di.ll -relocation-model=pic
$ gcc di.s
$ gdb ./a.out
...
(gdb) b di.rs:3
Breakpoint 1 at 0x677: file /cache/di.rs, line 3.
(gdb) r
Starting program: /cache/a.out 
[Inferior 1 (process 16580) exited with code 0160]
(gdb) q
; How was my breakpoint skipped?

## Expected Result

Both calls to `bar` are in line 3, and the second call is run, so the breakpoint should get hit (equivalently, stepping through using `next` should go through lines 2->3->4).
Comment 1 Ariel Ben-Yehuda 2017-03-02 16:17:06 PST
For reference, heart of sample code:

define void @main(i64, i8**) !dbg !366 {
entry-block:
  %cmp = icmp ne i64 %0, 1, !dbg !1002
  br i1 %cmp, label %bb1, label %bb2, !dbg !1002
bb1:
  call void @bar(), !dbg !1003
  br label %bb1, !dbg !1003
bb2:
  call void @bar(), !dbg !1003
  ret void, !dbg !1004
}
Comment 2 Paul Robinson 2017-03-02 23:03:03 PST
If you enable column information, that might help.
I believe it's `-gcolumn-info`.
Comment 3 David Blaikie 2017-03-03 09:06:18 PST
Shooting from the hip: Fixing this fully would probably involve tracking "is stmt" from the frontend (there are a few issues that this might fix). Probably by adding a stmt scope node or the like.

Alternatively/short-term it might be possible to get somewhat better behavior by putting a new line entry at the start of every basic block, even if it's the same location as the previous one.

This might cause too much breaking, though - "x ? f1() : f1()" would then probably break for x and the call to f1 (whichever one executed).