summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2004-05-06 21:18:08 +0000
committerJohn Criswell <criswell@uiuc.edu>2004-05-06 21:18:08 +0000
commit7775c1f1363ca92609f3529ea05bbaad88a09926 (patch)
treec5b7116f29aa724b5fc6d7cd5a9997f02e03e298 /lib
parent817d8d304688457ce57296fa8c5c5f62b682aa74 (diff)
downloadexternal_llvm-7775c1f1363ca92609f3529ea05bbaad88a09926.zip
external_llvm-7775c1f1363ca92609f3529ea05bbaad88a09926.tar.gz
external_llvm-7775c1f1363ca92609f3529ea05bbaad88a09926.tar.bz2
Fix for PR#330.
When looking at getelementptr instructions, make sure to use a forwarded type. We want to do this because a DerivedType may drop its uses and then refine its users, who may then use another user who hasn't been refined yet. By getting the forwarded type, we always ensure that we're looking at a Type that isn't in a halfway refined state. Now, I should be able to put this stuff in PATypeHandle, but it doesn't work for some reason. This should do for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-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 1fc1df8..32fe71a 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;
}