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

Anton Korobeynikov asl at math.spbu.ru
Sat Apr 28 06:45:51 PDT 2007



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.cpp updated: 1.112 -> 1.113
Writer.cpp updated: 1.177 -> 1.178
---
Log message:

Implement review feedback. Aliasees can be either GlobalValue's or 
bitcasts of them.


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

 SlotCalculator.cpp |   13 +++++++++++++
 Writer.cpp         |   11 ++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.112 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.113
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.112	Mon Apr  9 01:14:31 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Sat Apr 28 08:44:59 2007
@@ -89,6 +89,12 @@
        I != E; ++I)
     CreateSlotIfNeeded(I);
 
+  // Add all of the global aliases to the value table...
+  //
+  for (Module::const_alias_iterator I = TheModule->alias_begin(),
+         E = TheModule->alias_end(); I != E; ++I)
+    CreateSlotIfNeeded(I);
+
   // Add all of the module level constants used as initializers
   //
   for (Module::const_global_iterator I = TheModule->global_begin(),
@@ -96,6 +102,13 @@
     if (I->hasInitializer())
       CreateSlotIfNeeded(I->getInitializer());
 
+  // Add all of the module level constants used as aliasees
+  //
+  for (Module::const_alias_iterator I = TheModule->alias_begin(),
+         E = TheModule->alias_end(); I != E; ++I)
+    if (I->getAliasee())
+      CreateSlotIfNeeded(I->getAliasee());
+
   // Now that all global constants have been added, rearrange constant planes
   // that contain constant strings so that the strings occur at the start of the
   // plane, not somewhere in the middle.


Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.177 llvm/lib/Bytecode/Writer/Writer.cpp:1.178
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.177	Wed Apr 25 09:27:10 2007
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Sat Apr 28 08:44:59 2007
@@ -1095,9 +1095,11 @@
   // Output aliases
   for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
        I != E; ++I) {
-    unsigned Slot = Table.getTypeSlot(I->getType());
-    assert(((Slot << 2) >> 2) == Slot && "Slot # too big!");
+    unsigned TypeSlotNo    = Table.getTypeSlot(I->getType());
+    unsigned AliaseeSlotNo = Table.getSlot(I->getAliasee());
+    assert(((TypeSlotNo << 3) >> 3) == TypeSlotNo && "Slot # too big!");
     unsigned aliasLinkage = 0;
+    unsigned isConstantAliasee = ((!isa<GlobalValue>(I->getAliasee())) << 2);
     switch (I->getLinkage()) {
      case GlobalValue::ExternalLinkage:
       aliasLinkage = 0;
@@ -1111,9 +1113,8 @@
      default:
       assert(0 && "Invalid alias linkage");
     }    
-    output_vbr((Slot << 2) | aliasLinkage);
-    output_vbr(Table.getTypeSlot(I->getAliasee()->getType()));
-    output_vbr(Table.getSlot(I->getAliasee()));
+    output_vbr((TypeSlotNo << 3) | isConstantAliasee | aliasLinkage);
+    output_vbr(AliaseeSlotNo);
   }
   output_typeid(Table.getTypeSlot(Type::VoidTy));
 }






More information about the llvm-commits mailing list