forked from OSchip/llvm-project
[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
This commit is contained in:
parent
0d1d363c51
commit
ab93e71065
|
@ -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,
|
||||
/// location dataflow problem.
|
||||
void
|
||||
produceMLocTransferFunction(MachineFunction &MF,
|
||||
SmallVectorImpl<MLocTransferMap> &MLocTransfer,
|
||||
unsigned MaxNumBlocks,
|
||||
SmallVectorImpl<VLocTracker> &VLocs);
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue