Implement review feedback. Aliasees can be either GlobalValue's or

bitcasts of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36537 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov
2007-04-28 13:45:00 +00:00
parent 44b2c5098f
commit a80e1181b7
20 changed files with 231 additions and 113 deletions

View File

@@ -123,18 +123,29 @@ bool AsmPrinter::doFinalization(Module &M) {
}
if (TAI->getSetDirective()) {
if (M.alias_size())
if (!M.alias_empty())
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);
const Constant *Aliasee = dyn_cast_or_null<Constant>(I->getAliasee());
assert(Aliasee && "Aliasee cannot be null");
// Aliases with external weak linkage was emitted already
std::string Name = Mang->getValueName(I);
std::string Target;
if (const GlobalValue *GV = dyn_cast<GlobalValue>(Aliasee))
Target = Mang->getValueName(GV);
else {
const ConstantExpr *CE = 0;
if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
(CE->getOpcode() == Instruction::BitCast))
Target = Mang->getValueName(CE->getOperand(0));
else
assert(0 && "Unsupported aliasee");
}
if (I->hasExternalLinkage())
O << "\t.globl\t" << Name << "\n";
else if (I->hasWeakLinkage())