aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2022-04-21 14:39:39 +0100
committerJeremy Morse <jeremy.morse@sony.com>2022-04-25 13:41:34 +0100
commitfda4305e5378478051be225248bfe9c1d401d938 (patch)
treed695b0ff618ab3c3ba2d4f4ad9b35163bda68d45 /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
parent00f0c805ff7c0b5780d651d273899abe977fdca7 (diff)
downloadllvm-fda4305e5378478051be225248bfe9c1d401d938.zip
llvm-fda4305e5378478051be225248bfe9c1d401d938.tar.gz
llvm-fda4305e5378478051be225248bfe9c1d401d938.tar.bz2
[DebugInfo][InstrRef] Add a size operand to DBG_PHI
DBG_PHI instructions can refer to stack slots, to indicate that multiple values merge together on control flow joins in that slot. This is fine -- however the slot might be merged at a later date with a slot of a different size. In doing so, we lose information about the size the eliminated PHI. Later analysis passes have to guess. Improve this by attaching an optional "bit size" operand to DBG_PHI, which only gets added for stack slots, to let us know how large a size the value on the stack is. Differential Revision: https://reviews.llvm.org/D124184
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp39
1 files changed, 7 insertions, 32 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 74f6e6e8..72d025e 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -1293,41 +1293,16 @@ bool InstrRefBasedLDV::transferDebugPHI(MachineInstr &MI) {
if (!SpillNo)
return EmitBadPHI();
- // Problem: what value should we extract from the stack? LLVM does not
- // record what size the last store to the slot was, and it would become
- // sketchy after stack slot colouring anyway. Take a look at what values
- // are stored on the stack, and pick the largest one that wasn't def'd
- // by a spill (i.e., the value most likely to have been def'd in a register
- // and then spilt.
- std::array<unsigned, 4> CandidateSizes = {64, 32, 16, 8};
- Optional<ValueIDNum> Result = None;
- Optional<LocIdx> SpillLoc = None;
- for (unsigned CS : CandidateSizes) {
- unsigned SpillID = MTracker->getLocID(*SpillNo, {CS, 0});
- SpillLoc = MTracker->getSpillMLoc(SpillID);
- ValueIDNum Val = MTracker->readMLoc(*SpillLoc);
- // If this value was defined in it's own position, then it was probably
- // an aliasing index of a small value that was spilt.
- if (Val.getLoc() != SpillLoc->asU64()) {
- Result = Val;
- break;
- }
- }
+ // Any stack location DBG_PHI should have an associate bit-size.
+ assert(MI.getNumOperands() == 3 && "Stack DBG_PHI with no size?");
+ unsigned slotBitSize = MI.getOperand(2).getImm();
- // If we didn't find anything, we're probably looking at a PHI, or a memory
- // store folded into an instruction. FIXME: Take a guess that's it's 64
- // bits. This isn't ideal, but tracking the size that the spill is
- // "supposed" to be is more complex, and benefits a small number of
- // locations.
- if (!Result) {
- unsigned SpillID = MTracker->getLocID(*SpillNo, {64, 0});
- SpillLoc = MTracker->getSpillMLoc(SpillID);
- Result = MTracker->readMLoc(*SpillLoc);
- }
+ unsigned SpillID = MTracker->getLocID(*SpillNo, {slotBitSize, 0});
+ LocIdx SpillLoc = MTracker->getSpillMLoc(SpillID);
+ ValueIDNum Result = MTracker->readMLoc(SpillLoc);
// Record this DBG_PHI for later analysis.
- auto DbgPHI =
- DebugPHIRecord({InstrNum, MI.getParent(), *Result, *SpillLoc});
+ auto DbgPHI = DebugPHIRecord({InstrNum, MI.getParent(), Result, SpillLoc});
DebugPHINumToValue.push_back(DbgPHI);
} else {
// Else: if the operand is neither a legal register or a stack slot, then