[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Chris Lattner sabre at nondot.org
Tue Dec 5 22:15:58 PST 2006



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.223 -> 1.224
---
Log message:

The hasSlot methods are gone.
Remove the 'PrintName' argument to WriteAsOperand, as it is always true.
Only call getOrCreateSlot on things that are valid.


---
Diffs of the changes:  (+20 -25)

 AsmWriter.cpp |   45 ++++++++++++++++++++-------------------------
 1 files changed, 20 insertions(+), 25 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.223 llvm/lib/VMCore/AsmWriter.cpp:1.224
--- llvm/lib/VMCore/AsmWriter.cpp:1.223	Tue Dec  5 23:55:41 2006
+++ llvm/lib/VMCore/AsmWriter.cpp	Wed Dec  6 00:15:43 2006
@@ -79,10 +79,6 @@
   /// Its an error to ask for a Type*
   int getSlot(const Value *V);
 
-  /// Determine if a Value has a slot or not
-  bool hasSlot(const Value* V);
-  bool hasSlot(const Type* Ty);
-
 /// @}
 /// @name Mutators
 /// @{
@@ -622,8 +618,7 @@
 /// the whole instruction that generated it.
 ///
 std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V,
-                                   bool PrintType, bool PrintName,
-                                   const Module *Context) {
+                                   bool PrintType, const Module *Context) {
   std::map<const Type *, std::string> TypeNames;
   if (Context == 0) Context = getModuleFromVal(V);
 
@@ -633,7 +628,7 @@
   if (PrintType)
     printTypeInt(Out, V->getType(), TypeNames);
 
-  WriteAsOperandInternal(Out, V, PrintName, TypeNames, 0);
+  WriteAsOperandInternal(Out, V, true, TypeNames, 0);
   return Out;
 }
 
@@ -1437,15 +1432,17 @@
 void SlotMachine::processModule() {
   SC_DEBUG("begin processModule!\n");
 
-  // Add all of the global variables to the value table...
+  // Add all of the unnamed global variables to the value table.
   for (Module::const_global_iterator I = TheModule->global_begin(),
        E = TheModule->global_end(); I != E; ++I)
-    getOrCreateSlot(I);
+    if (!I->hasName()) 
+      getOrCreateSlot(I);
 
-  // Add all the functions to the table
+  // Add all the unnamed functions to the table.
   for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
        I != E; ++I)
-    getOrCreateSlot(I);
+    if (!I->hasName())
+      getOrCreateSlot(I);
 
   SC_DEBUG("end processModule!\n");
 }
@@ -1455,19 +1452,22 @@
 void SlotMachine::processFunction() {
   SC_DEBUG("begin processFunction!\n");
 
-  // Add all the function arguments
+  // Add all the function arguments with no names.
   for(Function::const_arg_iterator AI = TheFunction->arg_begin(),
       AE = TheFunction->arg_end(); AI != AE; ++AI)
-    getOrCreateSlot(AI);
+    if (!AI->hasName())
+      getOrCreateSlot(AI);
 
   SC_DEBUG("Inserting Instructions:\n");
 
-  // Add all of the basic blocks and instructions
+  // Add all of the basic blocks and instructions with no names.
   for (Function::const_iterator BB = TheFunction->begin(),
        E = TheFunction->end(); BB != E; ++BB) {
-    getOrCreateSlot(BB);
-    for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
-      getOrCreateSlot(I);
+    if (!BB->hasName())
+      getOrCreateSlot(BB);
+    for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+      if (I->getType() != Type::VoidTy && !I->hasName())
+        getOrCreateSlot(I);
   }
 
   FunctionProcessed = true;
@@ -1553,16 +1553,11 @@
 // inserted. Note that the logic here parallels getSlot but instead
 // of asserting when the Value* isn't found, it inserts the value.
 unsigned SlotMachine::getOrCreateSlot(const Value *V) {
-  assert(V && "Can't insert a null Value to SlotMachine");
+  const Type* VTy = V->getType();
+  assert(VTy != Type::VoidTy && !V->hasName() && "Doesn't need a slot!");
   assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
     "Can't insert a non-GlobalValue Constant into SlotMachine");
 
-  const Type* VTy = V->getType();
-
-  // Just ignore void typed things or things with names.
-  if (VTy == Type::VoidTy || V->hasName())
-    return 0; // FIXME: Wrong return value!
-
   // Look up the type plane for the Value's type from the module map
   TypedPlanes::const_iterator MI = mMap.find(VTy);
 
@@ -1618,7 +1613,7 @@
     }
   }
 
-  // N.B. Can only get here if !TheFunction
+  // N.B. Can only get here if TheFunction == 0
 
   // If the module map's type plane is not for the Value's type
   if (MI != mMap.end()) {






More information about the llvm-commits mailing list