diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -3202,7 +3202,8 @@ } } - if (MBB.isEHCatchretTarget()) { + if (MBB.isEHCatchretTarget() && + MAI->getExceptionHandlingType() == ExceptionHandling::WinEH) { OutStreamer->emitLabel(MBB.getEHCatchretSymbol()); } diff --git a/llvm/test/CodeGen/WebAssembly/eh-catchpad-nested.ll b/llvm/test/CodeGen/WebAssembly/eh-catchpad-nested.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/eh-catchpad-nested.ll @@ -0,0 +1,35 @@ +; RUN: llc -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling < %s | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown" + +declare void @personality() + +declare void @f() + +define void @test1() personality void ()* @personality { +entry: + invoke void @f() + to label %exit unwind label %catch.dispatch.1 +exit: + ret void + +catch.dispatch.1: + %cs1 = catchswitch within none [label %outer.catch] unwind to caller + +outer.catch: + %cp1 = catchpad within %cs1 [i32 1] + invoke void @f() [ "funclet"(token %cp1) ] + to label %outer.ret unwind label %catch.dispatch.2 +outer.ret: + catchret from %cp1 to label %exit + +catch.dispatch.2: + %cs2 = catchswitch within %cp1 [label %inner.catch] unwind to caller +inner.catch: + %cp2 = catchpad within %cs2 [i32 2] + catchret from %cp2 to label %outer.ret +} + +; Check that no $ehgcr symbols are emitted +; CHECK-NOT: $ehgcr