Implement the TargetMachine::getJITStubForFunction method for X86, finegrainify
[oota-llvm.git] / lib / VMCore / SlotCalculator.cpp
index b426cb74fbd9891d6dcc27325b9bddf6c2e863a3..f4414a5921d84e4f5a1f3ed5c091b08d5443b2db 100644 (file)
 #include "llvm/Constant.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/SymbolTable.h"
-#include "Support/DepthFirstIterator.h"
+#include "Support/PostOrderIterator.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
+using namespace llvm;
 
 #if 0
 #define SC_DEBUG(X) std::cerr << X
@@ -287,26 +288,20 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
     SC_DEBUG("  Inserted type: " << TheTy->getDescription() << " slot=" <<
              ResultSlot << "\n");
 
-    // Loop over any contained types in the definition... in reverse depth
-    // first order.
+    // Loop over any contained types in the definition... in post
+    // order.
     //
-    std::vector<const Type*> DfsOrder;
-    for (df_iterator<const Type*> I = df_begin(TheTy), E = df_end(TheTy);
+    for (po_iterator<const Type*> I = po_begin(TheTy), E = po_end(TheTy);
          I != E; ++I) {
       if (*I != TheTy) {
-       // If we haven't seen this sub type before, add it to our type table!
-       DfsOrder.push_back(*I);
-      }
-    }
-
-    for (std::vector<const Type*>::const_reverse_iterator
-             I = DfsOrder.rbegin(), E = DfsOrder.rend(); I != E; ++I) {
         const Type *SubTy = *I;
-      if (getSlot(SubTy) == -1) {
-       SC_DEBUG("  Inserting subtype: " << SubTy->getDescription() << "\n");
-        int Slot = doInsertValue(SubTy);
-        SC_DEBUG("  Inserted subtype: " << SubTy->getDescription() << 
-                 " slot=" << Slot << "\n");
+       // If we haven't seen this sub type before, add it to our type table!
+        if (getSlot(SubTy) == -1) {
+          SC_DEBUG("  Inserting subtype: " << SubTy->getDescription() << "\n");
+          int Slot = doInsertValue(SubTy);
+          SC_DEBUG("  Inserted subtype: " << SubTy->getDescription() << 
+                   " slot=" << Slot << "\n");
+        }
       }
     }
     return ResultSlot;