[PATCH] [opaque pointer type] bitcode support for explicit type parameter to the load instruction
David Blaikie
dblaikie at gmail.com
Tue Feb 24 18:36:13 PST 2015
Committed in r230414
On Tue, Feb 24, 2015 at 5:09 PM, David Blaikie <dblaikie at gmail.com> wrote:
> REPOSITORY
> rL LLVM
>
> http://reviews.llvm.org/D7655
>
> Files:
> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
>
> Index: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
> ===================================================================
> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
> @@ -1871,6 +1871,7 @@
> if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE)) // ptr
> AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
> }
> + Vals.push_back(VE.getTypeID(I.getType()));
> Vals.push_back(Log2_32(cast<LoadInst>(I).getAlignment())+1);
> Vals.push_back(cast<LoadInst>(I).isVolatile());
> if (cast<LoadInst>(I).isAtomic()) {
> @@ -2223,6 +2224,8 @@
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_LOAD));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Ptr
> + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
> + VE.computeBitsRequiredForTypeIndicies()));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile
> if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
> Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> ===================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> @@ -3574,23 +3574,36 @@
> unsigned OpNum = 0;
> Value *Op;
> if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
> - OpNum+2 != Record.size())
> + (OpNum + 2 != Record.size() && OpNum + 3 != Record.size()))
> return Error("Invalid record");
> +
> + Type *Ty = nullptr;
> + if (OpNum + 3 == Record.size())
> + Ty = getTypeByID(Record[OpNum++]);
> +
> unsigned Align;
> if (std::error_code EC = parseAlignmentValue(Record[OpNum], Align))
> return EC;
> I = new LoadInst(Op, "", Record[OpNum+1], Align);
> +
> + assert((!Ty || Ty == I->getType()) &&
> + "Explicit type doesn't match pointee type of the first
> operand");
> +
> InstructionList.push_back(I);
> break;
> }
> case bitc::FUNC_CODE_INST_LOADATOMIC: {
> // LOADATOMIC: [opty, op, align, vol, ordering, synchscope]
> unsigned OpNum = 0;
> Value *Op;
> if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
> - OpNum+4 != Record.size())
> + (OpNum + 4 != Record.size() && OpNum + 5 != Record.size()))
> return Error("Invalid record");
>
> + Type *Ty = nullptr;
> + if (OpNum + 5 == Record.size())
> + Ty = getTypeByID(Record[OpNum++]);
> +
> AtomicOrdering Ordering = GetDecodedOrdering(Record[OpNum+2]);
> if (Ordering == NotAtomic || Ordering == Release ||
> Ordering == AcquireRelease)
> @@ -3603,6 +3616,10 @@
> if (std::error_code EC = parseAlignmentValue(Record[OpNum], Align))
> return EC;
> I = new LoadInst(Op, "", Record[OpNum+1], Align, Ordering,
> SynchScope);
> +
> + assert((!Ty || Ty == I->getType()) &&
> + "Explicit type doesn't match pointee type of the first
> operand");
> +
> InstructionList.push_back(I);
> break;
> }
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150224/9511f6f1/attachment.html>
More information about the llvm-commits
mailing list