Allow aliasee to be a GEP or bitcast instead of just a bitcast.

The real fix for this whole mess is to require the operand of the
alias to be a *GlobalValue* (not a general constant, including 
constant exprs) but allow the operand and the alias type to be
unrelated.

This fixes PR4066

llvm-svn: 70079
This commit is contained in:
Chris Lattner 2009-04-25 21:23:19 +00:00
parent 95272494cb
commit cde89e48b2
2 changed files with 9 additions and 7 deletions

View File

@ -1317,12 +1317,12 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) {
Out << ' '; Out << ' ';
PrintLLVMName(Out, GA); PrintLLVMName(Out, GA);
} else { } else {
const ConstantExpr *CE = 0; const ConstantExpr *CE = cast<ConstantExpr>(Aliasee);
if ((CE = dyn_cast<ConstantExpr>(Aliasee)) && // The only valid GEP is an all zero GEP.
(CE->getOpcode() == Instruction::BitCast)) { assert((CE->getOpcode() == Instruction::BitCast ||
writeOperand(CE, false); CE->getOpcode() == Instruction::GetElementPtr) &&
} else "Unsupported aliasee");
assert(0 && "Unsupported aliasee"); writeOperand(CE, false);
} }
printInfoComment(*GA); printInfoComment(*GA);

View File

@ -427,7 +427,9 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) {
if (!isa<GlobalValue>(GA.getAliasee())) { if (!isa<GlobalValue>(GA.getAliasee())) {
const ConstantExpr *CE = dyn_cast<ConstantExpr>(GA.getAliasee()); const ConstantExpr *CE = dyn_cast<ConstantExpr>(GA.getAliasee());
Assert1(CE && CE->getOpcode() == Instruction::BitCast && Assert1(CE &&
(CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::GetElementPtr) &&
isa<GlobalValue>(CE->getOperand(0)), isa<GlobalValue>(CE->getOperand(0)),
"Aliasee should be either GlobalValue or bitcast of GlobalValue", "Aliasee should be either GlobalValue or bitcast of GlobalValue",
&GA); &GA);