[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp
Chris Lattner
clattner at apple.com
Sat Apr 28 21:11:10 PDT 2007
> Index: llvm/lib/CodeGen/AsmPrinter.cpp
> diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.157 llvm/lib/CodeGen/
> AsmPrinter.cpp:1.158
> --- llvm/lib/CodeGen/AsmPrinter.cpp:1.157 Wed Apr 25 09:27:10 2007
> +++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Apr 28 08:44:59 2007
> @@ -123,18 +123,29 @@
> 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");
Just use cast<Constant>()
It will assert that the pointer is non-null and is a constant.
>
> - // 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");
This seems like a common operation: I'd suggest introducing an (out-
of-line) method to GlobalAlias:
GlobalValue *GlobalAlias::getAliaseeGlobal() const
That does this. At that point, you'd have:
if (const GlobalValue *GV = I->getAliaseeGlobal())
..
else
assert();
-Chris
> + }
> +
> if (I->hasExternalLinkage())
> O << "\t.globl\t" << Name << "\n";
> else if (I->hasWeakLinkage())
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list