[llvm] [NVPTX] Fix NVPTXLowerUnreachable::isLoweredToTrap logic (PR #109730)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 18:32:54 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;
const CallInst *Call = dyn_cast_or_null<CallInst>(I.getPrevNode());
- return Call && Call->doesNotReturn();
+ if (Call) {
+ // We've already emitted a non-continuable trap.
+ if (Call->isNonContinuableTrap())
+ return true;
+
+ // No traps are emitted for calls that do not return
+ // when this option is enabled.
+ if (NoTrapAfterNoreturn && Call->doesNotReturn())
----------------
duk-37 wrote:
I don't think renaming fields would be appropriate for this commit, though there are definitely some parts of the pass that could use some reformatting. Also, `NoTrapAfterNoreturn` matches casing of the `TargetOptions` field so the current name feels appropriate unless we change that too, IMHO
https://github.com/llvm/llvm-project/pull/109730
More information about the llvm-commits
mailing list