[clang] [CIR] Refactor global variable emission and initialization (PR #138222)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 09:50:02 PDT 2025
================
@@ -324,8 +358,16 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
return entry;
}
- errorNYI(d->getSourceRange(), "reference of undeclared global");
- return {};
+ mlir::Location loc = getLoc(d->getSourceRange());
+
+ // mlir::SymbolTable::Visibility::Public is the default, no need to explicitly
+ // mark it as such.
+ cir::GlobalOp gv =
+ CIRGenModule::createGlobalOp(*this, loc, mangledName, ty,
+ /*insertPoint=*/entry.getOperation());
+
+ // errorNYI(d->getSourceRange(), "reference of undeclared global");
----------------
andykaylor wrote:
Yeah, I'm not sure how I left that. I had put this aside in the middle of creating the PR, so I think maybe I wanted to take another look at what the incubator does after this. There is a bit more code here, but nothing we're ready for yet. It handles deferred declarations from inline class members, and handles (or has NYI markers for) attributes based the info from the VarDecl. I think I was pausing here to test whether I had enough for it to work as it is, and it appears I do.
https://github.com/llvm/llvm-project/pull/138222
More information about the cfe-commits
mailing list