diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 | 
| commit | b915e9e0fc85ba6f398b3fab0db6a81a8913af94 (patch) | |
| tree | 98b8f811c7aff2547cab8642daf372d6c59502fb /lib/Transforms/Utils/LowerInvoke.cpp | |
| parent | 6421cca32f69ac849537a3cff78c352195e99f1b (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Utils/LowerInvoke.cpp')
| -rw-r--r-- | lib/Transforms/Utils/LowerInvoke.cpp | 49 | 
1 files changed, 32 insertions, 17 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 1b31c5ae580a1..ee84541e526db 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -14,6 +14,7 @@  //  //===----------------------------------------------------------------------===// +#include "llvm/Transforms/Utils/LowerInvoke.h"  #include "llvm/ADT/SmallVector.h"  #include "llvm/ADT/Statistic.h"  #include "llvm/IR/Instructions.h" @@ -28,36 +29,29 @@ using namespace llvm;  STATISTIC(NumInvokes, "Number of invokes replaced");  namespace { -  class LowerInvoke : public FunctionPass { +  class LowerInvokeLegacyPass : public FunctionPass {    public:      static char ID; // Pass identification, replacement for typeid -    explicit LowerInvoke() : FunctionPass(ID) { -      initializeLowerInvokePass(*PassRegistry::getPassRegistry()); +    explicit LowerInvokeLegacyPass() : FunctionPass(ID) { +      initializeLowerInvokeLegacyPassPass(*PassRegistry::getPassRegistry());      }      bool runOnFunction(Function &F) override;    };  } -char LowerInvoke::ID = 0; -INITIALIZE_PASS(LowerInvoke, "lowerinvoke", +char LowerInvokeLegacyPass::ID = 0; +INITIALIZE_PASS(LowerInvokeLegacyPass, "lowerinvoke",                  "Lower invoke and unwind, for unwindless code generators",                  false, false) -char &llvm::LowerInvokePassID = LowerInvoke::ID; - -// Public Interface To the LowerInvoke pass. -FunctionPass *llvm::createLowerInvokePass() { -  return new LowerInvoke(); -} - -bool LowerInvoke::runOnFunction(Function &F) { +static bool runImpl(Function &F) {    bool Changed = false;    for (BasicBlock &BB : F)      if (InvokeInst *II = dyn_cast<InvokeInst>(BB.getTerminator())) { -      SmallVector<Value*,16> CallArgs(II->op_begin(), II->op_end() - 3); +      SmallVector<Value *, 16> CallArgs(II->op_begin(), II->op_end() - 3);        // Insert a normal call instruction... -      CallInst *NewCall = CallInst::Create(II->getCalledValue(), -                                           CallArgs, "", II); +      CallInst *NewCall = +          CallInst::Create(II->getCalledValue(), CallArgs, "", II);        NewCall->takeName(II);        NewCall->setCallingConv(II->getCallingConv());        NewCall->setAttributes(II->getAttributes()); @@ -73,7 +67,28 @@ bool LowerInvoke::runOnFunction(Function &F) {        // Remove the invoke instruction now.        BB.getInstList().erase(II); -      ++NumInvokes; Changed = true; +      ++NumInvokes; +      Changed = true;      }    return Changed;  } + +bool LowerInvokeLegacyPass::runOnFunction(Function &F) { +  return runImpl(F); +} + +namespace llvm { +char &LowerInvokePassID = LowerInvokeLegacyPass::ID; + +// Public Interface To the LowerInvoke pass. +FunctionPass *createLowerInvokePass() { return new LowerInvokeLegacyPass(); } + +PreservedAnalyses LowerInvokePass::run(Function &F, +                                       FunctionAnalysisManager &AM) { +  bool Changed = runImpl(F); +  if (!Changed) +    return PreservedAnalyses::all(); + +  return PreservedAnalyses::none(); +} +}  | 
