[llvm] [InstrRef] Skip clobbered EntryValue register recovery (PR #142478)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 15:18:04 PDT 2025
jmorse wrote:
Hmmm, I'm less of a fan of the most recent refinement -- for the base patch, I think it's reasonable to use an entry-value DIExpression as part of the variable-value being propagated around a function, as it's easily understandable. Putting a register-location into the set of constant-value operands is much more confusing and moderate hack, when the pass is designed to avoid tracking register-locations until the last moment.
I don't believe a filter in loadInLocs would be so hard (I appreciate this is all pretty much undocumented). We can rely on two things:
* Transfer tracker runs after all inter-block analysis has completed, each variable-value at the start of each block has been fixed. So each block can be considered in isolation,
* The code that interprets the output of LiveDebugValues (DbgEntityHistoryCalculator) already has carve-outs for entry-value variable locations (it ignores clobbers to any registers they refer to), and it only considers locations on an individual block basis.
Following the diamond-diagram, assuming we have a DBG_VALUE setting a variable to an entry-value expression in block 1, and no other DBG_VALUEs for the variable, we'll begin blocks 2, 3, and 4 with a `DbgValue` struct recording the `ValueIDNum` for the entry value, and an expression. In each block one of two things happens:
* If the entry value is no longer available in any register, we take the `recoverAsEntryValue` path out of `loadVarInLoc`, produce a DBG_VALUE with an entry-value expression, and don't record anything to be tracked,
* If the entry value _is_ available in a register, we get to the end of `loadVarInLoc` and produce a DBG_VALUE with an entry-value expression, _and_ we record the location to be tracked.
It's the tracking at the end of the 2nd item that can be filtered: I think it's just a case of guarding the insertion to `ActiveVLocs`.
Through all the blocks, `DbgEntityHistoryCalculator` will keep the entry-value locations alive regardless of any clobbers. The only thing that'll make it change the variable location is if there's another DBG_VALUE for the same variable.
https://github.com/llvm/llvm-project/pull/142478
More information about the llvm-commits
mailing list