================
@@ -3374,10 +3379,93 @@ void CIRGenModule::release() {
emitLLVMUsed();
+ // Classic codegen calls `checkAliases` here to validate any alias
+ // definitions emitted during codegen.
+ assert(!cir::MissingFeatures::checkAliases());
+
// There's a lot of code that is not implemented yet.
assert(!cir::MissingFeatures::cgmRelease());
}
+void CIRGenModule::emitAliasDefinition(GlobalDecl gd) {
+ const auto *d = cast<ValueDecl>(gd.getDecl());
+ const AliasAttr *aa = d->getAttr<AliasAttr>();
+ assert(aa && "Not an alias?");
+
+ StringRef mangledName = getMangledName(gd);
+
+ if (aa->getAliasee() == mangledName) {
+ diags.Report(aa->getLocation(), diag::err_cyclic_alias) << 0;
+ return;
+ }
+
+ // If there is a definition in the module, then it wins over the alias.
+ // This is dubious, but allow it to be safe. Just ignore the alias.
+ mlir::Operation *entry = getGlobalValue(mangledName);
+ if (entry) {
+ auto entryGV = mlir::dyn_cast<cir::CIRGlobalValueInterface>(entry);
+ if (entryGV && !entryGV.isDeclaration())
----------------
erichkeane wrote:
Ok, so `isDeclaration` is actually wrong as a function, and it absolutely slays
readability here. In C/C++ parlance, 'declaration' is a subset of 'definition'
(in that ALL definitions are declarations). So I'd vastly prefer if this was
`&& entryGV.isDefinition()`
https://github.com/llvm/llvm-project/pull/195972
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits