[PATCH] CodeGen: Emit globals with a constant initializer but no definition as available_externally.
Richard Smith
richard at metafoo.co.uk
Sun Nov 3 20:51:19 PST 2013
Seems like a great idea to me.
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1591
@@ +1590,3 @@
+ if (D->hasInit() && !D->hasDefinition(Context)) {
+ assert(!D->getType().isVolatileQualified());
+ assert(GetLLVMLinkageVarDefinition(D, /*isConstant=*/true) ==
----------------
This is incorrect. The following is valid:
struct S {
static constexpr volatile int n = 0;
};
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1884-1885
@@ +1883,4 @@
+ if (D->hasInit() && !D->hasDefinition(Context)) {
+ assert(isTypeConstant(D->getType(), /*ExcludeCtor=*/true) &&
+ "Variable with init but no definition should be constant!");
+ return llvm::GlobalValue::AvailableExternallyLinkage;
----------------
This is incorrect. The following is valid:
struct A {
mutable int n;
};
struct B {
static constexpr A a = { 0 };
};
http://llvm-reviews.chandlerc.com/D1982
More information about the cfe-commits
mailing list