Fix major bugs in type resolution


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1092 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index fcf92fa..ec39a9f 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -103,7 +103,8 @@
 //
 void BytecodeParser::refineAbstractType(const DerivedType *OldType, 
 					const Type *NewType) {
-  if (OldType == NewType) return;  // Type is modified, but same
+  if (OldType == NewType &&
+      OldType->isAbstract()) return;  // Type is modified, but same
 
   TypeValuesListTy::iterator I = find(MethodTypeValues.begin(), 
 				      MethodTypeValues.end(), OldType);
@@ -113,7 +114,12 @@
 	   "Can't refine a type I don't know about!");
   }
 
-  *I = NewType;  // Update to point to new, more refined type.
+  if (OldType == NewType) {
+    assert(!OldType->isAbstract());
+    I->removeUserFromConcrete();
+  } else {
+    *I = NewType;  // Update to point to new, more refined type.
+  }
 }