aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-09-03 13:59:55 -0700
committerKarl Schimpf <kschimpf@google.com>2013-09-03 13:59:55 -0700
commit30aa17affbfa35a9d32895ff6f4b5f5fbfc9575a (patch)
tree387b9668a029e22fcbcbf428bc46b195e5c8e146 /lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
parent264065105b2b9be73662b3c7e5a66c9d70d26a2c (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.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;