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.

llvm-svn: 13386
This commit is contained in:
John Criswell 2004-05-06 21:18:08 +00:00
parent 8737169a6a
commit f6709bc579
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}