diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2020-10-23 11:06:51 +0100 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2020-10-23 11:13:20 +0100 |
commit | ab93e710652f764bf2ab51710980e7828ebe4a8b (patch) | |
tree | 41e35f76f493dd6dc22d97092f2da2e946e20a58 /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | |
parent | 0d1d363c51c93614783755426cb58c819c164fab (diff) | |
download | llvm-ab93e710652f764bf2ab51710980e7828ebe4a8b.zip llvm-ab93e710652f764bf2ab51710980e7828ebe4a8b.tar.gz llvm-ab93e710652f764bf2ab51710980e7828ebe4a8b.tar.bz2 |
[DebugInstrRef] NFC: Separate collection of machine/variable values
This patch adjusts _when_ something happens in LiveDebugValues /
InstrRefBasedLDV, to make it more amenable to dealing with DBG_INSTR_REF
instructions. There's no functional change.
In the current InstrRefBasedLDV implementation, we collect the machine
value-number transfer function for blocks at the same time as the
variable-value transfer function. After solving machine value numbers, the
variable-value transfer function is updated so that DBG_VALUEs of live-in
registers have the correct value. The same would need to be done for
DBG_INSTR_REFs, to connect instruction-references with machine value
numbers.
Rather than writing more code for that, this patch separates the two: we
collect the (machine-value-number) transfer function and solve for
machine value numbers, then step through the MachineInstrs again collecting
the variable value transfer function. This simplifies things for the new
few patches.
Differential Revision: https://reviews.llvm.org/D85760
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 1713700..0d10c7c 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -1324,13 +1324,11 @@ private: /// Step through the function, recording register definitions and movements /// in an MLocTracker. Convert the observations into a per-block transfer /// function in \p MLocTransfer, suitable for using with the machine value - /// location dataflow problem. Do the same with VLoc trackers in \p VLocs, - /// although the precise machine value numbers can't be known until after - /// the machine value number problem is solved. - void produceTransferFunctions(MachineFunction &MF, - SmallVectorImpl<MLocTransferMap> &MLocTransfer, - unsigned MaxNumBlocks, - SmallVectorImpl<VLocTracker> &VLocs); + /// location dataflow problem. + void + produceMLocTransferFunction(MachineFunction &MF, + SmallVectorImpl<MLocTransferMap> &MLocTransfer, + unsigned MaxNumBlocks); /// Solve the machine value location dataflow problem. Takes as input the /// transfer functions in \p MLocTransfer. Writes the output live-in and @@ -1925,9 +1923,9 @@ void InstrRefBasedLDV::process(MachineInstr &MI) { transferRegisterDef(MI); } -void InstrRefBasedLDV::produceTransferFunctions( +void InstrRefBasedLDV::produceMLocTransferFunction( MachineFunction &MF, SmallVectorImpl<MLocTransferMap> &MLocTransfer, - unsigned MaxNumBlocks, SmallVectorImpl<VLocTracker> &VLocs) { + unsigned MaxNumBlocks) { // Because we try to optimize around register mask operands by ignoring regs // that aren't currently tracked, we set up something ugly for later: RegMask // operands that are seen earlier than the first use of a register, still need @@ -1956,9 +1954,6 @@ void InstrRefBasedLDV::produceTransferFunctions( MTracker->reset(); MTracker->setMPhis(CurBB); - VTracker = &VLocs[CurBB]; - VTracker->MBB = &MBB; - // Step through each instruction in this block. for (auto &MI : MBB) { process(MI); @@ -2809,7 +2804,6 @@ void InstrRefBasedLDV::vlocDataflow( CurBB, VarsWeCareAbout, MOutLocs, MInLocs, InScopeBlocks, BlocksToExplore, JoinedInLocs); - auto &VTracker = AllTheVLocs[MBB->getNumber()]; bool FirstVisit = VLOCVisited.insert(MBB).second; // Always explore transfer function if inlocs changed, or if we've not @@ -2821,23 +2815,11 @@ void InstrRefBasedLDV::vlocDataflow( if (DowngradeOccurred && OnPending.insert(MBB).second) Pending.push(BBToOrder[MBB]); - // Patch up the variable value transfer function to use the live-in - // machine values, now that that problem is solved. - if (FirstVisit) { - for (auto &Transfer : VTracker.Vars) { - if (Transfer.second.Kind == DbgValue::Def && - Transfer.second.ID.getBlock() == CurBB && - Transfer.second.ID.isPHI()) { - LocIdx Loc = Transfer.second.ID.getLoc(); - Transfer.second.ID = MInLocs[CurBB][Loc.asU64()]; - } - } - } - if (!InLocsChanged) continue; // Do transfer function. + auto &VTracker = AllTheVLocs[MBB->getNumber()]; for (auto &Transfer : VTracker.Vars) { // Is this var we're mangling in this scope? if (VarsWeCareAbout.count(Transfer.first)) { @@ -3035,7 +3017,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF, initialSetup(MF); - produceTransferFunctions(MF, MLocTransfer, MaxNumBlocks, vlocs); + produceMLocTransferFunction(MF, MLocTransfer, MaxNumBlocks); // Allocate and initialize two array-of-arrays for the live-in and live-out // machine values. The outer dimension is the block number; while the inner @@ -3054,6 +3036,22 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF, // dataflow problem. mlocDataflow(MInLocs, MOutLocs, MLocTransfer); + // Walk back through each block / instruction, collecting DBG_VALUE + // instructions and recording what machine value their operands refer to. + for (auto &OrderPair : OrderToBB) { + MachineBasicBlock &MBB = *OrderPair.second; + CurBB = MBB.getNumber(); + VTracker = &vlocs[CurBB]; + VTracker->MBB = &MBB; + MTracker->loadFromArray(MInLocs[CurBB], CurBB); + CurInst = 1; + for (auto &MI : MBB) { + process(MI); + ++CurInst; + } + MTracker->reset(); + } + // Number all variables in the order that they appear, to be used as a stable // insertion order later. DenseMap<DebugVariable, unsigned> AllVarsNumbering; |