[PATCH] D53619: [WebAssembly] Fix immediate of rethrow when throwing to caller

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 15:35:14 PDT 2018


aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, sbc100.

Currently when assigning depths 'rethrow' does not take the whole
control flow stack into accounts but only considers EH pad stacks. When
assigning depth immmediates to rethrows, in normal cases it is done
correctly but when a rethrow instruction throws up to a caller, i.e., we
convert a pseudo RETHROW_TO_CALLER instruction to a rethrow, it
mistakenly compute the whole stack depth.


Repository:
  rL LLVM

https://reviews.llvm.org/D53619

Files:
  lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
  test/CodeGen/WebAssembly/cfg-stackify-eh.mir


Index: test/CodeGen/WebAssembly/cfg-stackify-eh.mir
===================================================================
--- test/CodeGen/WebAssembly/cfg-stackify-eh.mir
+++ test/CodeGen/WebAssembly/cfg-stackify-eh.mir
@@ -180,7 +180,7 @@
     RETHROW_TO_CALLER implicit-def $arguments
   ; CHECK-LABEL: bb.7:
     ; CHECK-NEXT: END_TRY
-    ; CHECK: RETHROW 3
+    ; CHECK: RETHROW 0
 
   bb.8:
   ; predecessors: %bb.2, %bb.4
Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -767,7 +767,7 @@
       case WebAssembly::RETHROW_TO_CALLER: {
         MachineInstr *Rethrow =
             BuildMI(MBB, MI, MI.getDebugLoc(), TII.get(WebAssembly::RETHROW))
-                .addImm(Stack.size());
+                .addImm(EHPadStack.size());
         MI.eraseFromParent();
         I = MachineBasicBlock::reverse_iterator(Rethrow);
         break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53619.170768.patch
Type: text/x-patch
Size: 1029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181023/2707d557/attachment.bin>


More information about the llvm-commits mailing list