diff options
author | Paul Robinson <paul_robinson@playstation.sony.com> | 2014-02-06 00:07:05 +0000 |
---|---|---|
committer | Paul Robinson <paul_robinson@playstation.sony.com> | 2014-02-06 00:07:05 +0000 |
commit | af4e64d0955aa47fd6e286ce48eeeed9a9ec7a4a (patch) | |
tree | f2a3ef5236ee396b9716402af3510a2b1073cc0e /llvm/lib/IR/Pass.cpp | |
parent | f9e58778bc78a4a4714de0e8e66f70614ea28948 (diff) | |
download | bcm5719-llvm-af4e64d0955aa47fd6e286ce48eeeed9a9ec7a4a.tar.gz bcm5719-llvm-af4e64d0955aa47fd6e286ce48eeeed9a9ec7a4a.zip |
Disable most IR-level transform passes on functions marked 'optnone'.
Ideally only those transform passes that run at -O0 remain enabled,
in reality we get as close as we reasonably can.
Passes are responsible for disabling themselves, it's not the job of
the pass manager to do it for them.
llvm-svn: 200892
Diffstat (limited to 'llvm/lib/IR/Pass.cpp')
-rw-r--r-- | llvm/lib/IR/Pass.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp index 3782e2d7be5..84b0b04d698 100644 --- a/llvm/lib/IR/Pass.cpp +++ b/llvm/lib/IR/Pass.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Pass.h" +#include "llvm/IR/Function.h" #include "llvm/IR/IRPrintingPasses.h" #include "llvm/PassRegistry.h" #include "llvm/Support/Debug.h" @@ -137,6 +138,15 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const { return PMT_FunctionPassManager; } +bool FunctionPass::skipOptnoneFunction(Function &F) const { + if (F.hasFnAttribute(Attribute::OptimizeNone)) { + DEBUG(dbgs() << "Skipping pass '" << getPassName() + << "' on function " << F.getName() << "\n"); + return true; + } + return false; +} + //===----------------------------------------------------------------------===// // BasicBlockPass Implementation // @@ -156,6 +166,18 @@ bool BasicBlockPass::doFinalization(Function &) { return false; } +bool BasicBlockPass::skipOptnoneFunction(BasicBlock &BB) const { + Function *F = BB.getParent(); + if (F && F->hasFnAttribute(Attribute::OptimizeNone)) { + // Report this only once per function. + if (&BB == &F->getEntryBlock()) + DEBUG(dbgs() << "Skipping pass '" << getPassName() + << "' on function " << F->getName() << "\n"); + return true; + } + return false; +} + PassManagerType BasicBlockPass::getPotentialPassManagerType() const { return PMT_BasicBlockPassManager; } |