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 | a97b694c823eb346d255ca04724f4003f9056800 (patch) | |
tree | 3545f70936dcd0d230e479913f19dc1c78c37cfb /llvm/lib/CodeGen | |
parent | 7818c03c6b6dd1481c467e8292516a388d567e27 (diff) | |
download | bcm5719-llvm-a97b694c823eb346d255ca04724f4003f9056800.tar.gz bcm5719-llvm-a97b694c823eb346d255ca04724f4003f9056800.zip |
Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow.
llvm-svn: 36435
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 16c478dcdc1..90a98cb5a75 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/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; } |