diff options
author | Joe Abbey <jabbey@arxan.com> | 2013-09-12 22:02:31 +0000 |
---|---|---|
committer | Joe Abbey <jabbey@arxan.com> | 2013-09-12 22:02:31 +0000 |
commit | 1a6e77080fef6163c10f16d227b0eb1a982127ca (patch) | |
tree | 7505841fab0fed46a353b10740849fb8ee6d0c06 /llvm/lib/Bitcode | |
parent | 6f3254962325da383c3a98c43e8b33b0a9fa8722 (diff) | |
download | bcm5719-llvm-1a6e77080fef6163c10f16d227b0eb1a982127ca.tar.gz bcm5719-llvm-1a6e77080fef6163c10f16d227b0eb1a982127ca.zip |
Patch provide by Tom Roeder!
Reviewed by Joe Abbey and Tobias Grosser
Here is a patch that fixes decoding of CE_SELECT in BitcodeReader,
along with a simple test case. The problem in the current code is that
it generates but doesn't accept bitcode that uses vectors for the
first element of a select in this context.
llvm-svn: 190634
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 3ac6e038fda..ca432fd5903 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1387,14 +1387,23 @@ bool BitcodeReader::ParseConstants() { bitc::CST_CODE_CE_INBOUNDS_GEP); break; } - case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#] + 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)); + + Type *SelectorTy = Type::getInt1Ty(Context); + + // 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)) + SelectorTy = VectorType::get(Type::getInt1Ty(Context), + VTy->getNumElements()); + + V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0], + SelectorTy), + ValueList.getConstantFwdRef(Record[1],CurTy), + ValueList.getConstantFwdRef(Record[2],CurTy)); break; + } case bitc::CST_CODE_CE_EXTRACTELT: { // CE_EXTRACTELT: [opty, opval, opval] if (Record.size() < 3) return Error("Invalid CE_EXTRACTELT record"); VectorType *OpTy = |