[Mlir-commits] [mlir] [mlir][llvm] adds an attribute for the module level assembly (PR #151318)
Tobias Gysi
llvmlistbot at llvm.org
Thu Jul 31 04:17:27 PDT 2025
================
@@ -2276,6 +2276,24 @@ prepareLLVMModule(Operation *m, llvm::LLVMContext &llvmContext,
llvmModule->setTargetTriple(
llvm::Triple(cast<StringAttr>(targetTripleAttr).getValue()));
+ if (auto asmAttr = m->getDiscardableAttr(
+ LLVM::LLVMDialect::getModuleLevelAsmAttrName())) {
+ if (!isa<ArrayAttr>(asmAttr)) {
+ m->emitError("expected an array attribute for a module level asm");
+ return nullptr;
+ }
+
+ auto arr = cast<ArrayAttr>(asmAttr);
----------------
gysit wrote:
```suggestion
auto asmArrayAttr = dyn_cast<ArrayAttr>(asmAttr);
if (!asmArrayAttr) {
m->emitError("expected an array attribute for a module level asm");
return nullptr;
}
```
nit: I would dyn_cast once.
https://github.com/llvm/llvm-project/pull/151318
More information about the Mlir-commits
mailing list