diff options
-rw-r--r-- | include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h | 2 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 19 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 29 |
3 files changed, 14 insertions, 36 deletions
diff --git a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h index 8361a17642..3a19ee84ca 100644 --- a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h +++ b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h @@ -145,7 +145,7 @@ namespace naclbitc { CST_CODE_NULL = 2, // NULL CST_CODE_UNDEF = 3, // UNDEF CST_CODE_INTEGER = 4, // INTEGER: [intval] - CST_CODE_WIDE_INTEGER = 5, // WIDE_INTEGER: [n x intval] + CST_CODE_WIDE_INTEGER = 5, // Not used in PNaCl. CST_CODE_FLOAT = 6, // FLOAT: [fpval] CST_CODE_AGGREGATE = 7, // AGGREGATE: [n x value number] CST_CODE_STRING = 8, // Not used in PNaCl. diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 028e750d92..e0dfdc1889 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -832,8 +832,13 @@ bool NaClBitcodeReader::ParseConstants() { Value *V = 0; unsigned BitCode = Stream.readRecord(Entry.ID, Record); switch (BitCode) { - default: - return Error("Unknown Constant"); + default: { + std::string Message; + raw_string_ostream StrM(Message); + StrM << "Invalid Constant code: " << BitCode; + StrM.flush(); + return Error(Message); + } case naclbitc::CST_CODE_UNDEF: // UNDEF V = UndefValue::get(CurTy); break; @@ -852,16 +857,6 @@ bool NaClBitcodeReader::ParseConstants() { return Error("Invalid CST_INTEGER record"); V = ConstantInt::get(CurTy, NaClDecodeSignRotatedValue(Record[0])); break; - case naclbitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] - if (!CurTy->isIntegerTy() || Record.empty()) - return Error("Invalid WIDE_INTEGER record"); - - APInt VInt = ReadWideAPInt(Record, - cast<IntegerType>(CurTy)->getBitWidth()); - V = ConstantInt::get(Context, VInt); - - break; - } case naclbitc::CST_CODE_FLOAT: { // FLOAT: [fpval] if (Record.empty()) return Error("Invalid FLOAT record"); diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index 2ac88c92a4..31b7c1e917 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -560,30 +560,14 @@ static void emitSignedInt64(SmallVectorImpl<uint64_t> &Vals, uint64_t V) { } static void EmitAPInt(SmallVectorImpl<uint64_t> &Vals, - unsigned &Code, unsigned &AbbrevToUse, const APInt &Val, - bool EmitSizeForWideNumbers = false - ) { + unsigned &Code, unsigned &AbbrevToUse, const APInt &Val) { if (Val.getBitWidth() <= 64) { uint64_t V = Val.getSExtValue(); emitSignedInt64(Vals, V); Code = naclbitc::CST_CODE_INTEGER; AbbrevToUse = CONSTANTS_INTEGER_ABBREV; } else { - // Wide integers, > 64 bits in size. - // We have an arbitrary precision integer value to write whose - // bit width is > 64. However, in canonical unsigned integer - // format it is likely that the high bits are going to be zero. - // So, we only write the number of active words. - unsigned NWords = Val.getActiveWords(); - - if (EmitSizeForWideNumbers) - Vals.push_back(NWords); - - const uint64_t *RawWords = Val.getRawData(); - for (unsigned i = 0; i != NWords; ++i) { - emitSignedInt64(Vals, RawWords[i]); - } - Code = naclbitc::CST_CODE_WIDE_INTEGER; + report_fatal_error("Wide integers are not supported"); } } @@ -875,7 +859,7 @@ static bool WriteInstruction(const Instruction &I, unsigned InstID, if (CaseRanges.isSingleNumber()) { Vals64.push_back(1/*NumItems = 1*/); Vals64.push_back(true/*IsSingleNumber = true*/); - EmitAPInt(Vals64, Code, Abbrev, CaseRanges.getSingleNumber(0), true); + EmitAPInt(Vals64, Code, Abbrev, CaseRanges.getSingleNumber(0)); } else { Vals64.push_back(CaseRanges.getNumItems()); @@ -886,8 +870,7 @@ static bool WriteInstruction(const Instruction &I, unsigned InstID, Vals64.push_back(true/*IsSingleNumber = true*/); - EmitAPInt(Vals64, Code, Abbrev, - CaseRanges.getSingleNumber(ri), true); + EmitAPInt(Vals64, Code, Abbrev, CaseRanges.getSingleNumber(ri)); } } else for (unsigned ri = 0, rn = CaseRanges.getNumItems(); @@ -897,9 +880,9 @@ static bool WriteInstruction(const Instruction &I, unsigned InstID, Vals64.push_back(IsSingleNumber); - EmitAPInt(Vals64, Code, Abbrev, r.getLow(), true); + EmitAPInt(Vals64, Code, Abbrev, r.getLow()); if (!IsSingleNumber) - EmitAPInt(Vals64, Code, Abbrev, r.getHigh(), true); + EmitAPInt(Vals64, Code, Abbrev, r.getHigh()); } } Vals64.push_back(VE.getValueID(i.getCaseSuccessor())); |