aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-03 17:35:00 +0000
committerChris Lattner <sabre@nondot.org>2003-11-03 17:35:00 +0000
commit5ea326a23b0cf74e3f1f96b8846b43437a00cd2a (patch)
tree6dfe343410da52a01641ef15dc35f0de85cf4947 /lib/Target/CBackend/Writer.cpp
parent2580d4f232ce0885e1ffc03240ebbcc031b05a43 (diff)
Work around a bug in GCC where it can't handle common variables marked weak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend/Writer.cpp')
-rw-r--r--lib/Target/CBackend/Writer.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 0fd3046021..258c287878 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -693,7 +693,14 @@ void CWriter::printModule(Module *M) {
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());
}