[PATCH] D96824: [WebAssembly] Do not use EHCatchret symbols with wasm EH

Derek Schuff via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 16:56:23 PST 2021


dschuff created this revision.
dschuff added reviewers: aheejin, tlively.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, sbc100.
dschuff requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

D94835 <https://reviews.llvm.org/D94835> added support for WinEH to export public symbols pointing to
basic blocks which are catchret targets for use with Windows CET.
Wasm currently doesn't support public symbols to non-function code
addresses (they get treated like new functions in asm but then don't
lower to object files correctly).
It created them unconditionally for all catchret targets.

This change disables those symbols unless the exceptionHandlingType
is WinEH (since they aren't used with ExceptionHandling::Wasm)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96824

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/WebAssembly/eh-catchpad-nested.ll


Index: llvm/test/CodeGen/WebAssembly/eh-catchpad-nested.ll
===================================================================
--- /dev/null
+++ 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
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3202,7 +3202,8 @@
     }
   }
 
-  if (MBB.isEHCatchretTarget()) {
+  if (MBB.isEHCatchretTarget() &&
+      MAI->getExceptionHandlingType() == ExceptionHandling::WinEH) {
     OutStreamer->emitLabel(MBB.getEHCatchretSymbol());
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96824.324136.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210217/7718a8fc/attachment.bin>


More information about the llvm-commits mailing list