[Mlir-commits] [mlir] [MLIR][LLVM] Allow importing of nameless globals (PR #101918)

Christian Ulmann llvmlistbot at llvm.org
Sun Aug 4 20:26:55 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() +
----------------
Dinistro wrote:

Nit: Maybe add a small comment that explains why this is necessary. 

Something like this, maybe?
```suggestion
    // Workaround to support LLVM's nameless globals. MLIR, in contrast to LLVM, always requires a symbol name.
    globalName = getNamelessGlobalPrefix().str() +
```

https://github.com/llvm/llvm-project/pull/101918


More information about the Mlir-commits mailing list