[cfe-commits] r95577 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/const-init.cpp
Daniel Dunbar
daniel at zuster.org
Thu Feb 11 08:52:39 PST 2010
On Mon, Feb 8, 2010 at 1:46 PM, John McCall <rjmccall at apple.com> wrote:
> Author: rjmccall
> Date: Mon Feb 8 15:46:50 2010
> New Revision: 95577
>
> URL: http://llvm.org/viewvc/llvm-project?rev=95577&view=rev
> Log:
> Emit global references with constant initializers as constants. Fixes PR5585.
>
> The standard actually says that such references should have internal linkage,
> but gcc doesn't do that, so we probably can't get away with it.
Would it be worth trying?
- Daniel
>
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/test/CodeGenCXX/const-init.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=95577&r1=95576&r2=95577&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Feb 8 15:46:50 2010
> @@ -783,7 +783,7 @@
> }
>
> static bool DeclIsConstantGlobal(ASTContext &Context, const VarDecl *D) {
> - if (!D->getType().isConstant(Context))
> + if (!D->getType().isConstant(Context) && !D->getType()->isReferenceType())
> return false;
> if (Context.getLangOptions().CPlusPlus &&
> Context.getBaseElementType(D->getType())->getAs<RecordType>()) {
>
> Modified: cfe/trunk/test/CodeGenCXX/const-init.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/const-init.cpp?rev=95577&r1=95576&r2=95577&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/const-init.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/const-init.cpp Mon Feb 8 15:46:50 2010
> @@ -2,11 +2,11 @@
>
> // CHECK: @a = global i32 10
> int a = 10;
> -// CHECK: @ar = global i32* @a
> +// CHECK: @ar = constant i32* @a
> int &ar = a;
>
> void f();
> -// CHECK: @fr = global void ()* @_Z1fv
> +// CHECK: @fr = constant void ()* @_Z1fv
> void (&fr)() = f;
>
> struct S { int& a; };
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list