summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-02-11 12:38:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-11 12:38:11 +0000
commite3b557809604d036af6e00c60f012c2025b59a5e (patch)
tree8a11ba2269a3b669601e2fd41145b174008f4da8 /llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
parent08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff)
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 7a1a769c6b16..5faa098b94ad 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -545,15 +545,13 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallBase *CI) {
ArgAttributes.push_back(InvokeAL.getParamAttrs(I));
AttrBuilder FnAttrs(CI->getContext(), InvokeAL.getFnAttrs());
- if (FnAttrs.contains(Attribute::AllocSize)) {
+ if (auto Args = FnAttrs.getAllocSizeArgs()) {
// The allocsize attribute (if any) referes to parameters by index and needs
// to be adjusted.
- unsigned SizeArg;
- Optional<unsigned> NEltArg;
- std::tie(SizeArg, NEltArg) = FnAttrs.getAllocSizeArgs();
+ auto [SizeArg, NEltArg] = *Args;
SizeArg += 1;
if (NEltArg)
- NEltArg = NEltArg.value() + 1;
+ NEltArg = *NEltArg + 1;
FnAttrs.addAllocSizeAttr(SizeArg, NEltArg);
}
// In case the callee has 'noreturn' attribute, We need to remove it, because
@@ -775,7 +773,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::wrapTestSetjmp(
// Output parameter assignment
Label = LabelPHI;
EndBB = EndBB1;
- LongjmpResult = IRB.CreateCall(GetTempRet0F, None, "longjmp_result");
+ LongjmpResult = IRB.CreateCall(GetTempRet0F, std::nullopt, "longjmp_result");
}
void WebAssemblyLowerEmscriptenEHSjLj::rebuildSSA(Function &F) {
@@ -1227,9 +1225,9 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
// Create a call to __cxa_find_matching_catch_N function
Function *FMCF = getFindMatchingCatch(M, FMCArgs.size());
CallInst *FMCI = IRB.CreateCall(FMCF, FMCArgs, "fmc");
- Value *Undef = UndefValue::get(LPI->getType());
- Value *Pair0 = IRB.CreateInsertValue(Undef, FMCI, 0, "pair0");
- Value *TempRet0 = IRB.CreateCall(GetTempRet0F, None, "tempret0");
+ Value *Poison = PoisonValue::get(LPI->getType());
+ Value *Pair0 = IRB.CreateInsertValue(Poison, FMCI, 0, "pair0");
+ Value *TempRet0 = IRB.CreateCall(GetTempRet0F, std::nullopt, "tempret0");
Value *Pair1 = IRB.CreateInsertValue(Pair0, TempRet0, 1, "pair1");
LPI->replaceAllUsesWith(Pair1);
@@ -1290,9 +1288,11 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
"setjmpTableSize", Entry->getTerminator());
SetjmpTableSize->setDebugLoc(FirstDL);
// setjmpTable = (int *) malloc(40);
- Instruction *SetjmpTable = CallInst::CreateMalloc(
- SetjmpTableSize, IRB.getInt32Ty(), IRB.getInt32Ty(), IRB.getInt32(40),
- nullptr, nullptr, "setjmpTable");
+ Type *IntPtrTy = getAddrIntType(&M);
+ Constant *size = ConstantInt::get(IntPtrTy, 40);
+ Instruction *SetjmpTable =
+ CallInst::CreateMalloc(SetjmpTableSize, IntPtrTy, IRB.getInt32Ty(), size,
+ nullptr, nullptr, "setjmpTable");
SetjmpTable->setDebugLoc(FirstDL);
// CallInst::CreateMalloc may return a bitcast instruction if the result types
// mismatch. We need to set the debug loc for the original call too.
@@ -1355,7 +1355,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
Instruction *NewSetjmpTable =
IRB.CreateCall(SaveSetjmpF, Args, "setjmpTable");
Instruction *NewSetjmpTableSize =
- IRB.CreateCall(GetTempRet0F, None, "setjmpTableSize");
+ IRB.CreateCall(GetTempRet0F, std::nullopt, "setjmpTableSize");
SetjmpTableInsts.push_back(NewSetjmpTable);
SetjmpTableSizeInsts.push_back(NewSetjmpTableSize);
ToErase.push_back(CI);
@@ -1630,7 +1630,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForEmscriptenSjLj(
// Create switch instruction
IRB.SetInsertPoint(EndBB);
- IRB.SetCurrentDebugLocation(EndBB->getInstList().back().getDebugLoc());
+ IRB.SetCurrentDebugLocation(EndBB->back().getDebugLoc());
SwitchInst *SI = IRB.CreateSwitch(Label, Tail, SetjmpRetPHIs.size());
// -1 means no longjmp happened, continue normally (will hit the default
// switch case). 0 means a longjmp that is not ours to handle, needs a