[Mlir-commits] [mlir] [MLIR][LLVM] Allow strings in module flag value (PR #136793)
Tobias Gysi
llvmlistbot at llvm.org
Tue Apr 22 23:00:49 PDT 2025
================
@@ -525,18 +525,22 @@ LogicalResult ModuleImport::convertModuleFlagsMetadata() {
SmallVector<Attribute> moduleFlags;
for (const auto [behavior, key, val] : llvmModuleFlags) {
- // Currently only supports most common: int constant values.
- auto *constInt = llvm::mdconst::dyn_extract<llvm::ConstantInt>(val);
- if (!constInt) {
+ Attribute valAttr = nullptr;
+ if (auto *constInt = llvm::mdconst::dyn_extract<llvm::ConstantInt>(val)) {
+ valAttr = builder.getI32IntegerAttr(constInt->getZExtValue());
+ } else if (auto *mdString = dyn_cast<llvm::MDString>(val)) {
+ valAttr = builder.getStringAttr(mdString->getString());
+ } else {
emitWarning(mlirModule.getLoc())
- << "unsupported module flag value: " << diagMD(val, llvmModule.get())
- << ", only constant integer currently supported";
- continue;
+ << "unsupported module flag value: " << diagMD(val, llvmModule.get());
}
+ if (!valAttr)
+ continue;
----------------
gysit wrote:
I would probably move the continue into the else above?
https://github.com/llvm/llvm-project/pull/136793
More information about the Mlir-commits
mailing list