From: Florian Hahn Date: Tue, 30 Jul 2019 17:04:58 +0000 (+0000) Subject: Revert [GVN] Preserve loop related analysis/canonical forms. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0b6f42936bfb6d56d325c732ae79400c9c6016a;p=platform%2Fupstream%2Fllvm.git Revert [GVN] Preserve loop related analysis/canonical forms. This reverts r367332 (git commit 2d7227ec3ac91f36fc32b1c21e72e2f1f5d030ad) llvm-svn: 367335 --- diff --git a/llvm/include/llvm/Analysis/CFG.h b/llvm/include/llvm/Analysis/CFG.h index 68f137b..bb55e76 100644 --- a/llvm/include/llvm/Analysis/CFG.h +++ b/llvm/include/llvm/Analysis/CFG.h @@ -46,8 +46,6 @@ unsigned GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ); /// bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges = false); -bool isCriticalEdge(const Instruction *TI, const BasicBlock *Succ, - bool AllowIdenticalEdges = false); /// Determine whether instruction 'To' is reachable from 'From', without passing /// through any blocks in ExclusionSet, returning true if uncertain. diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h index 2c9287f..9fe00a9 100644 --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/llvm/include/llvm/Transforms/Scalar/GVN.h @@ -159,7 +159,6 @@ private: SetVector DeadBlocks; OptimizationRemarkEmitter *ORE; ImplicitControlFlowTracking *ICF; - LoopInfo *LI; ValueTable VN; diff --git a/llvm/lib/Analysis/CFG.cpp b/llvm/lib/Analysis/CFG.cpp index 8215b4e..18b83d6 100644 --- a/llvm/lib/Analysis/CFG.cpp +++ b/llvm/lib/Analysis/CFG.cpp @@ -87,18 +87,11 @@ unsigned llvm::GetSuccessorNumber(const BasicBlock *BB, /// with multiple predecessors. bool llvm::isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges) { - assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!"); - return isCriticalEdge(TI, TI->getSuccessor(SuccNum), AllowIdenticalEdges); -} - -bool llvm::isCriticalEdge(const Instruction *TI, const BasicBlock *Dest, - bool AllowIdenticalEdges) { assert(TI->isTerminator() && "Must be a terminator to have successors!"); + assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!"); if (TI->getNumSuccessors() == 1) return false; - assert(find(predecessors(Dest), TI->getParent()) != pred_end(Dest) && - "No edge between TI's block and Dest."); - + const BasicBlock *Dest = TI->getSuccessor(SuccNum); const_pred_iterator I = pred_begin(Dest), E = pred_end(Dest); // If there is more than one predecessor, this is a critical edge... diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 29911a4..1a02e9d 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -70,7 +70,6 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/SSAUpdater.h" @@ -627,8 +626,6 @@ PreservedAnalyses GVN::run(Function &F, FunctionAnalysisManager &AM) { PA.preserve(); PA.preserve(); PA.preserve(); - if (LI) - PA.preserve(); return PA; } @@ -1979,7 +1976,6 @@ bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT, MD = RunMD; ImplicitControlFlowTracking ImplicitCFT(DT); ICF = &ImplicitCFT; - this->LI = LI; VN.setMemDep(MD); ORE = RunORE; InvalidBlockRPONumbers = true; @@ -2339,7 +2335,7 @@ bool GVN::performPRE(Function &F) { /// the block inserted to the critical edge. BasicBlock *GVN::splitCriticalEdges(BasicBlock *Pred, BasicBlock *Succ) { BasicBlock *BB = - SplitCriticalEdge(Pred, Succ, CriticalEdgeSplittingOptions(DT, LI)); + SplitCriticalEdge(Pred, Succ, CriticalEdgeSplittingOptions(DT)); if (MD) MD->invalidateCachedPredecessors(); InvalidBlockRPONumbers = true; @@ -2354,7 +2350,7 @@ bool GVN::splitCriticalEdges() { do { std::pair Edge = toSplit.pop_back_val(); SplitCriticalEdge(Edge.first, Edge.second, - CriticalEdgeSplittingOptions(DT, LI)); + CriticalEdgeSplittingOptions(DT)); } while (!toSplit.empty()); if (MD) MD->invalidateCachedPredecessors(); InvalidBlockRPONumbers = true; @@ -2460,26 +2456,18 @@ void GVN::addDeadBlock(BasicBlock *BB) { if (DeadBlocks.count(B)) continue; - // First, split the critical edges. This might also create additional blocks - // to preserve LoopSimplify form and adjust edges accordingly. SmallVector Preds(pred_begin(B), pred_end(B)); for (BasicBlock *P : Preds) { if (!DeadBlocks.count(P)) continue; - if (llvm::any_of(successors(P), - [B](BasicBlock *Succ) { return Succ == B; }) && - isCriticalEdge(P->getTerminator(), B)) { + if (isCriticalEdge(P->getTerminator(), GetSuccessorNumber(P, B))) { if (BasicBlock *S = splitCriticalEdges(P, B)) DeadBlocks.insert(P = S); } - } - // Now undef the incoming values from the dead predecessors. - for (BasicBlock *P : predecessors(B)) { - if (!DeadBlocks.count(P)) - continue; - for (PHINode &Phi : B->phis()) { + for (BasicBlock::iterator II = B->begin(); isa(II); ++II) { + PHINode &Phi = cast(*II); Phi.setIncomingValueForBlock(P, UndefValue::get(Phi.getType())); if (MD) MD->invalidateCachedPointerInfo(&Phi); @@ -2568,7 +2556,6 @@ public: AU.addRequired(); AU.addRequired(); AU.addRequired(); - AU.addRequired(); if (!NoMemDepAnalysis) AU.addRequired(); AU.addRequired(); @@ -2576,8 +2563,6 @@ public: AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); - AU.addPreserved(); - AU.addPreservedID(LoopSimplifyID); AU.addRequired(); } diff --git a/llvm/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll b/llvm/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll index 6592c69..05dc79d 100644 --- a/llvm/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll +++ b/llvm/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll @@ -50,14 +50,8 @@ bb15: %tmp18 = icmp eq i8 %tmp17, 0 br label %bb19 -; CHECK-LABEL: bb6: -; CHECK: br i1 undef, label %bb15split, label %bb10 - -; CHECK-LABEL: bb15split: ; preds = %bb6 -; CHECK-NEXT: br label %bb15 - -; CHECK-LABEL: bb15: -; CHECK: %tmp17 = phi i8 [ %tmp8, %bb15split ], [ %tmp17.pre, %bb1.bb15_crit_edge ] +; CHECK: bb15: +; CHECK: %tmp17 = phi i8 [ %tmp17.pre, %bb1.bb15_crit_edge ], [ %tmp8, %bb6 ] bb19: ; preds = %bb15 ret i1 %tmp18 diff --git a/llvm/test/Transforms/GVN/preserve-analysis.ll b/llvm/test/Transforms/GVN/preserve-analysis.ll deleted file mode 100644 index 2454bb1a..0000000 --- a/llvm/test/Transforms/GVN/preserve-analysis.ll +++ /dev/null @@ -1,56 +0,0 @@ -; RUN: opt < %s -debug-pass=Structure -indvars -gvn -indvars 2>&1 -S | FileCheck --check-prefix=CHECK --check-prefix=IR %s -; RUN: opt < %s -debug-pass-manager -passes='require,loop(simplify-cfg),gvn,loop(indvars)' 2>&1 -S | FileCheck --check-prefix=NEW-PM --check-prefix=IR %s - -; Check CFG-only analysis are preserved by SCCP by running it between 2 -; loop-vectorize runs. - -; CHECK: Dominator Tree Construction -; CHECK: Natural Loop Information -; CHECK: Canonicalize natural loops -; CHECK: LCSSA Verifier -; CHECK: Loop-Closed SSA Form Pass -; CHECK: Global Value Numbering -; CHECK-NOT: Dominator Tree Construction -; CHECK-NOT: Natural Loop Information -; CHECK-NOT: Canonicalize natural loops - -; NEW-PM-DAG: Running analysis: LoopAnalysis on test -; NEW-PM-DAG: Running analysis: DominatorTreeAnalysis on test -; NEW-PM: Running pass: GVN on test -; NEW-PM-NOT: Running analysis: LoopAnalysis on test -; NEW-PM-NOT: Running analysis: DominatorTreeAnalysis on test - -declare i1 @cond() -declare void @dostuff() - -define i32 @test() { -; IR-LABEL: define i32 @test() -; IR-LABEL: header: -; IR: br i1 false, label %then, label %latch -; IR-LABEL: then: -; IR-NEXT: call void @dostuff() -; IR-NEXT: br label %latch -entry: - %res = add i32 1, 10 - br label %header - -header: - %iv = phi i32 [ %res, %entry ], [ 0, %latch ] - %ic = icmp eq i32 %res, 99 - br i1 %ic, label %then, label %latch - -then: - br label %then.2 - -then.2: - call void @dostuff() - br label %latch - - -latch: - %ec = call i1 @cond() - br i1 %ec, label %exit, label %header - -exit: - ret i32 %iv -}