From f6709bc5795f0af48c29668c95b5b10e12d41a94 Mon Sep 17 00:00:00 2001 From: John Criswell Date: Thu, 6 May 2004 21:18:08 +0000 Subject: 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 --- llvm/lib/VMCore/iMemory.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/VMCore/iMemory.cpp') diff --git a/llvm/lib/VMCore/iMemory.cpp b/llvm/lib/VMCore/iMemory.cpp index 1fc1df8c95b..32fe71a0862 100644 --- a/llvm/lib/VMCore/iMemory.cpp +++ b/llvm/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; } -- cgit v1.2.3