From 088eb45cf4be366750874c25b6c8a7a6ed434c8c Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Fri, 31 Oct 2003 03:02:34 +0000 Subject: [PATCH] Use already existing classes for post order iterator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9629 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Writer/SlotCalculator.cpp | 28 ++++++++++---------------- lib/VMCore/SlotCalculator.cpp | 28 ++++++++++---------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index b426cb74fbd..aef71763c44 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -23,7 +23,7 @@ #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 @@ -287,26 +287,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 DfsOrder; - for (df_iterator I = df_begin(TheTy), E = df_end(TheTy); + for (po_iterator 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_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; diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index b426cb74fbd..aef71763c44 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -23,7 +23,7 @@ #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 @@ -287,26 +287,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 DfsOrder; - for (df_iterator I = df_begin(TheTy), E = df_end(TheTy); + for (po_iterator 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_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; -- 2.34.1