Skip to content

Commit 48d2446

Browse files
preameszmodem
authored andcommitted
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. (cherry picked from commit 14845b2)
1 parent f87cc45 commit 48d2446

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
@@ -790,41 +790,6 @@ class ControlFlowHoister {
790790
};
791791
} // namespace
792792

793-
794-
/// Return true if we know how to rewrite all uses of the given alloca after
795-
/// hoisting it out of the loop. The main concerns are a) potential captures
796-
/// and b) invariant.start markers which don't capture, but are no longer
797-
/// valid w/o a corresponding invariant.end.
798-
static bool canRewriteUsesOfAlloca(AllocaInst &AI) {
799-
// TODO: This looks a lot like capture tracking, but we need to remove any
800-
// invariant starts if we extend the lifetime of the alloca by hoisting it.
801-
// We should probably refactor capture tracking into a form which allows us
802-
// to reuse the relevant bits and remove the duplicated logic here.
803-
804-
SmallVector<Use *, 16> Worklist;
805-
for (Use &U : AI.uses())
806-
Worklist.push_back(&U);
807-
808-
unsigned NumUsesExplored = 0;
809-
while (!Worklist.empty()) {
810-
Use *U = Worklist.pop_back_val();
811-
Instruction *I = cast<Instruction>(U->getUser());
812-
NumUsesExplored++;
813-
if (NumUsesExplored > DefaultMaxUsesToExplore)
814-
return false;
815-
// Non capturing, terminating uses
816-
if (isa<LoadInst>(I) ||
817-
(isa<StoreInst>(I) && U->getOperandNo() == 1))
818-
continue;
819-
// Non capturing, non-terminating
820-
if (!isa<BitCastInst>(I) && !isa<GetElementPtrInst>(I))
821-
return false;
822-
for (Use &U : I->uses())
823-
Worklist.push_back(&U);
824-
}
825-
return true;
826-
}
827-
828793
/// Walk the specified region of the CFG (defined by all blocks dominated by
829794
/// the specified block, and that are in the current loop) in depth first
830795
/// order w.r.t the DominatorTree. This allows us to visit definitions before
@@ -945,16 +910,6 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
945910
continue;
946911
}
947912

948-
if (isa<AllocaInst>(&I) &&
949-
SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop) &&
950-
canRewriteUsesOfAlloca(cast<AllocaInst>(I))) {
951-
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
952-
MSSAU, SE, ORE);
953-
HoistedInstructions.push_back(&I);
954-
Changed = true;
955-
continue;
956-
}
957-
958913
if (PHINode *PN = dyn_cast<PHINode>(&I)) {
959914
if (CFH.canHoistPHI(PN)) {
960915
// 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)