[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h

Chris Lattner sabre at nondot.org
Fri Feb 9 20:36:26 PST 2007



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.cpp updated: 1.91 -> 1.92
SlotCalculator.h updated: 1.34 -> 1.35
---
Log message:

ModuleContainsAllFunctionConstants is always true


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

 SlotCalculator.cpp |   44 ++++++++++----------------------------------
 SlotCalculator.h   |    5 -----
 2 files changed, 10 insertions(+), 39 deletions(-)


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.91 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.92
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.91	Fri Feb  9 22:31:52 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Fri Feb  9 22:36:10 2007
@@ -24,7 +24,6 @@
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/Type.h"
 #include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/ConstantsScanner.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/STLExtras.h"
 #include <algorithm>
@@ -65,7 +64,6 @@
 }
 
 SlotCalculator::SlotCalculator(const Module *M ) {
-  ModuleContainsAllFunctionConstants = false;
   ModuleTypeLevel = 0;
   TheModule = M;
 
@@ -76,7 +74,6 @@
 }
 
 SlotCalculator::SlotCalculator(const Function *M ) {
-  ModuleContainsAllFunctionConstants = false;
   TheModule = M ? M->getParent() : 0;
 
   insertPrimitives();
@@ -142,27 +139,20 @@
   }
 
   // Scan all of the functions for their constants, which allows us to emit
-  // more compact modules.  This is optional, and is just used to compactify
-  // the constants used by different functions together.
-  //
-  // This functionality tends to produce smaller bytecode files.  This should
-  // not be used in the future by clients that want to, for example, build and
-  // emit functions on the fly.  For now, however, it is unconditionally
-  // enabled.
-  ModuleContainsAllFunctionConstants = true;
-
+  // more compact modules.
   SC_DEBUG("Inserting function constants:\n");
   for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
        F != E; ++F) {
-    for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
-      for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); 
-           OI != E; ++OI) {
-        if ((isa<Constant>(*OI) && !isa<GlobalValue>(*OI)) ||
-            isa<InlineAsm>(*OI))
-          getOrCreateSlot(*OI);
+    for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
+      for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
+        for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); 
+             OI != E; ++OI) {
+          if ((isa<Constant>(*OI) && !isa<GlobalValue>(*OI)) ||
+              isa<InlineAsm>(*OI))
+            getOrCreateSlot(*OI);
+        }
+        getOrCreateTypeSlot(I->getType());
       }
-      getOrCreateTypeSlot(I->getType());
-    }
   }
 
   // Insert constants that are named at module level into the slot pool so that
@@ -241,20 +231,6 @@
       I != E; ++I)
     getOrCreateSlot(I);
 
-  if (!ModuleContainsAllFunctionConstants) {
-    // Iterate over all of the instructions in the function, looking for
-    // constant values that are referenced.  Add these to the value pools
-    // before any nonconstant values.  This will be turned into the constant
-    // pool for the bytecode writer.
-    //
-
-    // Emit all of the constants that are being used by the instructions in
-    // the function...
-    for (constant_iterator CI = constant_begin(F), CE = constant_end(F);
-         CI != CE; ++CI)
-      getOrCreateSlot(*CI);
-  }
-
   SC_DEBUG("Inserting Instructions:\n");
 
   // Add all of the instructions to the type planes...


Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.34 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.35
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.34	Fri Feb  9 22:29:03 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h	Fri Feb  9 22:36:10 2007
@@ -57,11 +57,6 @@
   std::vector<unsigned> ModuleLevel;
   unsigned ModuleTypeLevel;
 
-  /// ModuleContainsAllFunctionConstants - This flag is set to true if all
-  /// function constants are incorporated into the module constant table.  This
-  /// is only possible if building information for a bytecode file.
-  bool ModuleContainsAllFunctionConstants;
-
   SlotCalculator(const SlotCalculator &);  // DO NOT IMPLEMENT
   void operator=(const SlotCalculator &);  // DO NOT IMPLEMENT
 public:






More information about the llvm-commits mailing list