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

Chris Lattner lattner at cs.uiuc.edu
Mon Nov 3 11:34:33 PST 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.140 -> 1.141

---
Log message:

Fix bugs with attribute weak emission


---
Diffs of the changes:  (+6 -3)

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.140 llvm/lib/CWriter/Writer.cpp:1.141
--- llvm/lib/CWriter/Writer.cpp:1.140	Sun Nov  2 22:31:54 2003
+++ llvm/lib/CWriter/Writer.cpp	Mon Nov  3 11:32:38 2003
@@ -653,6 +653,7 @@
       if ((I->hasInternalLinkage() || !MangledGlobals.count(I)) &&
           !I->getIntrinsicID()) {
         printFunctionSignature(I, true);
+        if (I->hasWeakLinkage()) Out << " __attribute__((weak))";
         Out << ";\n";
       }
     }
@@ -671,7 +672,11 @@
       if (!I->isExternal()) {
         Out << "extern ";
         printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
-      
+
+        if (I->hasLinkOnceLinkage())
+          Out << " __attribute__((common))";
+        else if (I->hasWeakLinkage())
+          Out << " __attribute__((weak))";
         Out << ";\n";
       }
   }
@@ -903,8 +908,6 @@
   FunctionInnards << ")";
   // Print out the return type and the entire signature for that matter
   printType(Out, F->getReturnType(), FunctionInnards.str());
-
-  if (F->hasWeakLinkage()) Out << " __attribute((weak))";
 }
 
 void CWriter::printFunction(Function *F) {





More information about the llvm-commits mailing list