aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp')
-rw-r--r--lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
index ea5e9cde54..4a6a454796 100644
--- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
+++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
@@ -718,7 +718,16 @@ static bool WriteInstruction(const Instruction &I, unsigned InstID,
AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
pushValue(I.getOperand(0), InstID, Vals, VE, Stream);
Vals.push_back(VE.getTypeID(I.getType()));
- Vals.push_back(GetEncodedCastOpcode(I.getOpcode(), I));
+ unsigned Opcode = I.getOpcode();
+ Vals.push_back(GetEncodedCastOpcode(Opcode, I));
+ if (PNaClVersion >= 2 &&
+ (Opcode == Instruction::PtrToInt ||
+ Opcode == Instruction::IntToPtr ||
+ (Opcode == Instruction::BitCast &&
+ (I.getOperand(0)->getType()->isPointerTy() ||
+ I.getType()->isPointerTy())))) {
+ ReportIllegalValue("(PNaCl ABI) pointer cast", I);
+ }
} else if (isa<BinaryOperator>(I)) {
// BINOP: [opval, opval, opcode[, flags]]
Code = naclbitc::FUNC_CODE_INST_BINOP;