diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-08-05 08:47:19 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-08-05 08:47:19 -0700 |
commit | b6846e1a64c3a56be80f1b7bd2d5bf10cfabc36f (patch) | |
tree | b734d0ec39b4cdf6beb905f31a7d6272089252b8 /lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | |
parent | 39bd1f66ebd83185944cf08903d8abf80321c17d (diff) |
Fix handling of the volatile bit of loads/stores in PNaCl bitcode files.
Fixes so that the volatile bit is no longer put into the bitcode file,
since the volatile bit is not in the PNaCl ABI.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3610
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/21949006
Diffstat (limited to 'lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp')
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index 9152879ff1..f6b85108e6 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -1007,23 +1007,35 @@ static bool WriteInstruction(const Instruction &I, unsigned InstID, break; case Instruction::Load: // PNaCl Version 1: LOAD: [op, align, vol] - // PNaCl Version 2: LOAD: [op, align, vol, ty] + // PNaCl Version 2: LOAD: [op, align, ty] Code = naclbitc::FUNC_CODE_INST_LOAD; pushValue(I.getOperand(0), InstID, Vals, VE, Stream); AbbrevToUse = FUNCTION_INST_LOAD_ABBREV; Vals.push_back(Log2_32(cast<LoadInst>(I).getAlignment())+1); - Vals.push_back(cast<LoadInst>(I).isVolatile()); + if (PNaClVersion == 1) { + // Note: Even though volatile values are not part of the ABI, + // we must add a value to the record for version 1, since the + // reader for version 1 has already been released. + Vals.push_back(0); + } if (PNaClVersion == 2) { Vals.push_back(VE.getTypeID(I.getType())); } break; - case Instruction::Store: // STORE: [ptr, val, align, vol] + case Instruction::Store: + // PNaCl version 1: STORE: [ptr, val, align, vol] + // PNaCl version 2: STORE: [ptr, val, align] Code = naclbitc::FUNC_CODE_INST_STORE; AbbrevToUse = FUNCTION_INST_STORE_ABBREV; pushValue(I.getOperand(1), InstID, Vals, VE, Stream); pushValue(I.getOperand(0), InstID, Vals, VE, Stream); Vals.push_back(Log2_32(cast<StoreInst>(I).getAlignment())+1); - Vals.push_back(cast<StoreInst>(I).isVolatile()); + if (PNaClVersion == 1) { + // Note: Even though volatile values are not part of the ABI, + // we must add a value to the record for version 1, since the + // reader for version 1 has already been released. + Vals.push_back(0); + } break; case Instruction::Call: { const CallInst &CI = cast<CallInst>(I); @@ -1244,7 +1256,13 @@ static void WriteBlockInfo(const NaClValueEnumerator &VE, Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_LOAD)); Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // Ptr Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 4)); // Align - Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // volatile + if (PNaClVersion == 1) { + // Note: Even though volatile values are not part of the ABI, + // we must add a value to the record for version 1, since the + // reader for version 1 has already been released. By using a constant, + // we at least avoid wasting space in the bitcode file. + Abbv->Add(NaClBitCodeAbbrevOp(0)); + } if (PNaClVersion == 2) { Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 4)); // Typecast } @@ -1323,7 +1341,13 @@ static void WriteBlockInfo(const NaClValueEnumerator &VE, Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // Ptr Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // Value Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 4)); // Align - Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // volatile + if (PNaClVersion == 1) { + // Note: Even though volatile values are not part of the ABI, + // we must add a value to the record for version 1, since the + // reader for version 1 has already been released. By using a constant, + // we at least avoid wasting space in the bitcode file. + Abbv->Add(NaClBitCodeAbbrevOp(0)); + } if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_STORE_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); |