[llvm-commits] [gcc-plugin] r83276 - /gcc-plugin/trunk/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Sun Oct 4 05:23:49 PDT 2009


Author: baldrick
Date: Sun Oct  4 07:23:48 2009
New Revision: 83276

URL: http://llvm.org/viewvc/llvm-project?rev=83276&view=rev
Log:
Don't bother running the garbage collector.  The original idea was that once
functions are converted to LLVM IR, they can be discarded.  This was done by
estimating the amount of memory that could be recovered, and running the garbage
collector if that seemed beneficial.  However even on huge testcases this never
saved more than a megabyte or three, while it increased compile time considerably.
In fact, if the garbage collector isn't run at all then gcc-4.5 with the plugin
uses up less memory than gcc-4.5 (presumably because RTL is fat), and about the
same or less than llvm-gcc (on insn-attrtab.c a bit more than 5% less).  Turning
off the garbage collector almost doubles -O0 compile times, making them about the
same as llvm-gcc.

Modified:
    gcc-plugin/trunk/llvm-backend.cpp

Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=83276&r1=83275&r2=83276&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Sun Oct  4 07:23:48 2009
@@ -94,12 +94,6 @@
 #include "llvm-cache.h"
 }
 
-// TODO: Space aliens beamed these numbers into my head.  Replace with something
-// more down-to-earth.
-#define ESTIMATED_MEMORY_PER_BASIC_BLOCK	1500
-#define ESTIMATED_MEMORY_PER_GIMPLE_STATEMENT	128
-#define MIN_BYTES_WORTH_GARBAGE_COLLECTING	(1024*1024)
-
 // Non-zero if bytecode from PCH is successfully read.
 int flag_llvm_pch_read;
 
@@ -162,30 +156,6 @@
   ++NumStatements;
 }
 
-static size_t LastNumBasicBlocks;
-static size_t LastNumStatements;
-
-/// EstimatedCollectableGCCMemory - Return an estimate of the amount of memory
-/// we think the GCC garbage collector would free if we ran it.
-static size_t EstimatedCollectableGCCMemory() {
-  return
-    (NumBasicBlocks - LastNumBasicBlocks) * ESTIMATED_MEMORY_PER_BASIC_BLOCK +
-    (NumStatements - LastNumStatements) * ESTIMATED_MEMORY_PER_GIMPLE_STATEMENT;
-}
-
-/// isWorthGarbageCollecting - Returns whether running the GCC garbage collector
-/// would free up enough memory to make it worthwhile.
-static bool isWorthGarbageCollecting() {
-  return EstimatedCollectableGCCMemory() > MIN_BYTES_WORTH_GARBAGE_COLLECTING;
-}
-
-/// ResetGarbageCollectionStatistics - The memory estimated by the previous
-/// statistics will be garbage collected.  Reset the statistics.
-static void ResetGarbageCollectionStatistics() {
-  LastNumBasicBlocks = NumBasicBlocks;
-  LastNumStatements = NumStatements;
-}
-
 
 //===----------------------------------------------------------------------===//
 //                   Matching LLVM Values with GCC DECL trees
@@ -1758,13 +1728,6 @@
 static unsigned int emit_function (void) {
   LazilyInitializeModule();
 
-  // The previously converted function is now garbage collectable.  If it seems
-  // worthwhile, run the garbage collector after converting this function (the
-  // current function will not itself be collected though).
-  ggc_force_collect = isWorthGarbageCollecting();
-  if (ggc_force_collect)
-    ResetGarbageCollectionStatistics();
-
 //TODO Don't want to use sorry at this stage...
 //TODO  if (cfun->nonlocal_goto_save_area)
 //TODO    sorry("%Jnon-local gotos not supported by LLVM", fndecl);
@@ -1851,15 +1814,6 @@
 
   LazilyInitializeModule();
 
-  // If it seems worthwhile, garbage collect any functions we converted before
-  // running the optimizers or generating code.
-  if (isWorthGarbageCollecting()) {
-    ResetGarbageCollectionStatistics();
-    ggc_force_collect = 1;
-    ggc_collect();
-    ggc_force_collect = 0;
-  }
-
 //TODO  timevar_push(TV_LLVM_PERFILE);
   LLVMContext &Context = getGlobalContext();
 





More information about the llvm-commits mailing list