summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp5
-rw-r--r--llvm/test/CodeGen/WebAssembly/exception.ll3
2 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
index e92b3443027..fda116d5f6b 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
@@ -233,6 +233,7 @@ bool WebAssemblyLateEHPrepare::removeUnnecessaryUnreachables(
// it. The pseudo instruction will be deleted later.
bool WebAssemblyLateEHPrepare::addExceptionExtraction(MachineFunction &MF) {
const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
+ MachineRegisterInfo &MRI = MF.getRegInfo();
auto *EHInfo = MF.getWasmEHFuncInfo();
SmallVector<MachineInstr *, 16> ExtractInstrs;
SmallVector<MachineInstr *, 8> ToDelete;
@@ -339,9 +340,11 @@ bool WebAssemblyLateEHPrepare::addExceptionExtraction(MachineFunction &MF) {
WebAssembly::ClangCallTerminateFn);
assert(ClangCallTerminateFn &&
"There is no __clang_call_terminate() function");
+ unsigned Reg = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
+ BuildMI(ElseMBB, DL, TII.get(WebAssembly::CONST_I32), Reg).addImm(0);
BuildMI(ElseMBB, DL, TII.get(WebAssembly::CALL_VOID))
.addGlobalAddress(ClangCallTerminateFn)
- .addImm(0);
+ .addReg(Reg);
BuildMI(ElseMBB, DL, TII.get(WebAssembly::UNREACHABLE));
} else {
diff --git a/llvm/test/CodeGen/WebAssembly/exception.ll b/llvm/test/CodeGen/WebAssembly/exception.ll
index fc61f4099e0..af470b27e89 100644
--- a/llvm/test/CodeGen/WebAssembly/exception.ll
+++ b/llvm/test/CodeGen/WebAssembly/exception.ll
@@ -138,7 +138,8 @@ ehcleanup: ; preds = %entry
; CHECK: catch
; CHECK: block i32
; CHECK: br_on_exn 0, __cpp_exception
-; CHECK: call __clang_call_terminate, 0
+; CHECK: i32.const ${{.*}}=, 0
+; CHECK: call __clang_call_terminate
; CHECK: unreachable
; CHECK: end_block
; CHECK: call __clang_call_terminate
OpenPOWER on IntegriCloud