[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp
Chris Lattner
clattner at apple.com
Sat Apr 28 21:16:58 PDT 2007
> +++ llvm/lib/VMCore/AsmWriter.cpp Sat Apr 28 08:44:59 2007
> @@ -926,7 +926,7 @@
> assert(0 && "Invalid alias linkage");
> }
>
> - const GlobalValue *Aliasee = GA->getAliasee();
> + const Constant *Aliasee = dyn_cast_or_null<Constant>(GA-
> >getAliasee());
> assert(Aliasee && "Aliasee cannot be null");
You can drop the dyn_cast_or_null
>
> if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Aliasee)) {
> @@ -940,9 +940,15 @@
> Out << getLLVMName(F->getName(), GlobalPrefix);
> else
> Out << "@\"\"";
> - } else
> - assert(0 && "Unsupported aliasee");
> -
> + } else {
> + const ConstantExpr *CE = 0;
> + if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
> + (CE->getOpcode() == Instruction::BitCast)) {
> + writeOperand(CE, false);
> + } else
> + assert(0 && "Unsupported aliasee");
> + }
This can use the new getAliaseeGlobal() method.
> bool GlobalAlias::isDeclaration() const {
> - return (Aliasee && Aliasee->isDeclaration());
> + const GlobalValue* AV = dyn_cast_or_null<const GlobalValue>
> (getAliasee());
> + return (AV && AV->isDeclaration());
> }
What does it mean for an alias to be a declaration? I'd be fine with
them always returning true or false. What code calls
GlobalValue::isDeclaration?
> +void GlobalAlias::setAliasee(Constant *Aliasee)
> {
> - // FIXME: Some checks?
> - Aliasee = GV;
> + if (Aliasee) {
> + assert(Aliasee->getType() == getType() &&
> + "Alias and aliasee types should match!");
> + setOperand(0, Aliasee);
> + }
> }
With this code, setAliasee(0) is a noop - that is a bug.
-Chris
More information about the llvm-commits
mailing list