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

Chris Lattner sabre at nondot.org
Sun Apr 8 20:37:53 PDT 2007



Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.169 -> 1.170
---
Log message:

Fix a bug that caused alignment information to occasionally get stripped off
of an allocation instruction when writing to bytecode.


---
Diffs of the changes:  (+11 -2)

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


Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.169 llvm/lib/Bytecode/Writer/Writer.cpp:1.170
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.169	Tue Feb 27 20:25:20 2007
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Sun Apr  8 22:37:36 2007
@@ -429,8 +429,14 @@
   output_typeid(Type);                      // Result type
 
   unsigned NumArgs = I->getNumOperands();
-  output_vbr(NumArgs + (isa<CastInst>(I)  || isa<InvokeInst>(I) || 
-                        isa<CmpInst>(I) || isa<VAArgInst>(I) || Opcode == 58));
+  bool HasExtraArg = false;
+  if (isa<CastInst>(I)  || isa<InvokeInst>(I) || 
+      isa<CmpInst>(I) || isa<VAArgInst>(I) || Opcode == 58)
+    HasExtraArg = true;
+  if (const AllocationInst *AI = dyn_cast<AllocationInst>(I))
+    HasExtraArg = AI->getAlignment() != 0;
+  
+  output_vbr(NumArgs + HasExtraArg);
 
   if (!isa<GetElementPtrInst>(&I)) {
     for (unsigned i = 0; i < NumArgs; ++i)
@@ -445,6 +451,9 @@
     } else if (Opcode == 58) {  // Call escape sequence
       output_vbr((cast<CallInst>(I)->getCallingConv() << 1) |
                  unsigned(cast<CallInst>(I)->isTailCall()));
+    } else if (const AllocationInst *AI = dyn_cast<AllocationInst>(I)) {
+      if (AI->getAlignment())
+        output_vbr((unsigned)Log2_32(AI->getAlignment())+1);
     }
   } else {
     output_vbr(Table.getSlot(I->getOperand(0)));






More information about the llvm-commits mailing list