diff options
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 20 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h | 32 |
2 files changed, 14 insertions, 38 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index a37201e8f4..1646fc8b35 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -815,17 +815,10 @@ bool NaClBitcodeReader::ParseModule(bool Resume) { case naclbitc::MODULE_CODE_VERSION: { // VERSION: [version#] if (Record.size() < 1) return Error("Malformed MODULE_CODE_VERSION"); - // Only version #0 and #1 are supported so far. + // Only version #1 is supported for PNaCl. Version #0 is not supported. unsigned module_version = Record[0]; - switch (module_version) { - default: return Error("Unknown bitstream version!"); - case 0: - UseRelativeIDs = false; - break; - case 1: - UseRelativeIDs = true; - break; - } + if (module_version != 1) + return Error("Unknown bitstream version!"); break; } // FUNCTION: [type, callingconv, isproto, linkage] @@ -1286,13 +1279,10 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) { for (unsigned i = 0, e = Record.size()-1; i != e; i += 2) { Value *V; - // With the new function encoding, it is possible that operands have + // With relative value IDs, it is possible that operands have // negative IDs (for forward references). Use a signed VBR // representation to keep the encoding small. - if (UseRelativeIDs) - V = getValueSigned(Record, 1+i, NextValueNo); - else - V = getValue(Record, 1+i, NextValueNo); + V = getValueSigned(Record, 1+i, NextValueNo); unsigned BBIndex = Record[2+i]; BasicBlock *BB = getBasicBlock(BBIndex); if (!V || !BB) return Error("Invalid PHI record"); diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h index b6cf9fab80..2e2816f0f1 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h @@ -188,15 +188,6 @@ class NaClBitcodeReader : public GVMaterializer { /// stream. DenseMap<Function*, uint64_t> DeferredFunctionInfo; - /// UseRelativeIDs - Indicates that we are using a new encoding for - /// instruction operands where most operands in the current - /// FUNCTION_BLOCK are encoded relative to the instruction number, - /// for a more compact encoding. Some instruction operands are not - /// relative to the instruction ID: basic block numbers, and types. - /// Once the old style function blocks have been phased out, we would - /// not need this flag. - bool UseRelativeIDs; - /// \brief True if we should only accept supported bitcode format. bool AcceptSupportedBitcodeOnly; @@ -209,7 +200,7 @@ public: : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), LazyStreamer(0), NextUnreadBit(0), SeenValueSymbolTable(false), ValueList(C), - SeenFirstFunctionBody(false), UseRelativeIDs(false), + SeenFirstFunctionBody(false), AcceptSupportedBitcodeOnly(AcceptSupportedOnly), IntPtrType(IntegerType::get(C, PNaClIntPtrTypeBitSize)) { } @@ -218,7 +209,7 @@ public: : Context(C), TheModule(0), Buffer(0), BufferOwned(false), LazyStreamer(streamer), NextUnreadBit(0), SeenValueSymbolTable(false), ValueList(C), - SeenFirstFunctionBody(false), UseRelativeIDs(false), + SeenFirstFunctionBody(false), AcceptSupportedBitcodeOnly(AcceptSupportedOnly), IntPtrType(IntegerType::get(C, PNaClIntPtrTypeBitSize)) { } @@ -274,10 +265,8 @@ private: bool popValue(const SmallVector<uint64_t, 64> &Record, unsigned *Slot, unsigned InstNum, Value **ResVal) { if (*Slot == Record.size()) return true; - unsigned ValNo = (unsigned)Record[(*Slot)++]; - // Adjust the ValNo, if it was encoded relative to the InstNum. - if (UseRelativeIDs) - ValNo = InstNum - ValNo; + // ValNo is encoded relative to the InstNum. + unsigned ValNo = InstNum - (unsigned)Record[(*Slot)++]; *ResVal = getFnValueByID(ValNo); return *ResVal == 0; } @@ -287,10 +276,8 @@ private: Value *getValue(const SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum) { if (Slot == Record.size()) return 0; - unsigned ValNo = (unsigned)Record[Slot]; - // Adjust the ValNo, if it was encoded relative to the InstNum. - if (UseRelativeIDs) - ValNo = InstNum - ValNo; + // ValNo is encoded relative to the InstNum. + unsigned ValNo = InstNum - (unsigned)Record[Slot]; return getFnValueByID(ValNo); } @@ -298,10 +285,9 @@ private: Value *getValueSigned(const SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum) { if (Slot == Record.size()) return 0; - unsigned ValNo = (unsigned) NaClDecodeSignRotatedValue(Record[Slot]); - // Adjust the ValNo, if it was encoded relative to the InstNum. - if (UseRelativeIDs) - ValNo = InstNum - ValNo; + // ValNo is encoded relative to the InstNum. + unsigned ValNo = InstNum - + (unsigned) NaClDecodeSignRotatedValue(Record[Slot]); return getFnValueByID(ValNo); } |