[PATCH] D12440: [BitcodeReader] Ensure we can read constant vector selects with an i1 condition
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 11:35:43 PDT 2015
filcab created this revision.
filcab added reviewers: nlewycky, rafael.
filcab added a subscriber: llvm-commits.
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.
http://reviews.llvm.org/D12440
Files:
lib/Bitcode/Reader/BitcodeReader.cpp
test/Bitcode/select.ll
Index: test/Bitcode/select.ll
===================================================================
--- test/Bitcode/select.ll
+++ test/Bitcode/select.ll
@@ -8,3 +8,11 @@
; CHECK: define <2 x i32> @main() {
; CHECK: ret <2 x i32> <i32 0, i32 undef>
; CHECK: }
+
+define <2 x float> @f() {
+ ret <2 x float> select (i1 ptrtoint (<2 x float> ()* @f to i1), <2 x float> <float 1.000000e+00, float 0.000000e+00>, <2 x float> zeroinitializer)
+}
+
+; CHECK: define <2 x float> @f() {
+; CHECK: ret <2 x float> select (i1 ptrtoint (<2 x float> ()* @f to i1), <2 x float> <float 1.000000e+00, float 0.000000e+00>, <2 x float> zeroinitializer)
+; CHECK: }
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2474,11 +2474,13 @@
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(Type::getInt1Ty(Context),
+ VTy->getNumElements());
V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
SelectorTy),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12440.33447.patch
Type: text/x-patch
Size: 1744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150828/cb555e5a/attachment.bin>
More information about the llvm-commits
mailing list