[llvm] dcfec27 - [WebAssembly] Handle empty cleanuppads when adding catch_all
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 10:07:30 PST 2021
Author: Heejin Ahn
Date: 2021-03-01T10:07:05-08:00
New Revision: dcfec279d607c41095f0f2d6469d6e4b2e618269
URL: https://github.com/llvm/llvm-project/commit/dcfec279d607c41095f0f2d6469d6e4b2e618269
DIFF: https://github.com/llvm/llvm-project/commit/dcfec279d607c41095f0f2d6469d6e4b2e618269.diff
LOG: [WebAssembly] Handle empty cleanuppads when adding catch_all
In `LateEHPrepare::addCatchAlls`, the current code tries to get the
iterator's debug info even when it is `MachineBasicBlock::end()`. This
fixes the bug by adding empty debug info instead in that case.
Reviewed By: tlively
Differential Revision: https://reviews.llvm.org/D97679
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
llvm/test/CodeGen/WebAssembly/exception.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
index 629abc04add9..8cd2b38d8e00 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
@@ -216,7 +216,8 @@ bool WebAssemblyLateEHPrepare::addCatchAlls(MachineFunction &MF) {
if (InsertPos == MBB.end() ||
!WebAssembly::isCatch(InsertPos->getOpcode())) {
Changed = true;
- BuildMI(MBB, InsertPos, InsertPos->getDebugLoc(),
+ BuildMI(MBB, InsertPos,
+ InsertPos == MBB.end() ? DebugLoc() : InsertPos->getDebugLoc(),
TII.get(WebAssembly::CATCH_ALL));
}
}
diff --git a/llvm/test/CodeGen/WebAssembly/exception.mir b/llvm/test/CodeGen/WebAssembly/exception.mir
index d5011c4f24a2..744d15a83d22 100644
--- a/llvm/test/CodeGen/WebAssembly/exception.mir
+++ b/llvm/test/CodeGen/WebAssembly/exception.mir
@@ -12,6 +12,9 @@
define void @unreachable_ehpad_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
ret void
}
+ define void @empty_cleanuppad_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
+ ret void
+ }
...
---
@@ -81,3 +84,30 @@ body: |
; predecessors: %bb.0, %bb.1
RETURN implicit-def dead $arguments
...
+
+---
+# Regression test for a bug that LateEHPrepare::addCatchAll didn't handle empty
+# cleanup pads. (It tried to get debug info from end() iterator.)
+name: empty_cleanuppad_test
+liveins:
+ - { reg: '$arguments' }
+body: |
+ bb.0:
+ successors: %bb.1, %bb.3
+ EH_LABEL <mcsymbol .Ltmp0>
+ CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
+ EH_LABEL <mcsymbol .Ltmp1>
+ BR %bb.3, implicit-def dead $arguments
+
+ ;; Empty cleanuppad
+ bb.1 (landing-pad):
+ successors: %bb.2
+ EH_LABEL <mcsymbol .Ltmp2>
+
+ bb.2:
+ successors: %bb.3
+ CLEANUPRET implicit-def dead $arguments
+
+ bb.3:
+ RETURN implicit-def dead $arguments
+...
More information about the llvm-commits
mailing list