diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/CodeGen/InlineSpiller.cpp | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
download | src-344a3780b2e33f6ca763666c380202b18aab72a3.tar.gz src-344a3780b2e33f6ca763666c380202b18aab72a3.zip |
Vendor import of llvm-project main 88e66fa60ae5, the last commit beforevendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
the upstream release/13.x branch was created.
Diffstat (limited to 'llvm/lib/CodeGen/InlineSpiller.cpp')
-rw-r--r-- | llvm/lib/CodeGen/InlineSpiller.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index 876e1d3f932a..71e91b445d9a 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -173,7 +173,7 @@ class InlineSpiller : public Spiller { LiveRangeEdit *Edit; LiveInterval *StackInt; int StackSlot; - unsigned Original; + Register Original; // All registers to spill to StackSlot, including the main register. SmallVector<Register, 8> RegsToSpill; @@ -191,19 +191,23 @@ class InlineSpiller : public Spiller { // Object records spills information and does the hoisting. HoistSpillHelper HSpiller; + // Live range weight calculator. + VirtRegAuxInfo &VRAI; + ~InlineSpiller() override = default; public: - InlineSpiller(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm) - : MF(mf), LIS(pass.getAnalysis<LiveIntervals>()), - LSS(pass.getAnalysis<LiveStacks>()), - AA(&pass.getAnalysis<AAResultsWrapperPass>().getAAResults()), - MDT(pass.getAnalysis<MachineDominatorTree>()), - Loops(pass.getAnalysis<MachineLoopInfo>()), VRM(vrm), - MRI(mf.getRegInfo()), TII(*mf.getSubtarget().getInstrInfo()), - TRI(*mf.getSubtarget().getRegisterInfo()), - MBFI(pass.getAnalysis<MachineBlockFrequencyInfo>()), - HSpiller(pass, mf, vrm) {} + InlineSpiller(MachineFunctionPass &Pass, MachineFunction &MF, VirtRegMap &VRM, + VirtRegAuxInfo &VRAI) + : MF(MF), LIS(Pass.getAnalysis<LiveIntervals>()), + LSS(Pass.getAnalysis<LiveStacks>()), + AA(&Pass.getAnalysis<AAResultsWrapperPass>().getAAResults()), + MDT(Pass.getAnalysis<MachineDominatorTree>()), + Loops(Pass.getAnalysis<MachineLoopInfo>()), VRM(VRM), + MRI(MF.getRegInfo()), TII(*MF.getSubtarget().getInstrInfo()), + TRI(*MF.getSubtarget().getRegisterInfo()), + MBFI(Pass.getAnalysis<MachineBlockFrequencyInfo>()), + HSpiller(Pass, MF, VRM), VRAI(VRAI) {} void spill(LiveRangeEdit &) override; void postOptimization() override; @@ -239,10 +243,10 @@ Spiller::~Spiller() = default; void Spiller::anchor() {} -Spiller *llvm::createInlineSpiller(MachineFunctionPass &pass, - MachineFunction &mf, - VirtRegMap &vrm) { - return new InlineSpiller(pass, mf, vrm); +Spiller *llvm::createInlineSpiller(MachineFunctionPass &Pass, + MachineFunction &MF, VirtRegMap &VRM, + VirtRegAuxInfo &VRAI) { + return new InlineSpiller(Pass, MF, VRM, VRAI); } //===----------------------------------------------------------------------===// @@ -1044,7 +1048,7 @@ void InlineSpiller::spillAroundUses(Register Reg) { // Modify DBG_VALUE now that the value is in a spill slot. MachineBasicBlock *MBB = MI->getParent(); LLVM_DEBUG(dbgs() << "Modifying debug info due to spill:\t" << *MI); - buildDbgValueForSpill(*MBB, MI, *MI, StackSlot); + buildDbgValueForSpill(*MBB, MI, *MI, StackSlot, Reg); MBB->erase(MI); continue; } @@ -1200,7 +1204,7 @@ void InlineSpiller::spill(LiveRangeEdit &edit) { if (!RegsToSpill.empty()) spillAll(); - Edit->calculateRegClassAndHint(MF, Loops, MBFI); + Edit->calculateRegClassAndHint(MF, VRAI); } /// Optimizations after all the reg selections and spills are done. @@ -1241,13 +1245,16 @@ bool HoistSpillHelper::rmFromMergeableSpills(MachineInstr &Spill, /// i.e., there should be a living sibling of OrigReg at the insert point. bool HoistSpillHelper::isSpillCandBB(LiveInterval &OrigLI, VNInfo &OrigVNI, MachineBasicBlock &BB, Register &LiveReg) { - SlotIndex Idx; + SlotIndex Idx = IPA.getLastInsertPoint(OrigLI, BB); + // The original def could be after the last insert point in the root block, + // we can't hoist to here. + if (Idx < OrigVNI.def) { + // TODO: We could be better here. If LI is not alive in landing pad + // we could hoist spill after LIP. + LLVM_DEBUG(dbgs() << "can't spill in root block - def after LIP\n"); + return false; + } Register OrigReg = OrigLI.reg(); - MachineBasicBlock::iterator MI = IPA.getLastInsertPointIter(OrigLI, BB); - if (MI != BB.end()) - Idx = LIS.getInstructionIndex(*MI); - else - Idx = LIS.getMBBEndIdx(&BB).getPrevSlot(); SmallSetVector<Register, 16> &Siblings = Virt2SiblingsMap[OrigReg]; assert(OrigLI.getVNInfoAt(Idx) == &OrigVNI && "Unexpected VNI"); |