... when the are no SPIR-V env attributes.
Fixes: https://github.com/llvm/llvm-project/issues/59983
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D141695
spirv::ModuleOp module = getOperation();
MLIRContext *context = &getContext();
- spirv::TargetEnv targetEnv(spirv::lookupTargetEnv(module));
+ spirv::TargetEnvAttr targetEnvAttr = spirv::lookupTargetEnv(module);
+ if (!targetEnvAttr) {
+ module->emitOpError("missing SPIR-V target env attribute");
+ return signalPassFailure();
+ }
+ spirv::TargetEnv targetEnv(targetEnvAttr);
SPIRVTypeConverter typeConverter(targetEnv);
-// RUN: mlir-opt -split-input-file -spirv-lower-abi-attrs %s | FileCheck %s
+// RUN: mlir-opt --split-input-file --spirv-lower-abi-attrs --verify-diagnostics %s \
+// RUN: | FileCheck %s
module attributes {
spirv.target_env = #spirv.target_env<
} // end spirv.module
} // end module
+
+// -----
+
+module {
+// expected-error@+1 {{'spirv.module' op missing SPIR-V target env attribute}}
+spirv.module Logical GLSL450 {}
+} // end module