[llvm-branch-commits] [cfe-branch] r195386 - Merging r195367:
Bill Wendling
isanbard at gmail.com
Thu Nov 21 15:33:07 PST 2013
Author: void
Date: Thu Nov 21 17:33:07 2013
New Revision: 195386
URL: http://llvm.org/viewvc/llvm-project?rev=195386&view=rev
Log:
Merging r195367:
------------------------------------------------------------------------
r195367 | joey | 2013-11-21 09:09:05 -0800 (Thu, 21 Nov 2013) | 17 lines
Fix a crash in EmitStoreThroughExtVectorComponentLValue for vectors of odd sizes.
In OpenCL a vector of 3 elements, acts like a vector of four elements.
So for a vector of size 3 the '.hi' and '.odd' accessors, would access
the elements {2, 3} and {1, 3} respectively.
However, in EmitStoreThroughExtVectorComponentLValue we are still operating on
a vector of size 3, so we should only access {2} and {1}. We do this by checking
the last element to be accessed, and ignore it if it is out-of-bounds.
EmitLoadOfExtVectorElementLValue doesn't have a similar problem, because it does
a direct shufflevector with undef, so an out-of-bounds access just gives an undef
value.
Patch by Anastasia Stulova!
------------------------------------------------------------------------
Added:
cfe/branches/release_34/test/CodeGenOpenCL/vector_odd.cl
- copied unchanged from r195367, cfe/trunk/test/CodeGenOpenCL/vector_odd.cl
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/lib/CodeGen/CGExpr.cpp
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 21 17:33:07 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195367
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/CodeGen/CGExpr.cpp?rev=195386&r1=195385&r2=195386&view=diff
==============================================================================
--- cfe/branches/release_34/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/release_34/lib/CodeGen/CGExpr.cpp Thu Nov 21 17:33:07 2013
@@ -1553,6 +1553,12 @@ void CodeGenFunction::EmitStoreThroughEx
for (unsigned i = 0; i != NumDstElts; ++i)
Mask.push_back(Builder.getInt32(i));
+ // When the vector size is odd and .odd or .hi is used, the last element
+ // of the Elts constant array will be one past the size of the vector.
+ // Ignore the last element here, if it is greater than the mask size.
+ if (getAccessedFieldNo(NumSrcElts - 1, Elts) == Mask.size())
+ NumSrcElts--;
+
// modify when what gets shuffled in
for (unsigned i = 0; i != NumSrcElts; ++i)
Mask[getAccessedFieldNo(i, Elts)] = Builder.getInt32(i+NumDstElts);
More information about the llvm-branch-commits
mailing list