From 30aa17affbfa35a9d32895ff6f4b5f5fbfc9575a Mon Sep 17 00:00:00 2001 From: Karl Schimpf Date: Tue, 3 Sep 2013 13:59:55 -0700 Subject: Remove all remaining pointer casts from PNaCl bitcode files. For PNaClVersion==2, removes remaining pointer casts from bitcode files. This includes: * Return value can be casted to a scalar value. * Intrinsic calls may return an inherent pointer, which may need casting to a scalar value. Also modifies tests bitcast-elide.ll and inttoptr-elide.ll by removing tests that assumed there were remaining pointer bitcasts that do not get removed. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/23524003 --- lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp') 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(I)) { // BINOP: [opval, opval, opcode[, flags]] Code = naclbitc::FUNC_CODE_INST_BINOP; -- cgit v1.2.3-70-g09d2