[llvm-commits] [llvm] r137134 - in /llvm/trunk: lib/Target/CBackend/CBackend.cpp test/CodeGen/CBackend/pr10081.ll

Bill Wendling isanbard at gmail.com
Tue Aug 9 11:31:50 PDT 2011


Author: void
Date: Tue Aug  9 13:31:50 2011
New Revision: 137134

URL: http://llvm.org/viewvc/llvm-project?rev=137134&view=rev
Log:
Print out the variable declaration only if it is a declaration. Otherwise, a
'static' variable will be emitted twice.
PR10081

Added:
    llvm/trunk/test/CodeGen/CBackend/pr10081.ll
Modified:
    llvm/trunk/lib/Target/CBackend/CBackend.cpp

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=137134&r1=137133&r2=137134&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Aug  9 13:31:50 2011
@@ -1817,7 +1817,7 @@
     Out << "\n\n/* Global Variable Declarations */\n";
     for (Module::global_iterator I = M.global_begin(), E = M.global_end();
          I != E; ++I)
-      if (!I->isDeclaration()) {
+      if (I->isDeclaration()) {
         // Ignore special globals, such as debug info.
         if (getGlobalVariableClass(I))
           continue;

Added: llvm/trunk/test/CodeGen/CBackend/pr10081.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CBackend/pr10081.ll?rev=137134&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/CBackend/pr10081.ll (added)
+++ llvm/trunk/test/CodeGen/CBackend/pr10081.ll Tue Aug  9 13:31:50 2011
@@ -0,0 +1,11 @@
+; RUN: llc < %s -march=c | grep {static float _ZL3foo} | count 1
+; PR10081
+
+ at _ZL3foo = internal global float 0.000000e+00, align 4
+
+define float @_Z3barv() nounwind ssp {
+  %1 = load float* @_ZL3foo, align 4
+  %2 = fadd float %1, 1.000000e+00
+  store float %2, float* @_ZL3foo, align 4
+  ret float %1
+}





More information about the llvm-commits mailing list