handle gep aliasee
authorChris Lattner <sabre@nondot.org>
Sat, 5 May 2007 23:49:02 +0000 (23:49 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 5 May 2007 23:49:02 +0000 (23:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36815 91177308-0d34-0410-b5e6-96231b3b80d8

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");
     }