diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2015-06-08 18:50:43 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2015-06-08 18:50:43 +0000 |
commit | 4a61619ff508e8351d957f8ba3b0a37266d3095e (patch) | |
tree | 0ae1f5fba7cc2c8208a287f81ff174c7a7bef229 /llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp | |
parent | 11472c0a38529ad9c0cb988d1b28fe8d1d02d4f2 (diff) | |
download | llvm-4a61619ff508e8351d957f8ba3b0a37266d3095e.zip llvm-4a61619ff508e8351d957f8ba3b0a37266d3095e.tar.gz llvm-4a61619ff508e8351d957f8ba3b0a37266d3095e.tar.bz2 |
[ARM] Pass a callback to FunctionPass constructors to enable skipping execution
on a per-function basis.
Previously some of the passes were conditionally added to ARM's pass pipeline
based on the target machine's subtarget. This patch makes changes to add those
passes unconditionally and execute them conditonally based on the predicate
functor passed to the pass constructors. This enables running different sets of
passes for different functions in the module.
rdar://problem/20542263
Differential Revision: http://reviews.llvm.org/D8717
llvm-svn: 239325
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp index 8566cd9..f0e3ffd 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -193,11 +193,18 @@ namespace { struct CFGSimplifyPass : public FunctionPass { static char ID; // Pass identification, replacement for typeid unsigned BonusInstThreshold; - CFGSimplifyPass(int T = -1) : FunctionPass(ID) { + std::function<bool(const Function &)> PredicateFtor; + + CFGSimplifyPass(int T = -1, + std::function<bool(const Function &)> Ftor = nullptr) + : FunctionPass(ID), PredicateFtor(Ftor) { BonusInstThreshold = (T == -1) ? UserBonusInstThreshold : unsigned(T); initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry()); } bool runOnFunction(Function &F) override { + if (PredicateFtor && !PredicateFtor(F)) + return false; + if (skipOptnoneFunction(F)) return false; @@ -224,7 +231,9 @@ INITIALIZE_PASS_END(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false, false) // Public interface to the CFGSimplification pass -FunctionPass *llvm::createCFGSimplificationPass(int Threshold) { - return new CFGSimplifyPass(Threshold); +FunctionPass * +llvm::createCFGSimplificationPass(int Threshold, + std::function<bool(const Function &)> Ftor) { + return new CFGSimplifyPass(Threshold, Ftor); } |