[llvm] [NVPTX] Fix NVPTXLowerUnreachable::isLoweredToTrap logic (PR #109730)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 10:14:53 PDT 2024


================
@@ -110,17 +110,25 @@ StringRef NVPTXLowerUnreachable::getPassName() const {
 }
 
 // =============================================================================
-// Returns whether a `trap` intrinsic should be emitted before I.
+// Returns whether a `trap` intrinsic would be emitted before I.
 //
 // This is a copy of the logic in SelectionDAGBuilder::visitUnreachable().
 // =============================================================================
 bool NVPTXLowerUnreachable::isLoweredToTrap(const UnreachableInst &I) const {
-  if (!TrapUnreachable)
-    return false;
-  if (!NoTrapAfterNoreturn)
-    return true;
----------------
duk-37 wrote:

AIUI `isLoweredToTrap` is trying to detect whether a trap would _already_ be generated by isel for any given unreachable instruction. It does this by replicating the logic for emitting traps in `SelectionDAGBuilder::visitUnreachable`. That's why this function returning true if  `NoTrapAfterNoreturn && Call->doesNotReturn()` is wrong

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


More information about the llvm-commits mailing list