forked from OSchip/llvm-project
Revert http://reviews.llvm.org/D19926 as it breaks tests.
llvm-svn: 268681
This commit is contained in:
parent
5eba657ff3
commit
f50c67ce7c
|
@ -39,17 +39,6 @@ public:
|
||||||
PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
|
PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFGSimplifyPass : public FunctionPass {
|
|
||||||
static char ID; // Pass identification, replacement for typeid
|
|
||||||
unsigned BonusInstThreshold;
|
|
||||||
std::function<bool(const Function &)> PredicateFtor;
|
|
||||||
|
|
||||||
CFGSimplifyPass(int T = -1,
|
|
||||||
std::function<bool(const Function &)> Ftor = nullptr);
|
|
||||||
bool runOnFunction(Function &F) override;
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -196,31 +196,35 @@ PreservedAnalyses SimplifyCFGPass::run(Function &F,
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFGSimplifyPass::CFGSimplifyPass(int T,
|
namespace {
|
||||||
std::function<bool(const Function &)> Ftor)
|
struct CFGSimplifyPass : public FunctionPass {
|
||||||
: FunctionPass(ID), PredicateFtor(Ftor) {
|
static char ID; // Pass identification, replacement for typeid
|
||||||
BonusInstThreshold = (T == -1) ? UserBonusInstThreshold : unsigned(T);
|
unsigned BonusInstThreshold;
|
||||||
initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry());
|
std::function<bool(const Function &)> PredicateFtor;
|
||||||
}
|
|
||||||
|
|
||||||
bool CFGSimplifyPass::runOnFunction(Function &F) {
|
CFGSimplifyPass(int T = -1,
|
||||||
if (PredicateFtor && !PredicateFtor(F))
|
std::function<bool(const Function &)> Ftor = nullptr)
|
||||||
return false;
|
: 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))
|
AssumptionCache *AC =
|
||||||
return false;
|
&getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
||||||
|
const TargetTransformInfo &TTI =
|
||||||
|
getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
||||||
|
return simplifyFunctionCFG(F, TTI, AC, BonusInstThreshold);
|
||||||
|
}
|
||||||
|
|
||||||
AssumptionCache *AC =
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
&getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
AU.addRequired<AssumptionCacheTracker>();
|
||||||
const TargetTransformInfo &TTI =
|
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||||
getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
AU.addPreserved<GlobalsAAWrapperPass>();
|
||||||
return simplifyFunctionCFG(F, TTI, AC, BonusInstThreshold);
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
void CFGSimplifyPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
||||||
AU.addRequired<AssumptionCacheTracker>();
|
|
||||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
|
||||||
AU.addPreserved<GlobalsAAWrapperPass>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char CFGSimplifyPass::ID = 0;
|
char CFGSimplifyPass::ID = 0;
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -80,10 +79,6 @@ struct AddDiscriminators : public FunctionPass {
|
||||||
initializeAddDiscriminatorsPass(*PassRegistry::getPassRegistry());
|
initializeAddDiscriminatorsPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
||||||
AU.addRequired<CFGSimplifyPass>();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool runOnFunction(Function &F) override;
|
bool runOnFunction(Function &F) override;
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
@ -91,7 +86,6 @@ struct AddDiscriminators : public FunctionPass {
|
||||||
char AddDiscriminators::ID = 0;
|
char AddDiscriminators::ID = 0;
|
||||||
INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators",
|
INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators",
|
||||||
"Add DWARF path discriminators", false, false)
|
"Add DWARF path discriminators", false, false)
|
||||||
INITIALIZE_PASS_DEPENDENCY(CFGSimplifyPass)
|
|
||||||
INITIALIZE_PASS_END(AddDiscriminators, "add-discriminators",
|
INITIALIZE_PASS_END(AddDiscriminators, "add-discriminators",
|
||||||
"Add DWARF path discriminators", false, false)
|
"Add DWARF path discriminators", false, false)
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,20 @@ entry:
|
||||||
|
|
||||||
if.then: ; preds = %entry
|
if.then: ; preds = %entry
|
||||||
%1 = load i32, i32* %i.addr, align 4, !dbg !10
|
%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
|
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
|
br label %if.end, !dbg !10
|
||||||
; CHECK: br label %if.end, !dbg ![[THEN]]
|
; CHECK: br label %if.end, !dbg ![[THEN]]
|
||||||
|
|
||||||
if.else: ; preds = %entry
|
if.else: ; preds = %entry
|
||||||
%2 = load i32, i32* %i.addr, align 4, !dbg !10
|
%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
|
%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
|
store i32 %sub, i32* %x, align 4, !dbg !10
|
||||||
; CHECK: store i32 %sub, i32* %x, align 4, !dbg ![[ELSE]]
|
; CHECK: store i32 %sub, i32* %x, align 4, !dbg ![[ELSE]]
|
||||||
|
|
|
@ -21,20 +21,27 @@ define i32 @_Z3fooi(i32 %i) #0 !dbg !4 {
|
||||||
|
|
||||||
; <label>:5 ; preds = %0
|
; <label>:5 ; preds = %0
|
||||||
%6 = load i32, i32* %2, align 4, !dbg !23, !tbaa !13
|
%6 = load i32, i32* %2, align 4, !dbg !23, !tbaa !13
|
||||||
|
; CHECK: %6 = load i32, i32* %2, align 4, !dbg ![[THEN1:[0-9]+]],{{.*}}
|
||||||
|
|
||||||
%7 = icmp eq i32 %6, 5, !dbg !24
|
%7 = icmp eq i32 %6, 5, !dbg !24
|
||||||
|
; CHECK: %7 = icmp eq i32 %6, 5, !dbg ![[THEN2:[0-9]+]]
|
||||||
|
|
||||||
br i1 %7, label %8, label %9, !dbg !25
|
br i1 %7, label %8, label %9, !dbg !25
|
||||||
|
; CHECK: br i1 %7, label %8, label %9, !dbg ![[THEN3:[0-9]+]]
|
||||||
|
|
||||||
; <label>:8 ; preds = %5, %0
|
; <label>:8 ; preds = %5, %0
|
||||||
store i32 100, i32* %1, align 4, !dbg !26
|
store i32 100, i32* %1, align 4, !dbg !26
|
||||||
; CHECK: store i32 100, i32* %1, align 4, !dbg ![[THEN:[0-9]+]]
|
; CHECK: store i32 100, i32* %1, align 4, !dbg ![[ELSE:[0-9]+]]
|
||||||
|
|
||||||
br label %10, !dbg !26
|
br label %10, !dbg !26
|
||||||
|
; CHECK: br label %10, !dbg ![[ELSE]]
|
||||||
|
|
||||||
; <label>:9 ; preds = %5
|
; <label>:9 ; preds = %5
|
||||||
store i32 99, i32* %1, align 4, !dbg !27
|
store i32 99, i32* %1, align 4, !dbg !27
|
||||||
; CHECK: store i32 99, i32* %1, align 4, !dbg ![[ELSE:[0-9]+]]
|
; CHECK: store i32 99, i32* %1, align 4, !dbg ![[COMBINE:[0-9]+]]
|
||||||
|
|
||||||
br label %10, !dbg !27
|
br label %10, !dbg !27
|
||||||
|
; CHECK: br label %10, !dbg ![[COMBINE]]
|
||||||
|
|
||||||
; <label>:10 ; preds = %9, %8
|
; <label>:10 ; preds = %9, %8
|
||||||
%11 = load i32, i32* %1, align 4, !dbg !28
|
%11 = load i32, i32* %1, align 4, !dbg !28
|
||||||
|
@ -80,7 +87,11 @@ attributes #1 = { nounwind readnone }
|
||||||
!27 = !DILocation(line: 2, column: 42, scope: !20)
|
!27 = !DILocation(line: 2, column: 42, scope: !20)
|
||||||
!28 = !DILocation(line: 3, column: 1, scope: !4)
|
!28 = !DILocation(line: 3, column: 1, scope: !4)
|
||||||
|
|
||||||
; CHECK: ![[THEN]] = !DILocation(line: 2, column: 25, scope: ![[THENBLOCK:[0-9]+]])
|
; CHECK: ![[THEN1]] = !DILocation(line: 2, column: 17, scope: ![[THENBLOCK:[0-9]+]])
|
||||||
; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 1)
|
; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 1)
|
||||||
; CHECK: ![[ELSE]] = !DILocation(line: 2, column: 42, scope: ![[ELSEBLOCK:[0-9]+]])
|
; CHECK: ![[THEN2]] = !DILocation(line: 2, column: 19, scope: ![[THENBLOCK]])
|
||||||
|
; CHECK: ![[THEN3]] = !DILocation(line: 2, column: 7, scope: ![[THENBLOCK]])
|
||||||
|
; CHECK: ![[ELSE]] = !DILocation(line: 2, column: 25, scope: ![[ELSEBLOCK:[0-9]+]])
|
||||||
; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 2)
|
; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 2)
|
||||||
|
; CHECK: ![[COMBINE]] = !DILocation(line: 2, column: 42, scope: ![[COMBINEBLOCK:[0-9]+]])
|
||||||
|
; CHECK: ![[COMBINEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 3)
|
||||||
|
|
Loading…
Reference in New Issue