diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2022-04-25 14:06:12 +0100 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2022-04-25 14:06:12 +0100 |
commit | 13815e8cbf8d49b20f2c9d521a7cc6f5153ff9da (patch) | |
tree | cb2b2620d4c9ed43731ba6c7609b6919eac526d5 /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | |
parent | 36ba89b5b342bb450eec37d646e2ec11315fd315 (diff) | |
download | llvm-13815e8cbf8d49b20f2c9d521a7cc6f5153ff9da.zip llvm-13815e8cbf8d49b20f2c9d521a7cc6f5153ff9da.tar.gz llvm-13815e8cbf8d49b20f2c9d521a7cc6f5153ff9da.tar.bz2 |
Revert "[DebugInfo][InstrRef] Add a size operand to DBG_PHI"
This reverts commit fda4305e5378478051be225248bfe9c1d401d938.
Green dragon has spotted a problem -- it's understood, but might be fiddly
to fix, reverting in the meantime.
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 72d025e..74f6e6e8 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -1293,16 +1293,41 @@ bool InstrRefBasedLDV::transferDebugPHI(MachineInstr &MI) { if (!SpillNo) return EmitBadPHI(); - // 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(); + // 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; + } + } - unsigned SpillID = MTracker->getLocID(*SpillNo, {slotBitSize, 0}); - LocIdx SpillLoc = MTracker->getSpillMLoc(SpillID); - ValueIDNum Result = MTracker->readMLoc(SpillLoc); + // 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); + } // 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 |