[clang] [CIR] Defer declarations and tentative definitions (PR #141700)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Wed May 28 01:32:40 PDT 2025
================
@@ -1044,6 +1057,24 @@ StringRef CIRGenModule::getMangledName(GlobalDecl gd) {
return mangledDeclNames[canonicalGd] = result.first->first();
}
+void CIRGenModule::emitTentativeDefinition(const VarDecl *d) {
+ assert(!d->getInit() && "Cannot emit definite definitions here!");
+
+ StringRef mangledName = getMangledName(d);
+ mlir::Operation *gv = getGlobalValue(mangledName);
+
+ // If we already have a definition, not declaration, with the same mangled
+ // name, emitting of declaration is not required (and would actually overwrite
+ // the emitted definition).
+ if (gv && !cast<cir::GlobalOp>(gv).isDeclaration())
----------------
xlauko wrote:
```suggestion
if (gv && !mlir::cast<cir::GlobalOp>(gv).isDeclaration())
```
https://github.com/llvm/llvm-project/pull/141700
More information about the cfe-commits
mailing list