[llvm] Ensure NoTrapAfterNoreturn is false for the wasm backend (PR #65876)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 23:31:58 PDT 2023


================
@@ -37,6 +37,11 @@ static cl::opt<bool>
     EnableTrapUnreachable("trap-unreachable", cl::Hidden,
                           cl::desc("Enable generating trap for unreachable"));
 
+static cl::opt<bool> EnableNoTrapAfterNoreturn(
+    "no-trap-after-noreturn", cl::Hidden,
+    cl::desc("Do not emit a trap instruction for 'unreachable' IR instructions "
+             "after noreturn calls, even if --trap-unreachable is set."));
----------------
aheejin wrote:

As you correctly pointed out in https://github.com/llvm/llvm-project/pull/65876#issuecomment-1714681125, if we turn `NoTrapAfterNoreturn` on, our backend produces invalid code. I don't think our tests should test if we (correctly) produce invalid code when a command line option is turned on.

And why does the rust code need to turn that option on? I scrolled down as you said but failed to find out why..

> In the future, people may want to stop forcing TrapUnreachable to true and NoTrapAfterNoreturn to false, if the wasm backend improves and it stops being necessary for correctness.

If we want to test something, I think we should just test the current behavior. Not sure if we need to predict the future scenario and test it in advance.

https://github.com/llvm/llvm-project/pull/65876


More information about the llvm-commits mailing list