Skip to content

Commit 14845b2

Browse files
committed
Revert "[LICM] Support hosting of dynamic allocas out of loops"
This reverts commit 8d22100. There was a functional regression reported (https://bugs.llvm.org/show_bug.cgi?id=44996). I'm not actually sure the patch is wrong, but I don't have time to investigate currently, and this line of work isn't something I'm likely to get back to quickly.
1 parent 69da400 commit 14845b2

File tree

2 files changed

+0
-213
lines changed

2 files changed

+0
-213
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -742,41 +742,6 @@ class ControlFlowHoister {
742742
};
743743
} // namespace
744744

745-
746-
/// Return true if we know how to rewrite all uses of the given alloca after
747-
/// hoisting it out of the loop. The main concerns are a) potential captures
748-
/// and b) invariant.start markers which don't capture, but are no longer
749-
/// valid w/o a corresponding invariant.end.
750-
static bool canRewriteUsesOfAlloca(AllocaInst &AI) {
751-
// TODO: This looks a lot like capture tracking, but we need to remove any
752-
// invariant starts if we extend the lifetime of the alloca by hoisting it.
753-
// We should probably refactor capture tracking into a form which allows us
754-
// to reuse the relevant bits and remove the duplicated logic here.
755-
756-
SmallVector<Use *, 16> Worklist;
757-
for (Use &U : AI.uses())
758-
Worklist.push_back(&U);
759-
760-
unsigned NumUsesExplored = 0;
761-
while (!Worklist.empty()) {
762-
Use *U = Worklist.pop_back_val();
763-
Instruction *I = cast<Instruction>(U->getUser());
764-
NumUsesExplored++;
765-
if (NumUsesExplored > DefaultMaxUsesToExplore)
766-
return false;
767-
// Non capturing, terminating uses
768-
if (isa<LoadInst>(I) ||
769-
(isa<StoreInst>(I) && U->getOperandNo() == 1))
770-
continue;
771-
// Non capturing, non-terminating
772-
if (!isa<BitCastInst>(I) && !isa<GetElementPtrInst>(I))
773-
return false;
774-
for (Use &U : I->uses())
775-
Worklist.push_back(&U);
776-
}
777-
return true;
778-
}
779-
780745
/// Walk the specified region of the CFG (defined by all blocks dominated by
781746
/// the specified block, and that are in the current loop) in depth first
782747
/// order w.r.t the DominatorTree. This allows us to visit definitions before
@@ -897,16 +862,6 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
897862
continue;
898863
}
899864

900-
if (isa<AllocaInst>(&I) &&
901-
SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop) &&
902-
canRewriteUsesOfAlloca(cast<AllocaInst>(I))) {
903-
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
904-
MSSAU, SE, ORE);
905-
HoistedInstructions.push_back(&I);
906-
Changed = true;
907-
continue;
908-
}
909-
910865
if (PHINode *PN = dyn_cast<PHINode>(&I)) {
911866
if (CFH.canHoistPHI(PN)) {
912867
// Redirect incoming blocks first to ensure that we create hoisted

llvm/test/Transforms/LICM/hoist-alloca.ll

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)