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

Chris Lattner lattner at cs.uiuc.edu
Sat Nov 5 14:08:26 PST 2005



Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.168 -> 1.169
---
Log message:

Write/read allocation instruction alignment info to .bc files.


---
Diffs of the changes:  (+14 -8)

 Reader.cpp |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.168 llvm/lib/Bytecode/Reader/Reader.cpp:1.169
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.168	Sat Oct 22 23:37:20 2005
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Sat Nov  5 16:08:14 2005
@@ -902,27 +902,33 @@
     if (CallingConv) cast<InvokeInst>(Result)->setCallingConv(CallingConv);
     break;
   }
-  case Instruction::Malloc:
-    if (Oprnds.size() > 2)
+  case Instruction::Malloc: {
+    unsigned Align = 0;
+    if (Oprnds.size() == 2)
+      Align = (1 << Oprnds[1]) >> 1;
+    else if (Oprnds.size() > 2)
       error("Invalid malloc instruction!");
     if (!isa<PointerType>(InstTy))
       error("Invalid malloc instruction!");
 
     Result = new MallocInst(cast<PointerType>(InstTy)->getElementType(),
-                            Oprnds.size() ? getValue(Type::UIntTyID,
-                                                   Oprnds[0]) : 0);
+                            getValue(Type::UIntTyID, Oprnds[0]), Align);
     break;
+  }
 
-  case Instruction::Alloca:
-    if (Oprnds.size() > 2)
+  case Instruction::Alloca: {
+    unsigned Align = 0;
+    if (Oprnds.size() == 2)
+      Align = (1 << Oprnds[1]) >> 1;
+    else if (Oprnds.size() > 2)
       error("Invalid alloca instruction!");
     if (!isa<PointerType>(InstTy))
       error("Invalid alloca instruction!");
 
     Result = new AllocaInst(cast<PointerType>(InstTy)->getElementType(),
-                            Oprnds.size() ? getValue(Type::UIntTyID,
-                            Oprnds[0]) :0);
+                            getValue(Type::UIntTyID, Oprnds[0]), Align);
     break;
+  }
   case Instruction::Free:
     if (!isa<PointerType>(InstTy))
       error("Invalid free instruction!");






More information about the llvm-commits mailing list