[cfe-commits] r112043 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGen/volatile.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Aug 25 03:15:24 PDT 2010


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

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;





More information about the cfe-commits mailing list