summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2018-10-24 23:31:24 +0000
committerHeejin Ahn <aheejin@gmail.com>2018-10-24 23:31:24 +0000
commitac764aa88ea8c23d0f14a1296667394deff07fc4 (patch)
tree2d6ff9fd65167a46d6ebe7dd01d662a55e8224a1
parent81a650ee87eb679e85a4ca3b1565c5fbd362a472 (diff)
downloadbcm5719-llvm-ac764aa88ea8c23d0f14a1296667394deff07fc4.tar.gz
bcm5719-llvm-ac764aa88ea8c23d0f14a1296667394deff07fc4.zip
[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 llvm-svn: 345223
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp2
-rw-r--r--llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.mir2
2 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 93ca670bbdb..a3b3901f019 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -767,7 +767,7 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {
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;
diff --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.mir b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.mir
index 9038f68966b..b67579087fa 100644
--- a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.mir
+++ b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.mir
@@ -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
OpenPOWER on IntegriCloud