Skip to content

[WebAssembly] Fix resume-only case in Emscripten EH #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -755,6 +755,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
auto *II = dyn_cast<InvokeInst>(BB.getTerminator());
if (!II)
continue;
Changed = true;
LandingPads.insert(II->getLandingPadInst());
IRB.SetInsertPoint(II);

@@ -795,6 +796,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
auto *RI = dyn_cast<ResumeInst>(&I);
if (!RI)
continue;
Changed = true;

// Split the input into legal values
Value *Input = RI->getValue();
@@ -819,6 +821,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
continue;
if (Callee->getIntrinsicID() != Intrinsic::eh_typeid_for)
continue;
Changed = true;

IRB.SetInsertPoint(CI);
CallInst *NewCI =
@@ -834,7 +837,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
if (auto *LPI = dyn_cast<LandingPadInst>(I))
LandingPads.insert(LPI);
}
Changed = !LandingPads.empty();
Changed |= !LandingPads.empty();

// Handle all the landingpad for this function together, as multiple invokes
// may share a single lp
25 changes: 0 additions & 25 deletions llvm/test/CodeGen/WebAssembly/lower-em-exceptions-lpad-only.ll

This file was deleted.

17 changes: 17 additions & 0 deletions llvm/test/CodeGen/WebAssembly/lower-em-exceptions-resume-only.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; RUN: opt < %s -wasm-lower-em-ehsjlj -S | FileCheck %s

target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"

; Checks if a module that only contains a resume but not an invoke works
; correctly and does not crash.
; CHECK-LABEL: @resume_only
; CHECK: call void @__resumeException
define void @resume_only() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
%val0 = insertvalue { i8*, i32 } undef, i8* null, 0
%val1 = insertvalue { i8*, i32} %val0, i32 0, 1
resume { i8*, i32 } %val1
}

declare i32 @__gxx_personality_v0(...)