[Mlir-commits] [mlir] [mlir][llvm] adds an attribute for the module level assembly (PR #151318)
Tobias Gysi
llvmlistbot at llvm.org
Wed Jul 30 10:14:20 PDT 2025
================
@@ -2276,6 +2276,13 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
llvmModule->setTargetTriple(
llvm::Triple(cast<StringAttr>(targetTripleAttr).getValue()));
+ if (auto asmAttr =
+ m->getDiscardableAttr(LLVM::LLVMDialect::getModuleLevelAsmAttrName())) {
+ auto arr = cast<ArrayAttr>(asmAttr);
+ for (unsigned i = 0; i < arr.size(); ++i)
----------------
gysit wrote:
I would suggest to verify that the attribute is actually an array attribute containing strings and then use `m.emitError(...)` to produce an error message if the translation fails. IUC prepareLLVMModule can signal an error by returning nullptr.
`llvm-project/mlir/test/Target/LLVMIR/invalid-module.mlir` could be used for a small test.
https://github.com/llvm/llvm-project/pull/151318
More information about the Mlir-commits
mailing list