Teach getUnderlyingObject and skipPointerCasts about GlobalAliases.
authorDan Gohman <gohman@apple.com>
Thu, 27 Aug 2009 17:55:13 +0000 (17:55 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 27 Aug 2009 17:55:13 +0000 (17:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80265 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Value.cpp

index 34291b9d728fa7f7065d4ba0d6d4a1febbee9da9..f6740626096398327e56050983aefcc3baafd93d 100644 (file)
@@ -340,6 +340,10 @@ Value *Value::stripPointerCasts() {
       V = GEP->getPointerOperand();
     } else if (Operator::getOpcode(V) == Instruction::BitCast) {
       V = cast<Operator>(V)->getOperand(0);
+    } else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
+      if (GA->mayBeOverridden())
+        return V;
+      V = GA->getAliasee();
     } else {
       return V;
     }
@@ -357,6 +361,10 @@ Value *Value::getUnderlyingObject() {
       V = GEP->getPointerOperand();
     } else if (Operator::getOpcode(V) == Instruction::BitCast) {
       V = cast<Operator>(V)->getOperand(0);
+    } else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
+      if (GA->mayBeOverridden())
+        return V;
+      V = GA->getAliasee();
     } else {
       return V;
     }