From a26d00a67cd72ae6adc4f743690d6f0a77e54856 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Wed, 5 Dec 2018 10:16:21 +0000 Subject: [PATCH] [LICM] *Actually* disable ControlFlowHoisting. Summary: The remaining code paths that ControlFlowHoisting introduced that were not disabled, increased compile time by 3x for some benchmarks. The time is spent in DominatorTree updates. Reviewers: john.brawn, mkazantsev Subscribers: sanjoy, jlebar, llvm-commits Differential Revision: https://reviews.llvm.org/D55313 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348345 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LICM.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index ff94e86c7da..695eaf6cf4a 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -566,6 +566,8 @@ public: } BasicBlock *getOrCreateHoistedBlock(BasicBlock *BB) { + if (!ControlFlowHoisting) + return CurLoop->getLoopPreheader(); // If BB has already been hoisted, return that if (HoistDestinationMap.count(BB)) return HoistDestinationMap[BB]; @@ -801,21 +803,24 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI, // and also keep track of where in the block we are rehoisting to to make sure // that we rehoist instructions before the instructions that use them. Instruction *HoistPoint = nullptr; - for (Instruction *I : reverse(HoistedInstructions)) { - if (!llvm::all_of(I->uses(), [&](Use &U) { return DT->dominates(I, U); })) { - BasicBlock *Dominator = - DT->getNode(I->getParent())->getIDom()->getBlock(); - LLVM_DEBUG(dbgs() << "LICM rehoisting to " << Dominator->getName() << ": " - << *I << "\n"); - if (!HoistPoint || HoistPoint->getParent() != Dominator) { - if (HoistPoint) - assert(DT->dominates(Dominator, HoistPoint->getParent()) && - "New hoist point expected to dominate old hoist point"); - HoistPoint = Dominator->getTerminator(); + if (ControlFlowHoisting) { + for (Instruction *I : reverse(HoistedInstructions)) { + if (!llvm::all_of(I->uses(), + [&](Use &U) { return DT->dominates(I, U); })) { + BasicBlock *Dominator = + DT->getNode(I->getParent())->getIDom()->getBlock(); + LLVM_DEBUG(dbgs() << "LICM rehoisting to " << Dominator->getName() + << ": " << *I << "\n"); + if (!HoistPoint || HoistPoint->getParent() != Dominator) { + if (HoistPoint) + assert(DT->dominates(Dominator, HoistPoint->getParent()) && + "New hoist point expected to dominate old hoist point"); + HoistPoint = Dominator->getTerminator(); + } + moveInstructionBefore(*I, *HoistPoint, *SafetyInfo); + HoistPoint = I; + Changed = true; } - moveInstructionBefore(*I, *HoistPoint, *SafetyInfo); - HoistPoint = I; - Changed = true; } }