summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-08-31 18:00:30 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-08-31 18:00:30 +0000
commit984fefdd81f310baa4d0a2562e71adeb8cd80bce (patch)
treea43fda2d80fde9365f579298c14750e0e001e4d1 /llvm/lib/Bitcode
parentb9c2c71d09ee49e43618901cc9803fdc637c15c9 (diff)
downloadbcm5719-llvm-984fefdd81f310baa4d0a2562e71adeb8cd80bce.tar.gz
bcm5719-llvm-984fefdd81f310baa4d0a2562e71adeb8cd80bce.zip
[BitcodeReader] Ensure we can read constant vector selects with an i1 condition
Summary: Constant vectors weren't allowed to have an i1 condition in the BitcodeReader. Make sure we have the same restrictions that are documented, not more. Reviewers: nlewycky, rafael, kschimpf Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12440 llvm-svn: 246459
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index c767b6c5c17..b9604af3bc8 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2475,11 +2475,12 @@ std::error_code BitcodeReader::parseConstants() {
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.
+ // The selector might be an i1 or an <n x i1>
+ // Get the type from the ValueList before getting a forward ref.
if (VectorType *VTy = dyn_cast<VectorType>(CurTy))
- SelectorTy = VectorType::get(Type::getInt1Ty(Context),
- VTy->getNumElements());
+ if (Value *V = ValueList[Record[0]])
+ if (SelectorTy != V->getType())
+ SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements());
V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
SelectorTy),
OpenPOWER on IntegriCloud