From e040f9706697b786a1288971b6d5ab96107bb799 Mon Sep 17 00:00:00 2001
From: Chris Lattner <sabre@nondot.org>
Date: Thu, 13 Feb 2003 05:07:53 +0000
Subject: [PATCH] Remove gunk that was supposed to make space evaluation more
 precise, but never worked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5549 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Support/Timer.cpp         | 65 +----------------------------------
 support/lib/Support/Timer.cpp | 65 +----------------------------------
 2 files changed, 2 insertions(+), 128 deletions(-)

diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index 96d92f97191..e03c3121d94 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -23,12 +23,6 @@ namespace {
              cl::Hidden);
 }
 
-// getNumBytesToNotCount - This function is supposed to return the number of
-// bytes that are to be considered not allocated, even though malloc thinks they
-// are allocated.
-//
-static unsigned getNumBytesToNotCount();
-
 static TimerGroup *DefaultTimerGroup = 0;
 static TimerGroup *getDefaultTimerGroup() {
   if (DefaultTimerGroup) return DefaultTimerGroup;
@@ -75,7 +69,7 @@ Timer::~Timer() {
 static long getMemUsage() {
   if (TrackSpace) {
     struct mallinfo MI = mallinfo();
-    return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+    return MI.uordblks/*+MI.hblkhd*/;
   } else {
     return 0;
   }
@@ -257,60 +251,3 @@ void TimerGroup::removeTimer() {
     DefaultTimerGroup = 0;
   }
 }
-
-
-
-#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2) && (__GNUC_PATCHLEVEL__ == 0)
-// If we have GCC 3.2.0, we can calculate pool allocation bookkeeping info
-#define HAVE_POOL
-extern "C" {
-  // Taken from GCC 3.2's stl_alloc.h file:
-  enum {_ALIGN = 8, _MAX_BYTES = 128, NFREE = _MAX_BYTES / _ALIGN};
-  struct FreeList { FreeList *Next; };
-
-  FreeList *_ZNSt24__default_alloc_templateILb1ELi0EE12_S_free_listE[NFREE];
-  char *_ZNSt24__default_alloc_templateILb1ELi0EE13_S_start_freeE;
-  char *_ZNSt24__default_alloc_templateILb1ELi0EE11_S_end_freeE;
-  size_t _ZNSt24__default_alloc_templateILb1ELi0EE12_S_heap_sizeE;
-  
-  // Make the symbols possible to use...
-  FreeList* (&TheFreeList)[NFREE] = _ZNSt24__default_alloc_templateILb1ELi0EE12_S_free_listE;
-  char * &StartFree = _ZNSt24__default_alloc_templateILb1ELi0EE13_S_start_freeE;
-  char * &EndFree   = _ZNSt24__default_alloc_templateILb1ELi0EE11_S_end_freeE;
-  size_t &HeapSize  = _ZNSt24__default_alloc_templateILb1ELi0EE12_S_heap_sizeE;
-}
-#endif
-
-// getNumBytesToNotCount - This function is supposed to return the number of
-// bytes that are to be considered not allocated, even though malloc thinks they
-// are allocated.
-//
-static unsigned getNumBytesToNotCount() {
-#ifdef HAVE_POOL
-  // If we have GCC 3.2.0, we can subtract off pool allocation bookkeeping info
-
-  // Size of the free slab section... 
-  unsigned FreePoolMem = (unsigned)(EndFree-StartFree);
-
-  // Walk all of the free lists, adding memory to the free counter whenever we
-  // have a free bucket.
-  for (unsigned i = 0; i != NFREE; ++i) {
-    unsigned NumEntries = 0;
-    for (FreeList *FL = TheFreeList[i]; FL; ++NumEntries, FL = FL->Next)
-      /*empty*/ ;
-    
-#if 0
-    if (NumEntries)
-      std::cerr << "  For Size[" << (i+1)*_ALIGN << "]: " << NumEntries
-                << " Free entries\n";
-#endif
-    FreePoolMem += NumEntries*(i+1)*_ALIGN;
-  }
-  return FreePoolMem;
-  
-#else
-#warning "Don't know how to avoid pool allocation accounting overhead for this"
-#warning " compiler: Space usage numbers (with -time-passes) may be off!"
-  return 0;
-#endif
-}
diff --git a/support/lib/Support/Timer.cpp b/support/lib/Support/Timer.cpp
index 96d92f97191..e03c3121d94 100644
--- a/support/lib/Support/Timer.cpp
+++ b/support/lib/Support/Timer.cpp
@@ -23,12 +23,6 @@ namespace {
              cl::Hidden);
 }
 
-// getNumBytesToNotCount - This function is supposed to return the number of
-// bytes that are to be considered not allocated, even though malloc thinks they
-// are allocated.
-//
-static unsigned getNumBytesToNotCount();
-
 static TimerGroup *DefaultTimerGroup = 0;
 static TimerGroup *getDefaultTimerGroup() {
   if (DefaultTimerGroup) return DefaultTimerGroup;
@@ -75,7 +69,7 @@ Timer::~Timer() {
 static long getMemUsage() {
   if (TrackSpace) {
     struct mallinfo MI = mallinfo();
-    return MI.uordblks/*+MI.hblkhd-getNumBytesToNotCount()*/;
+    return MI.uordblks/*+MI.hblkhd*/;
   } else {
     return 0;
   }
@@ -257,60 +251,3 @@ void TimerGroup::removeTimer() {
     DefaultTimerGroup = 0;
   }
 }
-
-
-
-#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2) && (__GNUC_PATCHLEVEL__ == 0)
-// If we have GCC 3.2.0, we can calculate pool allocation bookkeeping info
-#define HAVE_POOL
-extern "C" {
-  // Taken from GCC 3.2's stl_alloc.h file:
-  enum {_ALIGN = 8, _MAX_BYTES = 128, NFREE = _MAX_BYTES / _ALIGN};
-  struct FreeList { FreeList *Next; };
-
-  FreeList *_ZNSt24__default_alloc_templateILb1ELi0EE12_S_free_listE[NFREE];
-  char *_ZNSt24__default_alloc_templateILb1ELi0EE13_S_start_freeE;
-  char *_ZNSt24__default_alloc_templateILb1ELi0EE11_S_end_freeE;
-  size_t _ZNSt24__default_alloc_templateILb1ELi0EE12_S_heap_sizeE;
-  
-  // Make the symbols possible to use...
-  FreeList* (&TheFreeList)[NFREE] = _ZNSt24__default_alloc_templateILb1ELi0EE12_S_free_listE;
-  char * &StartFree = _ZNSt24__default_alloc_templateILb1ELi0EE13_S_start_freeE;
-  char * &EndFree   = _ZNSt24__default_alloc_templateILb1ELi0EE11_S_end_freeE;
-  size_t &HeapSize  = _ZNSt24__default_alloc_templateILb1ELi0EE12_S_heap_sizeE;
-}
-#endif
-
-// getNumBytesToNotCount - This function is supposed to return the number of
-// bytes that are to be considered not allocated, even though malloc thinks they
-// are allocated.
-//
-static unsigned getNumBytesToNotCount() {
-#ifdef HAVE_POOL
-  // If we have GCC 3.2.0, we can subtract off pool allocation bookkeeping info
-
-  // Size of the free slab section... 
-  unsigned FreePoolMem = (unsigned)(EndFree-StartFree);
-
-  // Walk all of the free lists, adding memory to the free counter whenever we
-  // have a free bucket.
-  for (unsigned i = 0; i != NFREE; ++i) {
-    unsigned NumEntries = 0;
-    for (FreeList *FL = TheFreeList[i]; FL; ++NumEntries, FL = FL->Next)
-      /*empty*/ ;
-    
-#if 0
-    if (NumEntries)
-      std::cerr << "  For Size[" << (i+1)*_ALIGN << "]: " << NumEntries
-                << " Free entries\n";
-#endif
-    FreePoolMem += NumEntries*(i+1)*_ALIGN;
-  }
-  return FreePoolMem;
-  
-#else
-#warning "Don't know how to avoid pool allocation accounting overhead for this"
-#warning " compiler: Space usage numbers (with -time-passes) may be off!"
-  return 0;
-#endif
-}