[cfe-commits] r112043 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGen/volatile.c
Chris Lattner
clattner at apple.com
Wed Aug 25 11:37:16 PDT 2010
On Aug 25, 2010, at 3:15 AM, Argyrios Kyrtzidis wrote:
> Author: akirtzidis
> Date: Wed Aug 25 05:15:24 2010
> New Revision: 112043
>
> URL: http://llvm.org/viewvc/llvm-project?rev=112043&view=rev
> Log:
> Make sure volatile variables are emitted even if static. Fixes rdar://8315219
Wait, I don't get it. Why does being volatile qualified force a global to be emitted? The optimizer will delete it, so I don't think this is correct.
-Chris
>
> Modified:
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/test/CodeGen/volatile.c
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=112043&r1=112042&r2=112043&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 25 05:15:24 2010
> @@ -5606,6 +5606,10 @@
> if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly)
> return false;
>
> + // Always emit volatiles.
> + if (VD->getType().isVolatileQualified())
> + return true;
> +
> // Structs that have non-trivial constructors or destructors are required.
>
> // FIXME: Handle references.
>
> Modified: cfe/trunk/test/CodeGen/volatile.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/volatile.c?rev=112043&r1=112042&r2=112043&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/volatile.c (original)
> +++ cfe/trunk/test/CodeGen/volatile.c Wed Aug 25 05:15:24 2010
> @@ -1,6 +1,7 @@
> // RUN: %clang_cc1 -emit-llvm < %s -o %t
> // RUN: grep volatile %t | count 28
> // RUN: grep memcpy %t | count 7
> +// RUN: %clang_cc1 %s -Wall -verify -emit-llvm -o - | FileCheck %s
>
> // The number 28 comes from the current codegen for volatile loads;
> // if this number changes, it's not necessarily something wrong, but
> @@ -96,5 +97,9 @@
> (void)vF2;
> vF2 = vF2;
> vF2 = vF2 = vF2;
> - vF2 = (vF2, vF2);
> + vF2 = (vF2, vF2); // expected-warning {{expression result unused}}
> }
> +
> +// Make sure this is emitted. rdar://8315219
> +// CHECK: @gvx
> +static volatile int gvx = 0;
>
>
> _______________________________________________
> 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