aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h4
-rw-r--r--lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp36
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp47
-rw-r--r--test/NaCl/Bitcode/struct-types.ll79
4 files changed, 3 insertions, 163 deletions
diff --git a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
index dcb3df3473..b9c358f271 100644
--- a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
+++ b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
@@ -106,8 +106,8 @@ namespace naclbitc {
TYPE_CODE_X86_MMX = 17, // Not used in PNaCl.
TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
- TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
- TYPE_CODE_STRUCT_NAMED = 20,// STRUCT_NAMED: [ispacked, eltty x N]
+ TYPE_CODE_STRUCT_NAME = 19, // Not used in PNaCl.
+ TYPE_CODE_STRUCT_NAMED = 20,// Not used in PNaCl.
TYPE_CODE_FUNCTION = 21 // FUNCTION: [vararg, retty, paramty x N]
};
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
index 0eaab6d78b..9e8c398172 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
@@ -402,8 +402,6 @@ bool NaClBitcodeReader::ParseTypeTableBody() {
SmallVector<uint64_t, 64> Record;
unsigned NumRecords = 0;
- SmallString<64> TypeName;
-
// Read all the records for this type table.
while (1) {
NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks();
@@ -505,40 +503,6 @@ bool NaClBitcodeReader::ParseTypeTableBody() {
ResultTy = StructType::get(Context, EltTys, Record[0]);
break;
}
- case naclbitc::TYPE_CODE_STRUCT_NAME: // STRUCT_NAME: [strchr x N]
- if (ConvertToString(Record, 0, TypeName))
- return Error("Invalid STRUCT_NAME record");
- continue;
-
- case naclbitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N]
- if (Record.size() < 1)
- return Error("Invalid STRUCT type record");
-
- if (NumRecords >= TypeList.size())
- return Error("invalid TYPE table");
-
- // Check to see if this was forward referenced, if so fill in the temp.
- StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
- if (Res) {
- Res->setName(TypeName);
- TypeList[NumRecords] = 0;
- } else // Otherwise, create a new struct.
- Res = StructType::create(Context, TypeName);
- TypeName.clear();
-
- SmallVector<Type*, 8> EltTys;
- for (unsigned i = 1, e = Record.size(); i != e; ++i) {
- if (Type *T = getTypeByID(Record[i]))
- EltTys.push_back(T);
- else
- break;
- }
- if (EltTys.size() != Record.size()-1)
- return Error("invalid STRUCT type record");
- Res->setBody(EltTys, Record[0]);
- ResultTy = Res;
- break;
- }
case naclbitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid ARRAY type record");
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
index d4f7c51749..41a2501266 100644
--- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
@@ -95,8 +95,6 @@ enum {
TYPE_POINTER_ABBREV = naclbitc::FIRST_APPLICATION_ABBREV,
TYPE_FUNCTION_ABBREV,
TYPE_STRUCT_ANON_ABBREV,
- TYPE_STRUCT_NAME_ABBREV,
- TYPE_STRUCT_NAMED_ABBREV,
TYPE_ARRAY_ABBREV,
TYPE_MAX_ABBREV = TYPE_ARRAY_ABBREV
};
@@ -163,22 +161,6 @@ static unsigned GetEncodedCallingConv(CallingConv::ID conv) {
}
}
-static void WriteStringRecord(unsigned Code, StringRef Str,
- unsigned AbbrevToUse,
- NaClBitstreamWriter &Stream) {
- SmallVector<unsigned, 64> Vals;
-
- // Code: [strchar x N]
- for (unsigned i = 0, e = Str.size(); i != e; ++i) {
- if (AbbrevToUse && !NaClBitCodeAbbrevOp::isChar6(Str[i]))
- AbbrevToUse = 0;
- Vals.push_back(Str[i]);
- }
-
- // Emit the finished record.
- Stream.EmitRecord(Code, Vals, AbbrevToUse);
-}
-
/// WriteTypeTable - Write out the type table for a module.
static void WriteTypeTable(const NaClValueEnumerator &VE,
NaClBitstreamWriter &Stream) {
@@ -228,23 +210,6 @@ static void WriteTypeTable(const NaClValueEnumerator &VE,
if (TYPE_STRUCT_ANON_ABBREV != Stream.EmitAbbrev(Abbv))
llvm_unreachable("Unexpected abbrev ordering!");
- // Abbrev for TYPE_CODE_STRUCT_NAME.
- Abbv = new NaClBitCodeAbbrev();
- Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAME));
- Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array));
- Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Char6));
- if (TYPE_STRUCT_NAME_ABBREV != Stream.EmitAbbrev(Abbv))
- llvm_unreachable("Unexpected abbrev ordering!");
-
- // Abbrev for TYPE_CODE_STRUCT_NAMED.
- Abbv = new NaClBitCodeAbbrev();
- Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAMED));
- Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // ispacked
- Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array));
- Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits));
- if (TYPE_STRUCT_NAMED_ABBREV != Stream.EmitAbbrev(Abbv))
- llvm_unreachable("Unexpected abbrev ordering!");
-
// Abbrev for TYPE_CODE_ARRAY.
Abbv = new NaClBitCodeAbbrev();
Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_ARRAY));
@@ -309,17 +274,7 @@ static void WriteTypeTable(const NaClValueEnumerator &VE,
Code = naclbitc::TYPE_CODE_STRUCT_ANON;
AbbrevToUse = TYPE_STRUCT_ANON_ABBREV;
} else {
- if (ST->isOpaque()) {
- report_fatal_error("Opaque structs not supported in PNaCl bitcode");
- } else {
- Code = naclbitc::TYPE_CODE_STRUCT_NAMED;
- AbbrevToUse = TYPE_STRUCT_NAMED_ABBREV;
- }
-
- // Emit the name if it is present.
- if (!ST->getName().empty())
- WriteStringRecord(naclbitc::TYPE_CODE_STRUCT_NAME, ST->getName(),
- TYPE_STRUCT_NAME_ABBREV, Stream);
+ report_fatal_error("Non-anon structs not supported in PNaCl bitcode");
}
break;
}
diff --git a/test/NaCl/Bitcode/struct-types.ll b/test/NaCl/Bitcode/struct-types.ll
deleted file mode 100644
index b2f7dc62a8..0000000000
--- a/test/NaCl/Bitcode/struct-types.ll
+++ /dev/null
@@ -1,79 +0,0 @@
-; Checks if llvm bitcode defines a struct type before the pointer type,
-; even if the struct definintion appears after the pointer type, while
-; pnacl bitcode moves the pointer before the struct.
-; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=LLVM
-; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \
-; RUN: | FileCheck %s -check-prefix=PNACL
-
-%typeB = type { i8, %typeA, i32, %typeA }
-%typeA = type { i16 }
-
-define %typeB* @foo(%typeB* %a) {
- ret %typeB* %a
-}
-
-define %typeB* @bar(%typeB* %b) {
- ret %typeB* %b
-}
-
-define i16 @bam(i16 %a) {
- ret i16 %a
-}
-
-; Show the ordering llvm uses to order types, which is to expand subtypes
-; (including accross pointers) before the type. Expands types for functions
-; in order: @foo, @bar, @bam.
-; LLVM: <TYPE_BLOCK_ID {{.*}}>
-; i8
-; LLVM: <INTEGER op0=8/>
-; i16
-; LLVM: <INTEGER op0=16/>
-; %typeA = type { i16 }
-; LLVM: <STRUCT_NAME abbrevid=7 op0=116 op1=121 op2=112 op3=101 op4=65/>
-; LLVM: <STRUCT_NAMED abbrevid=8 op0=0 op1=1/>
-; i32
-; LLVM: <INTEGER op0=32/>
-; %typeB = type { i8, %typeA, i32, %typeA }
-; LLVM: <STRUCT_NAME abbrevid=7 op0=116 op1=121 op2=112 op3=101 op4=66/>
-; LLVM: <STRUCT_NAMED abbrevid=8 op0=0 op1=0 op2=2 op3=3 op4=2/>
-; %typeB*
-; LLVM: <POINTER abbrevid=4 op0=4 op1=0/>
-; %typeB* (%typeB*)
-; LLVM: <FUNCTION abbrevid=5 op0=0 op1=5 op2=5/>
-; %typeB* (%typeB*)*
-; LLVM: <POINTER abbrevid=4 op0=6 op1=0/>
-; i16 (i16)
-; LLVM: <FUNCTION abbrevid=5 op0=0 op1=1 op2=1/>
-; i16 (i16)*
-; LLVM: <POINTER abbrevid=4 op0=8 op1=0/>
-; type of instruction "RET"
-; LLVM: <VOID/>
-; LLVM: </TYPE_BLOCK_ID>
-
-; Show the ordering pnacl-freeze uses to order types.
-; PNACL: <TYPE_BLOCK_ID>
-; %typeB*
-; PNACL: <POINTER op0=8 op1=0/>
-; i16
-; PNACL: <INTEGER op0=16/>
-; type of instruction "RET"
-; PNACL: <VOID/>
-; %typeA = type { i16 }
-; PNACL: <STRUCT_NAME op0=116 op1=121 op2=112 op3=101 op4=65/>
-; PNACL: <STRUCT_NAMED op0=0 op1=1/>
-; %typeB* (%typeB*)
-; PNACL: <FUNCTION op0=0 op1=0 op2=0/>
-; %typeB* (%typeB*)*
-; PNACL: <POINTER op0=4 op1=0/>
-; i8
-; PNACL: <INTEGER op0=8/>
-; i32
-; PNACL: <INTEGER op0=32/>
-; %typeB = type { i8, %typeA, i32, %typeA }
-; PNACL: <STRUCT_NAME op0=116 op1=121 op2=112 op3=101 op4=66/>
-; PNACL: <STRUCT_NAMED op0=0 op1=6 op2=3 op3=7 op4=3/>
-; i16 (i16)
-; PNACL: <FUNCTION op0=0 op1=1 op2=1/>
-; i16 (i16)*
-; PNACL: <POINTER op0=9 op1=0/>
-; PNACL: </TYPE_BLOCK_ID>