diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:27:10 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:27:10 +0000 |
commit | 8b0a8c84da2030ee8f4440d5b60a8033de691222 (patch) | |
tree | 7b780ed0cf12403faeac0e65fb16bca29fda5dbf /lib/CodeGen/AsmPrinter.cpp | |
parent | 24a3cc4c83e5edb25fadf7b8979a26b4451795c6 (diff) |
Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 16c478dcdc..90a98cb5a7 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -111,7 +111,7 @@ bool AsmPrinter::doInitialization(Module &M) { bool AsmPrinter::doFinalization(Module &M) { if (TAI->getWeakRefDirective()) { - if (ExtWeakSymbols.begin() != ExtWeakSymbols.end()) + if (!ExtWeakSymbols.empty()) SwitchToDataSection(""); for (std::set<const GlobalValue*>::iterator i = ExtWeakSymbols.begin(), @@ -122,6 +122,30 @@ bool AsmPrinter::doFinalization(Module &M) { } } + if (TAI->getSetDirective()) { + if (M.alias_size()) + SwitchToTextSection(TAI->getTextSection()); + + O << "\n"; + for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end(); + I!=E; ++I) { + const GlobalValue *Aliasee = I->getAliasee(); + assert(Aliasee && "Aliasee cannot be null!"); + std::string Target = Mang->getValueName(Aliasee); + std::string Name = Mang->getValueName(I); + + // Aliases with external weak linkage was emitted already + if (I->hasExternalLinkage()) + O << "\t.globl\t" << Name << "\n"; + else if (I->hasWeakLinkage()) + O << TAI->getWeakRefDirective() << Name << "\n"; + else if (!I->hasInternalLinkage()) + assert(0 && "Invalid alias linkage"); + + O << TAI->getSetDirective() << Name << ", " << Target << "\n"; + } + } + delete Mang; Mang = 0; return false; } |