[PATCH] D53819: [WebAssembly] Fix bugs in rethrow depth counting and InstPrinter

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 2 11:42:01 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346029: [WebAssembly] Fix bugs in rethrow depth counting and InstPrinter (authored by aheejin, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D53819

Files:
  llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
  llvm/trunk/test/CodeGen/WebAssembly/exception.ll


Index: llvm/trunk/test/CodeGen/WebAssembly/exception.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/exception.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/exception.ll
@@ -1,5 +1,6 @@
 ; RUN: not llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm
 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling | FileCheck -allow-deprecated-dag-overlap %s
+; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-keep-registers -exception-model=wasm -mattr=+exception-handling
 
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -739,7 +739,20 @@
       case WebAssembly::CATCH_I32:
       case WebAssembly::CATCH_I64:
       case WebAssembly::CATCH_ALL:
-        EHPadStack.push_back(&MBB);
+        // Currently the only case there are more than one catch for a try is
+        // for catch terminate pad, in the form of
+        //   try
+        //   catch
+        //     call @__clang_call_terminate
+        //     unreachable
+        //   catch_all
+        //     call @std::terminate
+        //     unreachable
+        //   end
+        // So we shouldn't push the current BB for the second catch_all block
+        // here.
+        if (!WebAssembly::isCatchAllTerminatePad(MBB))
+          EHPadStack.push_back(&MBB);
         break;
 
       case WebAssembly::LOOP:
Index: llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
+++ llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
@@ -120,10 +120,9 @@
     case WebAssembly::CATCH_I64_S:
     case WebAssembly::CATCH_ALL:
     case WebAssembly::CATCH_ALL_S:
-      assert(LastSeenEHInst != END_TRY);
       // There can be multiple catch instructions for one try instruction, so we
-      // only print 'catch' label when the last seen EH instruction was 'try'.
-      if (LastSeenEHInst == TRY) {
+      // print a label only for the first 'catch' label.
+      if (LastSeenEHInst != CATCH) {
         assert(!EHPadStack.empty() && "try-catch mismatch!");
         printAnnotation(OS, "catch" + utostr(EHPadStack.pop_back_val()) + ':');
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53819.172409.patch
Type: text/x-patch
Size: 2718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181102/ebb2996a/attachment.bin>


More information about the llvm-commits mailing list