Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -755,7 +755,6 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
auto *II = dyn_cast<InvokeInst>(BB.getTerminator());
if (!II)
continue;
Changed = true;
LandingPads.insert(II->getLandingPadInst());
IRB.SetInsertPoint(II);

Expand Down Expand Up @@ -835,6 +834,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
if (auto *LPI = dyn_cast<LandingPadInst>(I))
LandingPads.insert(LPI);
}
Changed = !LandingPads.empty();

// Handle all the landingpad for this function together, as multiple invokes
// may share a single lp
Expand Down
25 changes: 25 additions & 0 deletions llvm/test/CodeGen/WebAssembly/lower-em-exceptions-lpad-only.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; 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"

@_ZTIi = external constant i8*

; Checks if a module that only contains a landingpad (and resume) but not an
; invoke works correctly and does not crash.
; CHECK-LABEL: @landingpad_only
define void @landingpad_only() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
br label %cont

lpad: ; preds = %entry
%0 = landingpad { i8*, i32 }
catch i8* bitcast (i8** @_ZTIi to i8*)
catch i8* null
resume { i8*, i32 } %0

cont:
ret void
}

declare i32 @__gxx_personality_v0(...)