[llvm] [NVPTX] Fix code generation for `trap-unreachable`. (PR #67478)

Christian Sigg via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 09:22:50 PDT 2023


================
@@ -99,6 +105,24 @@ char NVPTXLowerUnreachable::ID = 1;
 INITIALIZE_PASS(NVPTXLowerUnreachable, "nvptx-lower-unreachable",
                 "Lower Unreachable", false, false)
 
+StringRef NVPTXLowerUnreachable::getPassName() const {
+  return "add an exit instruction before every unreachable";
+}
+
+// =============================================================================
+// Returns whether a `trap` intrinsic should be emitted before I.
+//
+// This is a copy of the logic in SelectionDAGBuilder::visitUnreachable().
+// =============================================================================
+bool NVPTXLowerUnreachable::shouldEmitTrap(const UnreachableInst &I) const {
+  if (!TrapUnreachable)
----------------
chsigg wrote:

I'm not sure I understand. `NoTrapAfterNoreturn` has no effect if `TrapUnreachable == false`.

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


More information about the llvm-commits mailing list