Patch to BitcodeReader
Tobias Grosser
tobias at grosser.es
Thu Sep 12 14:10:38 PDT 2013
On 09/12/2013 11:03 PM, Tom Roeder wrote:
> Here's a version with a comment and the fixed CHECK statement.
Nice.
Just a tiny comment I overlooked before:
> Index: lib/Bitcode/Reader/BitcodeReader.cpp
> ===================================================================
> --- lib/Bitcode/Reader/BitcodeReader.cpp (revision 190562)
> +++ lib/Bitcode/Reader/BitcodeReader.cpp (working copy)
> @@ -1389,11 +1389,23 @@
> }
> case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#]
> if (Record.size() < 3) return Error("Invalid CE_SELECT record");
> - V = ConstantExpr::getSelect(
> - ValueList.getConstantFwdRef(Record[0],
> - Type::getInt1Ty(Context)),
> - ValueList.getConstantFwdRef(Record[1],CurTy),
> - ValueList.getConstantFwdRef(Record[2],CurTy));
> +
> + // If CurTy is a vector of length n, then Record[0] must be a <n x i1>
> + // vector. Otherwise, it must be a single bit.
> + if (VectorType *VTy = dyn_cast<VectorType>(CurTy)) {
> + unsigned int EltCount = VTy->getNumElements();
> + Type *SelectorTy = VectorType::get(Type::getInt1Ty(Context), EltCount);
> +
> + V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
> + SelectorTy),
> + ValueList.getConstantFwdRef(Record[1],CurTy),
> + ValueList.getConstantFwdRef(Record[2],CurTy));
> + } else {
> + V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
> + Type::getInt1Ty(Context)),
> + ValueList.getConstantFwdRef(Record[1],CurTy),
> + ValueList.getConstantFwdRef(Record[2],CurTy));
^^ Those lines are not properly
aligned.
Otherwise, the patch looks good. Can you commit this patch yourself or
do you need me to commit it?
Cheers,
Tobias
More information about the llvm-commits
mailing list