[PATCH] CodeGen: Emit constant array temporaries into read-only globals.
Richard Smith
richard at metafoo.co.uk
Tue Mar 3 14:38:18 PST 2015
================
Comment at: lib/CodeGen/CGExpr.cpp:390-395
@@ -372,8 +389,8 @@
if (auto *Var = dyn_cast<llvm::GlobalVariable>(Object)) {
// If the temporary is a global and has a constant initializer, we may
// have already initialized it.
if (!Var->hasInitializer()) {
Var->setInitializer(CGM.EmitNullConstant(E->getType()));
EmitAnyExprToMem(E, Object, Qualifiers(), /*IsInit*/true);
}
} else {
----------------
Ah, here's where we deal with this. This code wasn't intended to handle the new case, but it it does the right thing, so ... OK then :)
Please update this comment to say "if the temporary is a global or is a constant temporary that we promoted to a global" or similar.
http://reviews.llvm.org/D8034
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list