[Mlir-commits] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op trait (PR #126886)
Mehdi Amini
llvmlistbot at llvm.org
Tue Mar 11 03:23:13 PDT 2025
================
@@ -1439,6 +1440,36 @@ NVVMTargetAttr::verify(function_ref<InFlightDiagnostic()> emitError,
return success();
}
+//===----------------------------------------------------------------------===//
+// Requires minimum target SM trait helper functions
+//===----------------------------------------------------------------------===//
+llvm::SmallVector<NVVMCheckSMVersion> NVVM::getTargetSMVersions(Operation *op) {
+ llvm::SmallVector<NVVMCheckSMVersion> TargetSMVersions;
+ gpu::GPUModuleOp GPUModule = op->getParentOfType<gpu::GPUModuleOp>();
+ if (GPUModule && GPUModule->hasAttr("targets")) {
+ ArrayAttr Targets = dyn_cast<ArrayAttr>(GPUModule->getAttr("targets"));
----------------
joker-eph wrote:
You have a dyn_cast without checking here, that could crash on the next line.
```suggestion
if (!GPUModule) return {};
GPUModule->hasAttr("targets")) {
auto targets = GPUModule->getAttrOfType<ArrayAttr>("targets");
if (!target) return {};
```
https://github.com/llvm/llvm-project/pull/126886
More information about the Mlir-commits
mailing list