aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/iMemory.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp
index 1fc1df8c95..32fe71a086 100644
--- a/lib/VMCore/iMemory.cpp
+++ b/lib/VMCore/iMemory.cpp
@@ -156,6 +156,14 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
return 0; // Can only index into pointer types at the first index!
if (!CT->indexValid(Index)) return 0;
Ptr = CT->getTypeAtIndex(Index);
+
+ // If the new type forwards to another type, then it is in the middle
+ // of being refined to another type (and hence, may have dropped all
+ // references to what it was using before). So, use the new forwarded
+ // type.
+ if (Ptr->getForwardedType()) {
+ Ptr = Ptr->getForwardedType();
+ }
}
return CurIdx == Idx.size() ? Ptr : 0;
}