diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 4 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 29 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp | 9 |
3 files changed, 15 insertions, 27 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index aac03678d1..1e524db3de 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -489,6 +489,10 @@ bool NaClBitcodeReader::ParseTypeTableBody() { break; } case naclbitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N] + // Deprecated. Only exists in early PNaCl version 1 bitcode files. + // TODO(kschimpf) Remove this as soon as is feasible. + if (GetPNaClVersion() >= 2) + return Error("Struct types not supported in PNaCl bitcode"); if (Record.size() < 1) return Error("Invalid STRUCT type record"); SmallVector<Type*, 8> EltTys; diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index 4a6a454796..3d5d50cc20 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -94,7 +94,6 @@ enum { // TYPE_BLOCK_ID_NEW abbrev id's. TYPE_POINTER_ABBREV = naclbitc::FIRST_APPLICATION_ABBREV, TYPE_FUNCTION_ABBREV, - TYPE_STRUCT_ANON_ABBREV, TYPE_ARRAY_ABBREV, TYPE_MAX_ABBREV = TYPE_ARRAY_ABBREV }; @@ -201,15 +200,6 @@ static void WriteTypeTable(const NaClValueEnumerator &VE, if (TYPE_FUNCTION_ABBREV != Stream.EmitAbbrev(Abbv)) llvm_unreachable("Unexpected abbrev ordering!"); - // Abbrev for TYPE_CODE_STRUCT_ANON. - Abbv = new NaClBitCodeAbbrev(); - Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_ANON)); - Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // ispacked - Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); - Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); - if (TYPE_STRUCT_ANON_ABBREV != Stream.EmitAbbrev(Abbv)) - llvm_unreachable("Unexpected abbrev ordering!"); - // Abbrev for TYPE_CODE_ARRAY. Abbv = new NaClBitCodeAbbrev(); Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_ARRAY)); @@ -261,23 +251,8 @@ static void WriteTypeTable(const NaClValueEnumerator &VE, AbbrevToUse = TYPE_FUNCTION_ABBREV; break; } - case Type::StructTyID: { - StructType *ST = cast<StructType>(T); - // STRUCT: [ispacked, eltty x N] - TypeVals.push_back(ST->isPacked()); - // Output all of the element types. - for (StructType::element_iterator I = ST->element_begin(), - E = ST->element_end(); I != E; ++I) - TypeVals.push_back(VE.getTypeID(*I)); - - if (ST->isLiteral()) { - Code = naclbitc::TYPE_CODE_STRUCT_ANON; - AbbrevToUse = TYPE_STRUCT_ANON_ABBREV; - } else { - report_fatal_error("Non-anon structs not supported in PNaCl bitcode"); - } - break; - } + case Type::StructTyID: + report_fatal_error("Struct types are not supported in PNaCl bitcode"); case Type::ArrayTyID: { ArrayType *AT = cast<ArrayType>(T); // ARRAY: [numelts, eltty] diff --git a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp index 5dbc525eec..be31779a3a 100644 --- a/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp @@ -90,6 +90,10 @@ NaClValueEnumerator::NaClValueEnumerator(const Module *M, uint32_t PNaClVersion) for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){ + // Don't generate types for elided pointer casts! + if (IsElidedCast(I)) + continue; + for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) { EnumerateOperandType(*OI); @@ -357,6 +361,11 @@ void NaClValueEnumerator::EnumerateType(Type *Ty, bool InsideOptimizeTypes) { // Enumerate the types for the specified value. If the value is a constant, // walk through it, enumerating the types of the constant. void NaClValueEnumerator::EnumerateOperandType(const Value *V) { + // Note: We intentionally don't create a type id for global variables, + // since the type is automatically generated by the reader before any + // use of the global variable. + if (isa<GlobalVariable>(V)) return; + EnumerateType(V->getType()); if (const Constant *C = dyn_cast<Constant>(V)) { |