[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Anton Korobeynikov
asl at math.spbu.ru
Thu Nov 30 16:25:36 PST 2006
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.289 -> 1.290
---
Log message:
Introducing external weak linkage. Darwin codegen should be added later.
---
Diffs of the changes: (+11 -4)
Writer.cpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.289 llvm/lib/Target/CBackend/Writer.cpp:1.290
--- llvm/lib/Target/CBackend/Writer.cpp:1.289 Tue Nov 28 17:07:32 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Thu Nov 30 18:25:12 2006
@@ -1157,8 +1157,6 @@
<< "#define __attribute__(X)\n"
<< "#endif\n\n";
-#if 0
- // At some point, we should support "external weak" vs. "weak" linkages.
// On Mac OS X, "external weak" is spelled "__attribute__((weak_import))".
Out << "#if defined(__GNUC__) && defined(__APPLE_CC__)\n"
<< "#define __EXTERNAL_WEAK__ __attribute__((weak_import))\n"
@@ -1167,7 +1165,6 @@
<< "#else\n"
<< "#define __EXTERNAL_WEAK__\n"
<< "#endif\n\n";
-#endif
// For now, turn off the weak linkage attribute on Mac OS X. (See above.)
Out << "#if defined(__GNUC__) && defined(__APPLE_CC__)\n"
@@ -1357,7 +1354,11 @@
Out << "__declspec(dllimport) ";
printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
Out << ";\n";
- }
+ } else if (I->hasExternalWeakLinkage()) {
+ Out << "extern ";
+ printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
+ Out << " __EXTERNAL_WEAK__ ;\n";
+ }
}
}
@@ -1370,9 +1371,13 @@
// Don't print declarations for intrinsic functions.
if (!I->getIntrinsicID() && I->getName() != "setjmp" &&
I->getName() != "longjmp" && I->getName() != "_setjmp") {
+ if (I->hasExternalWeakLinkage())
+ Out << "extern ";
printFunctionSignature(I, true);
if (I->hasWeakLinkage() || I->hasLinkOnceLinkage())
Out << " __ATTRIBUTE_WEAK__";
+ if (I->hasExternalWeakLinkage())
+ Out << " __EXTERNAL_WEAK__";
if (StaticCtors.count(I))
Out << " __ATTRIBUTE_CTOR__";
if (StaticDtors.count(I))
@@ -1405,6 +1410,8 @@
Out << " __attribute__((common))";
else if (I->hasWeakLinkage())
Out << " __ATTRIBUTE_WEAK__";
+ else if (I->hasExternalWeakLinkage())
+ Out << " __EXTERNAL_WEAK__";
Out << ";\n";
}
}
More information about the llvm-commits
mailing list