diff options
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index aeb8a20e..9037f75 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -2413,7 +2413,7 @@ bool InstrRefBasedLDV::mlocJoin( // Pick out the first predecessors live-out value for this location. It's // guaranteed to not be a backedge, as we order by RPO. - ValueIDNum FirstVal = OutLocs[BlockOrders[0]->getNumber()][Idx.asU64()]; + ValueIDNum FirstVal = OutLocs[*BlockOrders[0]][Idx.asU64()]; // If we've already eliminated a PHI here, do no further checking, just // propagate the first live-in value into this block. @@ -2430,8 +2430,7 @@ bool InstrRefBasedLDV::mlocJoin( bool Disagree = false; for (unsigned int I = 1; I < BlockOrders.size(); ++I) { const MachineBasicBlock *PredMBB = BlockOrders[I]; - const ValueIDNum &PredLiveOut = - OutLocs[PredMBB->getNumber()][Idx.asU64()]; + const ValueIDNum &PredLiveOut = OutLocs[*PredMBB][Idx.asU64()]; // Incoming values agree, continue trying to eliminate this PHI. if (FirstVal == PredLiveOut) @@ -2556,7 +2555,7 @@ void InstrRefBasedLDV::placeMLocPHIs( auto InstallPHIsAtLoc = [&PHIBlocks, &MInLocs](LocIdx L) { for (const MachineBasicBlock *MBB : PHIBlocks) - MInLocs[MBB->getNumber()][L.asU64()] = ValueIDNum(MBB->getNumber(), 0, L); + MInLocs[*MBB][L.asU64()] = ValueIDNum(MBB->getNumber(), 0, L); }; // For locations with no reg units, just place PHIs. @@ -2635,7 +2634,8 @@ void InstrRefBasedLDV::buildMLocValueMap( // Initialize entry block to PHIs. These represent arguments. for (auto Location : MTracker->locations()) - MInLocs[0][Location.Idx.asU64()] = ValueIDNum(0, 0, Location.Idx); + MInLocs.tableForEntryMBB()[Location.Idx.asU64()] = + ValueIDNum(0, 0, Location.Idx); MTracker->reset(); @@ -2664,7 +2664,7 @@ void InstrRefBasedLDV::buildMLocValueMap( // Join the values in all predecessor blocks. bool InLocsChanged; - InLocsChanged = mlocJoin(*MBB, Visited, MOutLocs, MInLocs[CurBB]); + InLocsChanged = mlocJoin(*MBB, Visited, MOutLocs, MInLocs[*MBB]); InLocsChanged |= Visited.insert(MBB).second; // Don't examine transfer function if we've visited this loc at least @@ -2673,7 +2673,7 @@ void InstrRefBasedLDV::buildMLocValueMap( continue; // Load the current set of live-ins into MLocTracker. - MTracker->loadFromArray(MInLocs[CurBB], CurBB); + MTracker->loadFromArray(MInLocs[*MBB], CurBB); // Each element of the transfer function can be a new def, or a read of // a live-in value. Evaluate each element, and store to "ToRemap". @@ -2700,8 +2700,8 @@ void InstrRefBasedLDV::buildMLocValueMap( // the transfer function, and mlocJoin. bool OLChanged = false; for (auto Location : MTracker->locations()) { - OLChanged |= MOutLocs[CurBB][Location.Idx.asU64()] != Location.Value; - MOutLocs[CurBB][Location.Idx.asU64()] = Location.Value; + OLChanged |= MOutLocs[*MBB][Location.Idx.asU64()] != Location.Value; + MOutLocs[*MBB][Location.Idx.asU64()] = Location.Value; } MTracker->reset(); @@ -2844,7 +2844,6 @@ std::optional<ValueIDNum> InstrRefBasedLDV::pickOperandPHILoc( unsigned NumLocs = MTracker->getNumLocs(); for (const auto p : BlockOrders) { - unsigned ThisBBNum = p->getNumber(); auto OutValIt = LiveOuts.find(p); assert(OutValIt != LiveOuts.end()); const DbgValue &OutVal = *OutValIt->second; @@ -2863,7 +2862,7 @@ std::optional<ValueIDNum> InstrRefBasedLDV::pickOperandPHILoc( ValueIDNum ValToLookFor = OutValOp.ID; // Search the live-outs of the predecessor for the specified value. for (unsigned int I = 0; I < NumLocs; ++I) { - if (MOutLocs[ThisBBNum][I] == ValToLookFor) + if (MOutLocs[*p][I] == ValToLookFor) Locs.back().push_back(LocIdx(I)); } } else { @@ -2876,7 +2875,7 @@ std::optional<ValueIDNum> InstrRefBasedLDV::pickOperandPHILoc( // machine-value PHI locations. for (unsigned int I = 0; I < NumLocs; ++I) { ValueIDNum MPHI(MBB.getNumber(), 0, LocIdx(I)); - if (MOutLocs[ThisBBNum][I] == MPHI) + if (MOutLocs[*p][I] == MPHI) Locs.back().push_back(LocIdx(I)); } } @@ -3498,19 +3497,15 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit( // Helper lambda for ejecting a block -- if nothing is going to use the block, // we can translate the variable location information into DBG_VALUEs and then // free all of InstrRefBasedLDV's data structures. - SmallPtrSet<const MachineBasicBlock *, 8> EjectedBBs; auto EjectBlock = [&](MachineBasicBlock &MBB) -> void { - if (EjectedBBs.insert(&MBB).second == false) - return; unsigned BBNum = MBB.getNumber(); AllTheVLocs[BBNum].clear(); // Prime the transfer-tracker, and then step through all the block // instructions, installing transfers. MTracker->reset(); - MTracker->loadFromArray(MInLocs[BBNum], BBNum); - TTracker->loadInlocs(MBB, MInLocs[BBNum], DbgOpStore, Output[BBNum], - NumLocs); + MTracker->loadFromArray(MInLocs[MBB], BBNum); + TTracker->loadInlocs(MBB, MInLocs[MBB], DbgOpStore, Output[BBNum], NumLocs); CurBB = BBNum; CurInst = 1; @@ -3521,8 +3516,8 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit( } // Free machine-location tables for this block. - MInLocs[BBNum] = ValueTable(); - MOutLocs[BBNum] = ValueTable(); + MInLocs.ejectTableForBlock(MBB); + MOutLocs.ejectTableForBlock(MBB); // We don't need live-in variable values for this block either. Output[BBNum].clear(); AllTheVLocs[BBNum].clear(); @@ -3587,7 +3582,8 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit( // anything for such out-of-scope blocks, but for the sake of being similar // to VarLocBasedLDV, eject these too. for (auto *MBB : ArtificialBlocks) - EjectBlock(*MBB); + if (MInLocs.hasTableFor(*MBB)) + EjectBlock(*MBB); return emitTransfers(AllVarsNumbering); } @@ -3686,8 +3682,8 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF, // machine values. The outer dimension is the block number; while the inner // dimension is a LocIdx from MLocTracker. unsigned NumLocs = MTracker->getNumLocs(); - FuncValueTable MOutLocs(MaxNumBlocks, ValueTable(NumLocs)); - FuncValueTable MInLocs(MaxNumBlocks, ValueTable(NumLocs)); + FuncValueTable MOutLocs(MaxNumBlocks, NumLocs); + FuncValueTable MInLocs(MaxNumBlocks, NumLocs); // Solve the machine value dataflow problem using the MLocTransfer function, // storing the computed live-ins / live-outs into the array-of-arrays. We use @@ -3725,7 +3721,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF, CurBB = MBB.getNumber(); VTracker = &vlocs[CurBB]; VTracker->MBB = &MBB; - MTracker->loadFromArray(MInLocs[CurBB], CurBB); + MTracker->loadFromArray(MInLocs[MBB], CurBB); CurInst = 1; for (auto &MI : MBB) { process(MI, &MOutLocs, &MInLocs); @@ -3939,7 +3935,7 @@ public: /// Find the live-in value number for the given block. Looks up the value at /// the PHI location on entry. BlockValueNum getValue(LDVSSABlock *LDVBB) { - return MLiveIns[LDVBB->BB.getNumber()][Loc.asU64()].asU64(); + return MLiveIns[LDVBB->BB][Loc.asU64()].asU64(); } }; @@ -4179,8 +4175,7 @@ std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIsImpl( }); for (auto &PHI : SortedPHIs) { - ValueIDNum ThisBlockValueNum = - MLiveIns[PHI->ParentBlock->BB.getNumber()][Loc.asU64()]; + ValueIDNum ThisBlockValueNum = MLiveIns[PHI->ParentBlock->BB][Loc.asU64()]; // Are all these things actually defined? for (auto &PHIIt : PHI->IncomingValues) { @@ -4189,7 +4184,7 @@ std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIsImpl( return std::nullopt; ValueIDNum ValueToCheck; - const ValueTable &BlockLiveOuts = MLiveOuts[PHIIt.first->BB.getNumber()]; + const ValueTable &BlockLiveOuts = MLiveOuts[PHIIt.first->BB]; auto VVal = ValidatedValues.find(PHIIt.first); if (VVal == ValidatedValues.end()) { |