1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Proper handle case, when aliasee is external weak symbol referenced only by alias itself.

Also, fix a case, when target doesn't have weak symbols supported.

llvm-svn: 41746
This commit is contained in:
Anton Korobeynikov 2007-09-06 17:21:48 +00:00
parent 6df3ab79be
commit 0e3789f07a
2 changed files with 17 additions and 6 deletions

View File

@ -132,13 +132,11 @@ bool AsmPrinter::doFinalization(Module &M) {
I!=E; ++I) {
std::string Name = Mang->getValueName(I);
std::string Target;
const GlobalValue *GV = cast<GlobalValue>(I->getAliasedGlobal());
Target = Mang->getValueName(GV);
if (const GlobalValue *GV = I->getAliasedGlobal())
Target = Mang->getValueName(GV);
else
assert(0 && "Unsupported aliasee");
if (I->hasExternalLinkage())
if (I->hasExternalLinkage() || !TAI->getWeakRefDirective())
O << "\t.globl\t" << Name << "\n";
else if (I->hasWeakLinkage())
O << TAI->getWeakRefDirective() << Name << "\n";
@ -146,6 +144,15 @@ bool AsmPrinter::doFinalization(Module &M) {
assert(0 && "Invalid alias linkage");
O << TAI->getSetDirective() << Name << ", " << Target << "\n";
// If the aliasee has external weak linkage it can be referenced only by
// alias itself. In this case it can be not in ExtWeakSymbols list. Emit
// weak reference in such case.
if (GV->hasExternalWeakLinkage())
if (TAI->getWeakRefDirective())
O << TAI->getWeakRefDirective() << Target << "\n";
else
O << "\t.globl\t" << Target << "\n";
}
}

View File

@ -0,0 +1,4 @@
; RUN: llvm-as < %s | llc -march=x86 | grep weak | count 2
@__gthrw_pthread_once = alias weak i32 (i32*, void ()*)* @pthread_once ; <i32 (i32*, void ()*)*> [#uses=0]
declare extern_weak i32 @pthread_once(i32*, void ()*)