Skip to content

Commit

Permalink
Also check wether we're targeting Pascal or prior
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfargnoli committed Sep 24, 2024
1 parent 681c40f commit 6bc6174
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTXSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
bool hasDotInstructions() const {
return SmVersion >= 61 && PTXVersion >= 50;
}
bool hasPTXASUnreachableBug() const {
return SmVersion < 70 && PTXVersion <= 74;
}
bool hasCvtaParam() const { return SmVersion >= 70 && PTXVersion >= 77; }
unsigned int getFullSmVersion() const { return FullSmVersion; }
unsigned int getSmVersion() const { return getFullSmVersion() / 10; }
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,9 @@ void NVPTXPassConfig::addIRPasses() {
addPass(createSROAPass());
}

if (ST.getPTXVersion() <= 74) {
// This pass is a WAR for a bug that's present in `ptxas` binaries that are
// shipped in or prior to CUDA Toolkit 11.4. The highest version that's
// supported by `ptxas` in CUDA 11.4 is 7.4. Limit this pass to only run
// when targeting PTX 7.4 or lower.
if (ST.hasPTXASUnreachableBug()) {
// Run LowerUnreachable to WAR a ptxas bug. See the commit description of
// 1ee4d880e8760256c606fe55b7af85a4f70d006d for more details.
const auto &Options = getNVPTXTargetMachine().Options;
addPass(createNVPTXLowerUnreachablePass(Options.TrapUnreachable,
Options.NoTrapAfterNoreturn));
Expand Down
6 changes: 4 additions & 2 deletions llvm/test/CodeGen/NVPTX/unreachable.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -verify-machineinstrs \
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOTRAP
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -verify-machineinstrs -mattr=+ptx75 \
; RUN: | FileCheck %s --check-prefixes=CHECK-PTX75
; RUN: | FileCheck %s --check-prefixes=CHECK-BUG-FIXED
; RUN: llc < %s -march=nvptx64 -mcpu=sm_70 -verify-machineinstrs \
; RUN: | FileCheck %s --check-prefixes=CHECK-BUG-FIXED
; RUN: llc < %s -march=nvptx -mcpu=sm_20 -verify-machineinstrs -trap-unreachable \
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-TRAP
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -verify-machineinstrs -trap-unreachable \
Expand All @@ -23,7 +25,7 @@ define void @kernel_func() {
; CHECK-TRAP: trap;
; CHECK-NOTRAP-NOT: trap;
; CHECK: exit;
; CHECK-PTX75-NOT: exit;
; CHECK-BUG-FIXED-NOT: exit;
unreachable
}

Expand Down

0 comments on commit 6bc6174

Please sign in to comment.