[llvm] Ensure NoTrapAfterNoreturn is false for the wasm backend (PR #65876)
Matt Harding via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 15:21:52 PDT 2023
================
@@ -109,6 +110,53 @@ static bool maybeRewriteToFallthrough(MachineInstr &MI, MachineBasicBlock &MBB,
return true;
}
+static bool eraseDeadCodeAroundUnreachable(MachineInstr &UnreachbleMI, MachineBasicBlock &MBB) {
+ SmallVector<MachineInstr*, 16> ToDelete;
+
+ // Because wasm unreachable is stack polymorphic and unconditionally ends control,
+ // all instructions after it can be removed until the end of this block.
+ // We remove the common case of double unreachable.
+ auto ForwardsIterator = UnreachbleMI.getIterator();
+ for (ForwardsIterator++; !ForwardsIterator.isEnd(); ForwardsIterator++) {
+ MachineInstr& MI = *ForwardsIterator;
+ if (MI.getOpcode() == WebAssembly::UNREACHABLE) {
+ ToDelete.push_back(&MI);
+ } else {
+ break;
+ }
+ }
+
+ [&]() {
----------------
majaha wrote:
It's just a syntactic convenience that allows me to jump out of the for loop with a `return` statement instead of a `break` statement, because `break` would break out of the switch statement instead. I could replace it with a `goto` to the end of the loop if you like, or if you can think of a better way.
https://github.com/llvm/llvm-project/pull/65876
More information about the llvm-commits
mailing list