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
3 changes: 2 additions & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ bool WebAssemblyLateEHPrepare::addCatchRefsAndThrowRefs(MachineFunction &MF) {
// caught exception is rethrown. And convert RETHROWs to THROW_REFs.
for (auto &[EHPad, Rethrows] : EHPadToRethrows) {
auto *Catch = WebAssembly::findCatch(EHPad);
auto *InsertPos = Catch->getIterator()->getNextNode();
assert(Catch && "CATCH not found in EHPad");
auto InsertPos = std::next(Catch->getIterator());
auto ExnReg = MRI.createVirtualRegister(&WebAssembly::EXNREFRegClass);
if (Catch->getOpcode() == WebAssembly::CATCH) {
MachineInstrBuilder MIB = BuildMI(*EHPad, InsertPos, Catch->getDebugLoc(),
Expand Down
27 changes: 27 additions & 0 deletions llvm/test/CodeGen/WebAssembly/exception.ll
Original file line number Diff line number Diff line change
Expand Up @@ -672,5 +672,32 @@ attributes #0 = { nounwind }
attributes #1 = { noreturn }
attributes #2 = { noreturn nounwind }

; CHECK-LABEL: empty_cleanup_pad:
; CHECK: try_table (catch_all_ref 0)
; CHECK: throw_ref
define void @empty_cleanup_pad(i32 %arg) personality ptr @__gxx_wasm_personality_v0 {
entry:
br label %loop

loop:
invoke void @foo()
to label %loop unwind label %cleanup

cleanup:
%exn = cleanuppad within none []
br label %dispatch

dispatch: ; preds = %cleanup, %dispatch
%cond = icmp eq i32 %arg, 0
br i1 %cond, label %ret, label %dispatch

ret: ; preds = %dispatch
cleanupret from %exn unwind label %cleanup2

cleanup2: ; preds = %ret
%exn2 = cleanuppad within none []
ret void
}

;; The exception tag should not be defined locally
; CHECK-NOT: __cpp_exception: