aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/AsmWriter.cpp12
-rw-r--r--lib/VMCore/Verifier.cpp4
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index f007c76..742931e 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1317,12 +1317,12 @@ void AssemblyWriter::printAlias(const GlobalAlias *GA) {
Out << ' ';
PrintLLVMName(Out, GA);
} else {
- const ConstantExpr *CE = 0;
- if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
- (CE->getOpcode() == Instruction::BitCast)) {
- writeOperand(CE, false);
- } else
- assert(0 && "Unsupported aliasee");
+ const ConstantExpr *CE = cast<ConstantExpr>(Aliasee);
+ // The only valid GEP is an all zero GEP.
+ assert((CE->getOpcode() == Instruction::BitCast ||
+ CE->getOpcode() == Instruction::GetElementPtr) &&
+ "Unsupported aliasee");
+ writeOperand(CE, false);
}
printInfoComment(*GA);
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index df9acee..5e1137f 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -427,7 +427,9 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) {
if (!isa<GlobalValue>(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)),
"Aliasee should be either GlobalValue or bitcast of GlobalValue",
&GA);