aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h4
-rw-r--r--lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp10
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp2
3 files changed, 7 insertions, 9 deletions
diff --git a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
index ef1c89c094..3620f7f526 100644
--- a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
+++ b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
@@ -212,8 +212,8 @@ namespace naclbitc {
CAST_SITOFP = 6,
CAST_FPTRUNC = 7,
CAST_FPEXT = 8,
- CAST_PTRTOINT = 9,
- CAST_INTTOPTR = 10,
+ // 9 was CAST_PTRTOINT; not used in PNaCl.
+ // 10 was CAST_INTTOPTR; not used in PNaCl.
CAST_BITCAST = 11
};
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
index 85f815a8a9..a37201e8f4 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
@@ -91,8 +91,6 @@ static int GetDecodedCastOpcode(unsigned Val) {
case naclbitc::CAST_SITOFP : return Instruction::SIToFP;
case naclbitc::CAST_FPTRUNC : return Instruction::FPTrunc;
case naclbitc::CAST_FPEXT : return Instruction::FPExt;
- case naclbitc::CAST_PTRTOINT: return Instruction::PtrToInt;
- case naclbitc::CAST_INTTOPTR: return Instruction::IntToPtr;
case naclbitc::CAST_BITCAST : return Instruction::BitCast;
}
}
@@ -1117,12 +1115,14 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) {
Value *Op;
if (popValue(Record, &OpNum, NextValueNo, &Op) ||
OpNum+2 != Record.size())
- return Error("Invalid CAST record");
+ return Error("Invalid CAST record: bad record size");
Type *ResTy = getTypeByID(Record[OpNum]);
+ if (ResTy == 0)
+ return Error("Invalid CAST record: bad type ID");
int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
- if (Opc == -1 || ResTy == 0)
- return Error("Invalid CAST record");
+ if (Opc == -1)
+ return Error("Invalid CAST record: bad opcode");
// If a ptrtoint cast was elided on the argument of the cast,
// add it back. Note: The casts allowed here should match the
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
index 4cbb74be09..8a8e108621 100644
--- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
@@ -119,8 +119,6 @@ static unsigned GetEncodedCastOpcode(unsigned Opcode, const Value &V) {
case Instruction::SIToFP : return naclbitc::CAST_SITOFP;
case Instruction::FPTrunc : return naclbitc::CAST_FPTRUNC;
case Instruction::FPExt : return naclbitc::CAST_FPEXT;
- case Instruction::PtrToInt: return naclbitc::CAST_PTRTOINT;
- case Instruction::IntToPtr: return naclbitc::CAST_INTTOPTR;
case Instruction::BitCast : return naclbitc::CAST_BITCAST;
}
}