Skip to content

Commit 81c5d46

Browse files
authored
[MLIR][NVVM] Propagate verification failure for unsupported SM targets (#170001)
Fixes: #169113 Correctly propagate verification failure when `NVVM::RequiresSMInterface` check fails during `gpu.module` verification. Previously, the walk was interrupted but the function returned `success()`, causing a mismatch between the emitted diagnostic and the return status. This led to assertion failures in Python bindings which expect `failure()` when diagnostics are emitted. CC: @grypp
1 parent e218140 commit 81c5d46

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4707,16 +4707,20 @@ LogicalResult NVVMTargetAttr::verifyTarget(Operation *gpuModule) {
47074707
"Minimum NVVM target SM version is sm_20");
47084708
}
47094709

4710-
gpuModuleOp->walk([&](Operation *op) {
4711-
if (auto reqOp = llvm::dyn_cast<NVVM::RequiresSMInterface>(op)) {
4712-
const NVVMCheckSMVersion requirement = reqOp.getRequiredMinSMVersion();
4713-
if (!requirement.isCompatibleWith(targetSMVersion)) {
4714-
op->emitOpError() << "is not supported on " << getChip();
4715-
return WalkResult::interrupt();
4716-
}
4717-
}
4718-
return WalkResult::advance();
4719-
});
4710+
if (gpuModuleOp
4711+
->walk([&](Operation *op) {
4712+
if (auto reqOp = llvm::dyn_cast<NVVM::RequiresSMInterface>(op)) {
4713+
const NVVMCheckSMVersion requirement =
4714+
reqOp.getRequiredMinSMVersion();
4715+
if (!requirement.isCompatibleWith(targetSMVersion)) {
4716+
op->emitOpError() << "is not supported on " << getChip();
4717+
return WalkResult::interrupt();
4718+
}
4719+
}
4720+
return WalkResult::advance();
4721+
})
4722+
.wasInterrupted())
4723+
return failure();
47204724

47214725
return success();
47224726
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: not mlir-opt %s 2>&1 | FileCheck %s
2+
// CHECK: 'nvvm.tcgen05.alloc' op is not supported on sm_90
3+
4+
module {
5+
gpu.module @mod [#nvvm.target<chip = "sm_90">] {
6+
func.func @tcgen05_alloc(%arg0: !llvm.ptr<7>, %arg1: i32) {
7+
nvvm.tcgen05.alloc %arg0, %arg1 : !llvm.ptr<7>, i32
8+
return
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)