LLVM: lib/Transforms/Utils/LowerInvoke.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
23using namespace llvm;
24
25#define DEBUG_TYPE "lower-invoke"
26
27STATISTIC(NumInvokes, "Number of invokes replaced");
28
29namespace {
30class LowerInvokeLegacyPass : public FunctionPass {
31public:
32 static char ID;
35 }
37};
38}
39
40char LowerInvokeLegacyPass::ID = 0;
42 "Lower invoke and unwind, for unwindless code generators",
43 false, false)
44
49 SmallVector<Value *, 16> CallArgs(II->args());
50 SmallVector<OperandBundleDef, 1> OpBundles;
51 II->getOperandBundlesAsDefs(OpBundles);
52
53 CallInst *NewCall =
54 CallInst::Create(II->getFunctionType(), II->getCalledOperand(),
55 CallArgs, OpBundles, "", II->getIterator());
56 NewCall->takeName(II);
57 NewCall->setCallingConv(II->getCallingConv());
58 NewCall->setAttributes(II->getAttributes());
59 NewCall->setDebugLoc(II->getDebugLoc());
60 II->replaceAllUsesWith(NewCall);
61
62
63 BranchInst::Create(II->getNormalDest(), II->getIterator());
64
65
66 II->getUnwindDest()->removePredecessor(&BB);
67
68
69 II->eraseFromParent();
70
71 ++NumInvokes;
72 Changed = true;
73 }
75}
76
77bool LowerInvokeLegacyPass::runOnFunction(Function &F) {
79}
80
82
83
85 return new LowerInvokeLegacyPass();
86}
87
static bool runOnFunction(Function &F, bool PostInlining)
static bool runImpl(Function &F, const TargetLowering &TLI, const LibcallLoweringInfo &Libcalls, AssumptionCache *AC)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM Basic Block Representation.
FunctionPass class - This class is used to implement most global optimizations.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition LowerInvoke.cpp:88
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void initializeLowerInvokeLegacyPassPass(PassRegistry &)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI FunctionPass * createLowerInvokePass()
Definition LowerInvoke.cpp:84
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI char & LowerInvokePassID
Definition LowerInvoke.cpp:81