Partial fix for PR1678: correct some parts of constant
[oota-llvm.git] / lib / VMCore / Globals.cpp
index 021d6bf801297f0fd470eb2b3e88e33fc1bc88f9..eb0df60757be4dff071e4b50dee4b1b34e9ee7ae 100644 (file)
@@ -210,7 +210,7 @@ void GlobalAlias::setAliasee(Constant *Aliasee)
   setOperand(0, Aliasee);
 }
 
-const GlobalValue *GlobalAlias::getAliasedGlobal() const  {
+const GlobalValue *GlobalAlias::getAliasedGlobal() const {
   const Constant *C = getAliasee();
   if (C) {
     if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
@@ -218,8 +218,9 @@ const GlobalValue *GlobalAlias::getAliasedGlobal() const  {
     else {
       const ConstantExpr *CE = 0;
       if ((CE = dyn_cast<ConstantExpr>(C)) &&
-          (CE->getOpcode() == Instruction::BitCast))
-        return cast<GlobalValue>(CE->getOperand(0));
+          (CE->getOpcode() == Instruction::BitCast || 
+           CE->getOpcode() == Instruction::GetElementPtr))
+        return dyn_cast<GlobalValue>(CE->getOperand(0));
       else
         assert(0 && "Unsupported aliasee");
     }