Packed Structures
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32361 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 3cc3b1d..2ac92bc 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -1192,7 +1192,18 @@
Typ = read_vbr_uint();
}
- Result = StructType::get(Elements);
+ Result = StructType::get(Elements, false);
+ break;
+ }
+ case Type::BC_ONLY_PackedStructTyID: {
+ std::vector<const Type*> Elements;
+ unsigned Typ = read_vbr_uint();
+ while (Typ) { // List is terminated by void/0 typeid
+ Elements.push_back(getType(Typ));
+ Typ = read_vbr_uint();
+ }
+
+ Result = StructType::get(Elements, true);
break;
}
case Type::PointerTyID: {
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index b69c1ad..c6bc22e 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -197,7 +197,11 @@
//===----------------------------------------------------------------------===//
void BytecodeWriter::outputType(const Type *T) {
- output_vbr((unsigned)T->getTypeID());
+ const StructType* STy = dyn_cast<StructType>(T);
+ if(STy && STy->isPacked())
+ output_vbr((unsigned)Type::BC_ONLY_PackedStructTyID);
+ else
+ output_vbr((unsigned)T->getTypeID());
// That's all there is to handling primitive types...
if (T->isPrimitiveType()) {
@@ -246,10 +250,8 @@
break;
}
-
case Type::StructTyID: {
const StructType *ST = cast<StructType>(T);
-
// Output all of the element types...
for (StructType::element_iterator I = ST->element_begin(),
E = ST->element_end(); I != E; ++I) {