[llvm] Fix insert DBG_VALUE after terminator Failure for Hexagon (PR #173401)

Fateme Hosseini via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 30 08:28:00 PST 2026


fhossein-quic wrote:

> Sorry for being silent here, I've been fairly sunk lately,
> 
> If I recall VLIW things correctly, this scenario is one where both a spill and a branch are executed in parallel: the spill takes effect but can't have a DBG_VALUE instruction created, because it can't be placed after the terminator?
> 
> To address the FIXME of how this might be represented without this limitation: you could adapt `VarLocBasedLDV::insertTransferDebugPair` to record the spill in `OpenRanges`, but not produce the DBG_VALUE instruction (it would need to know it's in a packet with a terminator). This would be fine because (AFAIUI) there are no instructions in the block that happen "after" the terminator, and so no change to the variable location in the block is needed. However with the spill recorded in `OpenRanges`, any successor blocks would benefit from the knowledge of the spill, which improves variable location coverage.

Yes, that's exactly the case, we are trying to insert DBG_VALUE for some spill/reg-copy inside the instruction bundle, but the insertion place is after the packet end which is a terminator, and it causes assertion failure.
Thanks for the tip. I'll try> Sorry for being silent here, I've been fairly sunk lately,
> 
> If I recall VLIW things correctly, this scenario is one where both a spill and a branch are executed in parallel: the spill takes effect but can't have a DBG_VALUE instruction created, because it can't be placed after the terminator?
> 
> To address the FIXME of how this might be represented without this limitation: you could adapt `VarLocBasedLDV::insertTransferDebugPair` to record the spill in `OpenRanges`, but not produce the DBG_VALUE instruction (it would need to know it's in a packet with a terminator). This would be fine because (AFAIUI) there are no instructions in the block that happen "after" the terminator, and so no change to the variable location in the block is needed. However with the spill recorded in `OpenRanges`, any successor blocks would benefit from the knowledge of the spill, which improves variable location coverage.

Yes, that’s exactly the situation. We’re trying to insert a DBG_VALUE for a spill/reg‑copy that is inside the instruction bundle, but the insertion point ends up after the packet end, which is a terminator, and that triggers the assertion.
Thanks for the suggestion. I’ll try adapting that approach.

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


More information about the llvm-commits mailing list