From f50c67ce7c99eb19a7392d1db2c51acf22396f53 Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Thu, 5 May 2016 20:47:53 +0000 Subject: [PATCH] Revert http://reviews.llvm.org/D19926 as it breaks tests. llvm-svn: 268681 --- .../llvm/Transforms/Scalar/SimplifyCFG.h | 11 ----- .../lib/Transforms/Scalar/SimplifyCFGPass.cpp | 48 ++++++++++--------- .../Transforms/Utils/AddDiscriminators.cpp | 6 --- .../Transforms/AddDiscriminators/multiple.ll | 6 ++- .../Transforms/AddDiscriminators/oneline.ll | 19 ++++++-- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h b/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h index 96b18a12558b..53f427a7d19a 100644 --- a/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h +++ b/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h @@ -39,17 +39,6 @@ public: PreservedAnalyses run(Function &F, AnalysisManager &AM); }; -struct CFGSimplifyPass : public FunctionPass { - static char ID; // Pass identification, replacement for typeid - unsigned BonusInstThreshold; - std::function PredicateFtor; - - CFGSimplifyPass(int T = -1, - std::function Ftor = nullptr); - bool runOnFunction(Function &F) override; - - void getAnalysisUsage(AnalysisUsage &AU) const override; -}; } #endif diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp index 97c5f183dcba..e69333369471 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -196,31 +196,35 @@ PreservedAnalyses SimplifyCFGPass::run(Function &F, return PreservedAnalyses::all(); } -CFGSimplifyPass::CFGSimplifyPass(int T, - std::function Ftor) - : FunctionPass(ID), PredicateFtor(Ftor) { - BonusInstThreshold = (T == -1) ? UserBonusInstThreshold : unsigned(T); - initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry()); -} +namespace { +struct CFGSimplifyPass : public FunctionPass { + static char ID; // Pass identification, replacement for typeid + unsigned BonusInstThreshold; + std::function PredicateFtor; -bool CFGSimplifyPass::runOnFunction(Function &F) { - if (PredicateFtor && !PredicateFtor(F)) - return false; + CFGSimplifyPass(int T = -1, + std::function Ftor = nullptr) + : FunctionPass(ID), PredicateFtor(Ftor) { + BonusInstThreshold = (T == -1) ? UserBonusInstThreshold : unsigned(T); + initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry()); + } + bool runOnFunction(Function &F) override { + if (skipFunction(F) || (PredicateFtor && !PredicateFtor(F))) + return false; - if (skipFunction(F)) - return false; + AssumptionCache *AC = + &getAnalysis().getAssumptionCache(F); + const TargetTransformInfo &TTI = + getAnalysis().getTTI(F); + return simplifyFunctionCFG(F, TTI, AC, BonusInstThreshold); + } - AssumptionCache *AC = - &getAnalysis().getAssumptionCache(F); - const TargetTransformInfo &TTI = - getAnalysis().getTTI(F); - return simplifyFunctionCFG(F, TTI, AC, BonusInstThreshold); -} - -void CFGSimplifyPass::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - AU.addRequired(); - AU.addPreserved(); + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.addRequired(); + AU.addRequired(); + AU.addPreserved(); + } +}; } char CFGSimplifyPass::ID = 0; diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp index 6c4db99efe36..2a6b6eb1b0b0 100644 --- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp +++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp @@ -67,7 +67,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/Scalar/SimplifyCFG.h" using namespace llvm; @@ -80,10 +79,6 @@ struct AddDiscriminators : public FunctionPass { initializeAddDiscriminatorsPass(*PassRegistry::getPassRegistry()); } - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired(); - } - bool runOnFunction(Function &F) override; }; } // end anonymous namespace @@ -91,7 +86,6 @@ struct AddDiscriminators : public FunctionPass { char AddDiscriminators::ID = 0; INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators", "Add DWARF path discriminators", false, false) -INITIALIZE_PASS_DEPENDENCY(CFGSimplifyPass) INITIALIZE_PASS_END(AddDiscriminators, "add-discriminators", "Add DWARF path discriminators", false, false) diff --git a/llvm/test/Transforms/AddDiscriminators/multiple.ll b/llvm/test/Transforms/AddDiscriminators/multiple.ll index c7306dc8f2e4..bacef89756b4 100644 --- a/llvm/test/Transforms/AddDiscriminators/multiple.ll +++ b/llvm/test/Transforms/AddDiscriminators/multiple.ll @@ -21,18 +21,20 @@ entry: if.then: ; preds = %entry %1 = load i32, i32* %i.addr, align 4, !dbg !10 +; CHECK: %1 = load i32, i32* %i.addr, align 4, !dbg ![[THEN:[0-9]+]] store i32 %1, i32* %x, align 4, !dbg !10 -; CHECK: store i32 %1, i32* %x, align 4, !dbg ![[THEN:[0-9]+]] +; CHECK: store i32 %1, i32* %x, align 4, !dbg ![[THEN]] br label %if.end, !dbg !10 ; CHECK: br label %if.end, !dbg ![[THEN]] if.else: ; preds = %entry %2 = load i32, i32* %i.addr, align 4, !dbg !10 +; CHECK: %2 = load i32, i32* %i.addr, align 4, !dbg ![[ELSE:[0-9]+]] %sub = sub nsw i32 0, %2, !dbg !10 -; CHECK: %sub = sub nsw i32 0, %1, !dbg ![[ELSE:[0-9]+]] +; CHECK: %sub = sub nsw i32 0, %2, !dbg ![[ELSE]] store i32 %sub, i32* %x, align 4, !dbg !10 ; CHECK: store i32 %sub, i32* %x, align 4, !dbg ![[ELSE]] diff --git a/llvm/test/Transforms/AddDiscriminators/oneline.ll b/llvm/test/Transforms/AddDiscriminators/oneline.ll index f0ac5a8d86d2..f07fa09ce0e7 100644 --- a/llvm/test/Transforms/AddDiscriminators/oneline.ll +++ b/llvm/test/Transforms/AddDiscriminators/oneline.ll @@ -21,20 +21,27 @@ define i32 @_Z3fooi(i32 %i) #0 !dbg !4 { ;