diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-09-03 13:59:55 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-09-03 13:59:55 -0700 |
commit | 30aa17affbfa35a9d32895ff6f4b5f5fbfc9575a (patch) | |
tree | 387b9668a029e22fcbcbf428bc46b195e5c8e146 /lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | |
parent | 264065105b2b9be73662b3c7e5a66c9d70d26a2c (diff) |
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
Diffstat (limited to 'lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp')
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 11 |
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; |