[llvm] [DebugInfo][RemoveDIs] Support DPValues in HWAsan (PR #78731)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 05:39:04 PST 2024


jmorse wrote:

Just to explain the addition of `getNextNonDebugInstruction` in this patch and the related test changes: in the two flavours of alloca.ll we have:
```
    %x = alloca ty    ; line 1
    call void @llvm.dbg.value
    call some_function ; line 2
```
And that becomes (without the patch):
```
    %x = alloca ty     ; line 1
    hwasan_instrumentation_insts ; line 2
    call void @llvm.dbg.value
    call some_function ; line 2
```

Right now, if someone operating a debugger requests a breakpoint on line 2 then they'll very likely end up stopped on the hwasan instrumentation instructions, and won't be able to see any variable assignments that were supposed to happen before line 2, which creates a small risk that they'll get confused.

Using `getNextNonDebugInstruction` makes the hwasan instrumentation come after the dbg.value intrinsic:
```
    %x = alloca ty     ; line 1
    call void @llvm.dbg.value
    hwasan_instrumentation_insts ; line 2
    call some_function ; line 2
```
Now when someone requests a breakpoint on line 2, they'll still stop on the hwasan instrumentation instructions, but all the variable assignments that happen before line 2 will be visible. It sort of makes the addition of the instrumentation more transparent to the developer.

Normally this sort of change deserves it's own patch -- however it's inherently connected with the debuginfo iterators change, as what we're doing there effectively makes `getNextNode` behave like `getNextNonDebugInstruction` at all times, so I thought it best to do it all at the same time. This'll avoid spurious test differences when we enable the new feature, plus as mentioned, the new output is slightly better.

https://github.com/llvm/llvm-project/pull/78731


More information about the llvm-commits mailing list