[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Nov 12 00:40:00 PST 2005



Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.131 -> 1.132
---
Log message:

Unswitch a loop, add more assertions, eliminate use of removeUserFromConcrete.


---
Diffs of the changes:  (+14 -10)

 Type.cpp |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.131 llvm/lib/VMCore/Type.cpp:1.132
--- llvm/lib/VMCore/Type.cpp:1.131	Sat Nov 12 02:22:41 2005
+++ llvm/lib/VMCore/Type.cpp	Sat Nov 12 02:39:48 2005
@@ -736,7 +736,9 @@
   /// The specified iterator tells us what the type USED to look like.
   void finishRefinement(TypeClass *Ty, const DerivedType *OldType,
                         const Type *NewType) {
-    assert((Ty->isAbstract() || !OldType->isAbstract()) &&
+    // Either NewTy == OldTy (in which case the specified type just became
+    // concrete) or they are different an the Ty is thought to be abstract.
+    assert((Ty->isAbstract() || OldType == NewType) &&
            "Refining a non-abstract type!");
 #ifdef DEBUG_MERGE_TYPES
     std::cerr << "refineAbstractTy(" << (void*)OldType << "[" << *OldType
@@ -755,20 +757,22 @@
     // Remember the structural hash for the type before we start hacking on it,
     // in case we need it later.
     unsigned OldTypeHash = ValType::hashTypeStructure(Ty);
-    unsigned NewTypeHash;
 
     // Find the type element we are refining... and change it now!
-    if (OldType != NewType || !OldType->isAbstract()) {
+    if (!OldType->isAbstract()) {
+      // If the element just became concrete, remove 'ty' from the abstract
+      // type user list for the type.
       for (unsigned i = 0, e = Ty->ContainedTys.size(); i != e; ++i)
-        if (Ty->ContainedTys[i] == OldType) {
-          Ty->ContainedTys[i].removeUserFromConcrete();
-          Ty->ContainedTys[i] = NewType;
-        }
-      NewTypeHash = ValType::hashTypeStructure(Ty);
+        if (Ty->ContainedTys[i] == OldType)
+          OldType->removeAbstractTypeUser(Ty);
     } else {
-      NewTypeHash = OldTypeHash;
+      assert(OldType != NewType && "Unknown case!");
+      for (unsigned i = 0, e = Ty->ContainedTys.size(); i != e; ++i)
+        if (Ty->ContainedTys[i] == OldType)
+          Ty->ContainedTys[i] = NewType;
     }
-
+    unsigned NewTypeHash = ValType::hashTypeStructure(Ty);
+    
     // If there are no cycles going through this node, we can do a simple,
     // efficient lookup in the map, instead of an inefficient nasty linear
     // lookup.






More information about the llvm-commits mailing list