[llvm-commits] [llvm] r41746 - in /llvm/trunk: lib/CodeGen/AsmPrinter.cpp test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll
Anton Korobeynikov
asl at math.spbu.ru
Thu Sep 6 10:21:48 PDT 2007
Author: asl
Date: Thu Sep 6 12:21:48 2007
New Revision: 41746
URL: http://llvm.org/viewvc/llvm-project?rev=41746&view=rev
Log:
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.
Added:
llvm/trunk/test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter.cpp?rev=41746&r1=41745&r2=41746&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter.cpp Thu Sep 6 12:21:48 2007
@@ -132,13 +132,11 @@
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 @@
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";
}
}
Added: llvm/trunk/test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll?rev=41746&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll Thu Sep 6 12:21:48 2007
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep weak | count 2
+ at __gthrw_pthread_once = alias weak i32 (i32*, void ()*)* @pthread_once ; <i32 (i32*, void ()*)*> [#uses=0]
+
+declare extern_weak i32 @pthread_once(i32*, void ()*)
More information about the llvm-commits
mailing list