aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/WasmEHPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/WasmEHPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/WasmEHPrepare.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index 7514d49fb18a..d18196b2217f 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -196,7 +196,7 @@ bool WasmEHPrepareImpl::prepareThrows(Function &F) {
bool Changed = false;
// wasm.throw() intinsic, which will be lowered to wasm 'throw' instruction.
- ThrowF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_throw);
+ ThrowF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_throw);
// Insert an unreachable instruction after a call to @llvm.wasm.throw and
// delete all following instructions within the BB, and delete all the dead
// children of the BB as well.
@@ -227,7 +227,7 @@ bool WasmEHPrepareImpl::prepareEHPads(Function &F) {
for (BasicBlock &BB : F) {
if (!BB.isEHPad())
continue;
- auto *Pad = BB.getFirstNonPHI();
+ BasicBlock::iterator Pad = BB.getFirstNonPHIIt();
if (isa<CatchPadInst>(Pad))
CatchPads.push_back(&BB);
else if (isa<CleanupPadInst>(Pad))
@@ -260,18 +260,21 @@ bool WasmEHPrepareImpl::prepareEHPads(Function &F) {
0, 2, "selector_gep");
// wasm.landingpad.index() intrinsic, which is to specify landingpad index
- LPadIndexF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_landingpad_index);
+ LPadIndexF =
+ Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_landingpad_index);
// wasm.lsda() intrinsic. Returns the address of LSDA table for the current
// function.
- LSDAF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_lsda);
+ LSDAF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_lsda);
// wasm.get.exception() and wasm.get.ehselector() intrinsics. Calls to these
// are generated in clang.
- GetExnF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_get_exception);
- GetSelectorF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_get_ehselector);
+ GetExnF =
+ Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_get_exception);
+ GetSelectorF =
+ Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_get_ehselector);
// wasm.catch() will be lowered down to wasm 'catch' instruction in
// instruction selection.
- CatchF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_catch);
+ CatchF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_catch);
// _Unwind_CallPersonality() wrapper function, which calls the personality
CallPersonalityF = M.getOrInsertFunction("_Unwind_CallPersonality",
@@ -281,7 +284,7 @@ bool WasmEHPrepareImpl::prepareEHPads(Function &F) {
unsigned Index = 0;
for (auto *BB : CatchPads) {
- auto *CPI = cast<CatchPadInst>(BB->getFirstNonPHI());
+ auto *CPI = cast<CatchPadInst>(BB->getFirstNonPHIIt());
// In case of a single catch (...), we don't need to emit a personalify
// function call
if (CPI->arg_size() == 1 &&
@@ -306,7 +309,7 @@ void WasmEHPrepareImpl::prepareEHPad(BasicBlock *BB, bool NeedPersonality,
IRBuilder<> IRB(BB->getContext());
IRB.SetInsertPoint(BB, BB->getFirstInsertionPt());
- auto *FPI = cast<FuncletPadInst>(BB->getFirstNonPHI());
+ auto *FPI = cast<FuncletPadInst>(BB->getFirstNonPHIIt());
Instruction *GetExnCI = nullptr, *GetSelectorCI = nullptr;
for (auto &U : FPI->uses()) {
if (auto *CI = dyn_cast<CallInst>(U.getUser())) {
@@ -385,13 +388,13 @@ void llvm::calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo) {
for (const auto &BB : *F) {
if (!BB.isEHPad())
continue;
- const Instruction *Pad = BB.getFirstNonPHI();
+ const Instruction *Pad = &*BB.getFirstNonPHIIt();
if (const auto *CatchPad = dyn_cast<CatchPadInst>(Pad)) {
const auto *UnwindBB = CatchPad->getCatchSwitch()->getUnwindDest();
if (!UnwindBB)
continue;
- const Instruction *UnwindPad = UnwindBB->getFirstNonPHI();
+ const Instruction *UnwindPad = &*UnwindBB->getFirstNonPHIIt();
if (const auto *CatchSwitch = dyn_cast<CatchSwitchInst>(UnwindPad))
// Currently there should be only one handler per a catchswitch.
EHInfo.setUnwindDest(&BB, *CatchSwitch->handlers().begin());