diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2006-12-01 09:13:26 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2006-12-01 09:13:26 +0000 |
| commit | 5fb2c76d599717900305e500222fd4c997061455 (patch) | |
| tree | f03653bc2d44f1adaeac12555aeaec94337688b9 /llvm/lib | |
| parent | fa54c0b6fb1770bf723e28b83ca9bf92c5a6e034 (diff) | |
| download | bcm5719-llvm-5fb2c76d599717900305e500222fd4c997061455.tar.gz bcm5719-llvm-5fb2c76d599717900305e500222fd4c997061455.zip | |
A initialized global variable cannot be extern weak. However, if a global value's initializer is itself a external weak symbol, emit the weak reference.
llvm-svn: 32069
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86AsmPrinter.cpp | 17 |
2 files changed, 16 insertions, 11 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index fdc335d4cf4..0998c29226a 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -605,6 +605,9 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: + case GlobalValue::ExternalWeakLinkage: + O << "\t.weak_reference " << name << "\n"; + break; case GlobalValue::WeakLinkage: O << "\t.globl " << name << '\n' << "\t.weak_definition " << name << '\n'; @@ -635,6 +638,13 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { EmitAlignment(Align, I); O << name << ":\t\t\t\t; '" << I->getName() << "'\n"; + + // If the initializer is a extern weak symbol, remember to emit the weak + // reference! + if (const GlobalValue *GV = dyn_cast<GlobalValue>(C)) + if (GV->hasExternalWeakLinkage()) + ExtWeakSymbols.insert(Mang->getValueName(GV)); + EmitGlobalConstant(C); O << '\n'; } diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index a37cbb5406b..b92a087859d 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -177,17 +177,6 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n"; } else { switch (I->getLinkage()) { - case GlobalValue::ExternalWeakLinkage: - if (Subtarget->isTargetDarwin()) { - assert(0 && "External weak linkage for Darwin not implemented yet"); - } else if (Subtarget->isTargetCygwin()) { - // There is no external weak linkage on Mingw32 platform. - // Defaulting just to external - O << "\t.globl " << name << "\n"; - } else { - O << "\t.weak " << name << "\n"; - break; - } case GlobalValue::LinkOnceLinkage: case GlobalValue::WeakLinkage: if (Subtarget->isTargetDarwin()) { @@ -257,6 +246,12 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size " << name << ", " << Size << "\n"; + // If the initializer is a extern weak symbol, remember to emit the weak + // reference! + if (const GlobalValue *GV = dyn_cast<GlobalValue>(C)) + if (GV->hasExternalWeakLinkage()) + ExtWeakSymbols.insert(Mang->getValueName(GV)); + EmitGlobalConstant(C); O << '\n'; } |

