[Mlir-commits] [mlir] [MLIR][LLVM] Allow importing of nameless globals (PR #101918)
Christian Ulmann
llvmlistbot at llvm.org
Sun Aug 4 20:26:54 PDT 2024
================
@@ -884,9 +890,15 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
globalExpressionAttr =
debugImporter->translateGlobalVariableExpression(globalExpressions[0]);
+ std::string globalName = globalVar->getName().str();
+ if (globalName == "") {
+ globalName = getNamelessGlobalPrefix().str() +
+ std::to_string(namelessGlobals.size());
+ namelessGlobals[globalVar] = FlatSymbolRefAttr::get(context, globalName);
+ }
GlobalOp globalOp = builder.create<GlobalOp>(
mlirModule.getLoc(), type, globalVar->isConstant(),
- convertLinkageFromLLVM(globalVar->getLinkage()), globalVar->getName(),
+ convertLinkageFromLLVM(globalVar->getLinkage()), globalName.c_str(),
----------------
Dinistro wrote:
Nit: Might be slightly more elegant to construct a `StringRef` instead, assuming this even works
```suggestion
convertLinkageFromLLVM(globalVar->getLinkage()), StringRef(globalName),
```
https://github.com/llvm/llvm-project/pull/101918
More information about the Mlir-commits
mailing list