[llvm] r345223 - [WebAssembly] Fix immediate of rethrow when throwing to caller

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 24 16:31:24 PDT 2018


Author: aheejin
Date: Wed Oct 24 16:31:24 2018
New Revision: 345223

URL: http://llvm.org/viewvc/llvm-project?rev=345223&view=rev
Log:
[WebAssembly] Fix immediate of rethrow when throwing to caller

Summary:
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.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D53619

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
    llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-eh.mir

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp?rev=345223&r1=345222&r2=345223&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp Wed Oct 24 16:31:24 2018
@@ -767,7 +767,7 @@ void WebAssemblyCFGStackify::rewriteDept
       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;

Modified: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-eh.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-eh.mir?rev=345223&r1=345222&r2=345223&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-eh.mir (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify-eh.mir Wed Oct 24 16:31:24 2018
@@ -180,7 +180,7 @@ body: |
     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




More information about the llvm-commits mailing list