[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Nov 3 11:36:04 PST 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.141 -> 1.142

---
Log message:

Work around a bug in GCC where it can't handle common variables marked weak.


---
Diffs of the changes:  (+8 -1)

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.141 llvm/lib/CWriter/Writer.cpp:1.142
--- llvm/lib/CWriter/Writer.cpp:1.141	Mon Nov  3 11:32:38 2003
+++ llvm/lib/CWriter/Writer.cpp	Mon Nov  3 11:35:00 2003
@@ -693,7 +693,14 @@
           Out << " __attribute__((common))";
         else if (I->hasWeakLinkage())
           Out << " __attribute__((weak))";
-        if (!I->getInitializer()->isNullValue()) {
+
+        // If the initializer is not null, emit the initializer.  If it is null,
+        // we try to avoid emitting large amounts of zeros.  The problem with
+        // this, however, occurs when the variable has weak linkage.  In this
+        // case, the assembler will complain about the variable being both weak
+        // and common, so we disable this optimization.
+        if (!I->getInitializer()->isNullValue() ||
+            I->hasWeakLinkage()) {
           Out << " = " ;
           writeOperand(I->getInitializer());
         }





More information about the llvm-commits mailing list