From edb4a5cb369bd87e69ffe8f30132c7b5dd5268a5 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 30 Jun 2020 11:20:12 -0400 Subject: [PATCH] TailDuplicator: Use Register --- llvm/include/llvm/CodeGen/TailDuplicator.h | 22 +++++------ llvm/lib/CodeGen/TailDuplicator.cpp | 44 +++++++++++----------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TailDuplicator.h b/llvm/include/llvm/CodeGen/TailDuplicator.h index 0903b93e50eb..6862bb2c3f44 100644 --- a/llvm/include/llvm/CodeGen/TailDuplicator.h +++ b/llvm/include/llvm/CodeGen/TailDuplicator.h @@ -50,13 +50,13 @@ class TailDuplicator { unsigned TailDupSize; // A list of virtual registers for which to update SSA form. - SmallVector SSAUpdateVRs; + SmallVector SSAUpdateVRs; // For each virtual register in SSAUpdateVals keep a list of source virtual // registers. - using AvailableValsTy = std::vector>; + using AvailableValsTy = std::vector>; - DenseMap SSAUpdateVals; + DenseMap SSAUpdateVals; public: /// Prepare to run on a specific machine function. @@ -98,24 +98,24 @@ public: private: using RegSubRegPair = TargetInstrInfo::RegSubRegPair; - void addSSAUpdateEntry(unsigned OrigReg, unsigned NewReg, + void addSSAUpdateEntry(Register OrigReg, Register NewReg, MachineBasicBlock *BB); void processPHI(MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, - DenseMap &LocalVRMap, - SmallVectorImpl> &Copies, - const DenseSet &UsedByPhi, bool Remove); + DenseMap &LocalVRMap, + SmallVectorImpl> &Copies, + const DenseSet &UsedByPhi, bool Remove); void duplicateInstruction(MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, - DenseMap &LocalVRMap, - const DenseSet &UsedByPhi); + DenseMap &LocalVRMap, + const DenseSet &UsedByPhi); void updateSuccessorsPHIs(MachineBasicBlock *FromBB, bool isDead, SmallVectorImpl &TDBBs, SmallSetVector &Succs); bool canCompletelyDuplicateBB(MachineBasicBlock &BB); bool duplicateSimpleBB(MachineBasicBlock *TailBB, SmallVectorImpl &TDBBs, - const DenseSet &RegsUsedByPhi, + const DenseSet &RegsUsedByPhi, SmallVectorImpl &Copies); bool tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, @@ -124,7 +124,7 @@ private: SmallVectorImpl &Copies, SmallVectorImpl *CandidatePtr); void appendCopies(MachineBasicBlock *MBB, - SmallVectorImpl> &CopyInfos, + SmallVectorImpl> &CopyInfos, SmallVectorImpl &Copies); void removeDeadBlock( diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index e3ecf52f875d..36b1809cb33c 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -206,11 +206,11 @@ bool TailDuplicator::tailDuplicateAndUpdate( } // Add the new vregs as available values. - DenseMap::iterator LI = + DenseMap::iterator LI = SSAUpdateVals.find(VReg); for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { MachineBasicBlock *SrcBB = LI->second[j].first; - unsigned SrcReg = LI->second[j].second; + Register SrcReg = LI->second[j].second; SSAUpdate.AddAvailableValue(SrcBB, SrcReg); } @@ -294,7 +294,7 @@ bool TailDuplicator::tailDuplicateBlocks() { return MadeChange; } -static bool isDefLiveOut(unsigned Reg, MachineBasicBlock *BB, +static bool isDefLiveOut(Register Reg, MachineBasicBlock *BB, const MachineRegisterInfo *MRI) { for (MachineInstr &UseMI : MRI->use_instructions(Reg)) { if (UseMI.isDebugValue()) @@ -316,7 +316,7 @@ static unsigned getPHISrcRegOpIdx(MachineInstr *MI, MachineBasicBlock *SrcBB) { // used to determine which registers are liveout while modifying the // block (which is why we need to copy the information). static void getRegsUsedByPHIs(const MachineBasicBlock &BB, - DenseSet *UsedByPhi) { + DenseSet *UsedByPhi) { for (const auto &MI : BB) { if (!MI.isPHI()) break; @@ -328,9 +328,9 @@ static void getRegsUsedByPHIs(const MachineBasicBlock &BB, } /// Add a definition and source virtual registers pair for SSA update. -void TailDuplicator::addSSAUpdateEntry(unsigned OrigReg, unsigned NewReg, +void TailDuplicator::addSSAUpdateEntry(Register OrigReg, Register NewReg, MachineBasicBlock *BB) { - DenseMap::iterator LI = + DenseMap::iterator LI = SSAUpdateVals.find(OrigReg); if (LI != SSAUpdateVals.end()) LI->second.push_back(std::make_pair(BB, NewReg)); @@ -346,9 +346,9 @@ void TailDuplicator::addSSAUpdateEntry(unsigned OrigReg, unsigned NewReg, /// source register that's contributed by PredBB and update SSA update map. void TailDuplicator::processPHI( MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, - DenseMap &LocalVRMap, - SmallVectorImpl> &Copies, - const DenseSet &RegsUsedByPhi, bool Remove) { + DenseMap &LocalVRMap, + SmallVectorImpl> &Copies, + const DenseSet &RegsUsedByPhi, bool Remove) { Register DefReg = MI->getOperand(0).getReg(); unsigned SrcOpIdx = getPHISrcRegOpIdx(MI, PredBB); assert(SrcOpIdx && "Unable to find matching PHI source?"); @@ -378,8 +378,8 @@ void TailDuplicator::processPHI( /// the source operands due to earlier PHI translation. void TailDuplicator::duplicateInstruction( MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, - DenseMap &LocalVRMap, - const DenseSet &UsedByPhi) { + DenseMap &LocalVRMap, + const DenseSet &UsedByPhi) { // Allow duplication of CFI instructions. if (MI->isCFIInstruction()) { BuildMI(*PredBB, PredBB->end(), PredBB->findDebugLoc(PredBB->begin()), @@ -504,7 +504,7 @@ void TailDuplicator::updateSuccessorsPHIs( // If Idx is set, the operands at Idx and Idx+1 must be removed. // We reuse the location to avoid expensive RemoveOperand calls. - DenseMap::iterator LI = + DenseMap::iterator LI = SSAUpdateVals.find(Reg); if (LI != SSAUpdateVals.end()) { // This register is defined in the tail block. @@ -517,7 +517,7 @@ void TailDuplicator::updateSuccessorsPHIs( if (!SrcBB->isSuccessor(SuccBB)) continue; - unsigned SrcReg = LI->second[j].second; + Register SrcReg = LI->second[j].second; if (Idx != 0) { MI.getOperand(Idx).setReg(SrcReg); MI.getOperand(Idx + 1).setMBB(SrcBB); @@ -708,7 +708,7 @@ bool TailDuplicator::canCompletelyDuplicateBB(MachineBasicBlock &BB) { bool TailDuplicator::duplicateSimpleBB( MachineBasicBlock *TailBB, SmallVectorImpl &TDBBs, - const DenseSet &UsedByPhi, + const DenseSet &UsedByPhi, SmallVectorImpl &Copies) { SmallPtrSet Succs(TailBB->succ_begin(), TailBB->succ_end()); @@ -815,7 +815,7 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, bool ShouldUpdateTerminators = TailBB->canFallThrough(); - DenseSet UsedByPhi; + DenseSet UsedByPhi; getRegsUsedByPHIs(*TailBB, &UsedByPhi); if (IsSimple) @@ -860,8 +860,8 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, TII->removeBranch(*PredBB); // Clone the contents of TailBB into PredBB. - DenseMap LocalVRMap; - SmallVector, 4> CopyInfos; + DenseMap LocalVRMap; + SmallVector, 4> CopyInfos; for (MachineBasicBlock::iterator I = TailBB->begin(), E = TailBB->end(); I != E; /* empty */) { MachineInstr *MI = &*I; @@ -920,8 +920,8 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, // duplicating the instructions in all cases. TII->removeBranch(*PrevBB); if (PreRegAlloc) { - DenseMap LocalVRMap; - SmallVector, 4> CopyInfos; + DenseMap LocalVRMap; + SmallVector, 4> CopyInfos; MachineBasicBlock::iterator I = TailBB->begin(); // Process PHI instructions first. while (I != TailBB->end() && I->isPHI()) { @@ -988,8 +988,8 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, if (PredBB->succ_size() != 1) continue; - DenseMap LocalVRMap; - SmallVector, 4> CopyInfos; + DenseMap LocalVRMap; + SmallVector, 4> CopyInfos; MachineBasicBlock::iterator I = TailBB->begin(); // Process PHI instructions first. while (I != TailBB->end() && I->isPHI()) { @@ -1007,7 +1007,7 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, /// At the end of the block \p MBB generate COPY instructions between registers /// described by \p CopyInfos. Append resulting instructions to \p Copies. void TailDuplicator::appendCopies(MachineBasicBlock *MBB, - SmallVectorImpl> &CopyInfos, + SmallVectorImpl> &CopyInfos, SmallVectorImpl &Copies) { MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); const MCInstrDesc &CopyD = TII->get(TargetOpcode::COPY);