[llvm-commits] CVS: llvm/include/llvm/Support/CFG.h

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 31 17:22:22 PST 2005



Changes in directory llvm/include/llvm/Support:

CFG.h updated: 1.22 -> 1.23
---
Log message:

Switch from using an ilist for uses to using a custom doubly linked list.
This list does not provide the ability to go backwards in the list (its
more of an unordered collection, stored in the shape of a list).

This change means that use iterators are now only forward iterators, not 
bidirectional.

This improves the memory usage of use lists from '5 + 4*#use' per value to
'1 + 4*#use'.  While it would be better to reduce the multiplied factor,
I'm not smart enough to do so.  This list also has slightly more efficient
operators for manipulating list nodes (a few less loads/stores), due to not
needing to be able to iterate backwards through the list.

This change reduces the memory footprint required to hold 176.gcc from 
66.025M -> 57.687M, a 14% reduction.  It also speeds up the compiler,
7.73% in the case of bytecode loading alone (release build loading 176.gcc).



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

 CFG.h |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)


Index: llvm/include/llvm/Support/CFG.h
diff -u llvm/include/llvm/Support/CFG.h:1.22 llvm/include/llvm/Support/CFG.h:1.23
--- llvm/include/llvm/Support/CFG.h:1.22	Wed Sep  1 17:55:34 2004
+++ llvm/include/llvm/Support/CFG.h	Mon Jan 31 19:22:06 2005
@@ -27,22 +27,22 @@
 //===--------------------------------------------------------------------===//
 
 template <class _Ptr,  class _USE_iterator> // Predecessor Iterator
-class PredIterator : public bidirectional_iterator<_Ptr, ptrdiff_t> {
-  typedef bidirectional_iterator<_Ptr, ptrdiff_t> super;
+class PredIterator : public forward_iterator<_Ptr, ptrdiff_t> {
+  typedef forward_iterator<_Ptr, ptrdiff_t> super;
   _Ptr *BB;
   _USE_iterator It;
 public:
   typedef PredIterator<_Ptr,_USE_iterator> _Self;
   typedef typename super::pointer pointer;
   
-  inline void advancePastConstants() {
+  inline void advancePastNonTerminators() {
     // Loop to ignore non terminator uses (for example PHI nodes)...
     while (It != BB->use_end() && !isa<TerminatorInst>(*It))
       ++It;
   }
   
   inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) {
-    advancePastConstants();
+    advancePastNonTerminators();
   }
   inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {}
     
@@ -57,18 +57,13 @@
   
   inline _Self& operator++() {   // Preincrement
     assert(It != BB->use_end() && "pred_iterator out of range!");
-    ++It; advancePastConstants();
+    ++It; advancePastNonTerminators();
     return *this; 
   }
   
   inline _Self operator++(int) { // Postincrement
     _Self tmp = *this; ++*this; return tmp; 
   }
-  
-  inline _Self& operator--() { --It; return *this; }  // Predecrement
-  inline _Self operator--(int) { // Postdecrement
-    _Self tmp = *this; --*this; return tmp;
-  }
 };
 
 typedef PredIterator<BasicBlock, Value::use_iterator> pred_iterator;






More information about the llvm-commits mailing list