[cfe-dev] assert when vector variable is used as the size of array
Anton Yartsev
anton.yartsev at gmail.com
Tue Jul 20 22:39:03 PDT 2010
Hi all,
I accidentally stumbled upon the fact that situation when a vector
variable is used as the size of array is not handled. Compiling the code
void f()
{
int __attribute__ ((vector_size (16))) a;
int b[a];
}
ends with
Assertion failed: castIsValid(getOpcode(), S, Ty) && "Illegal BitCast",
file Instructions.cpp, line 2654
While investigating the problem I found out that methods
Type::isIntegerType(), Type::isSignedIntegerType() and
Type::isUnsignedIntegerType() (.\lib\AST\Type.cpp ) return 'true' for
vector types with corresponding element types. It looks strange as
vector types are not treated as integer types.
I made two patches: the first one - vector_size_of_array.patch - removes
code for vectors from the above methods and adds additional methods
instead - Type::hasIntegerRepresentation(),
Type::hasSignedIntRepresentation() and
Type::hasUnsignedIntRepresentation() - by analogy with
Type::isFloatingType() and Type::hasFloatingRepresentation(). Calls to
old methods were replaced with calls to new ones where it was needed (at
least no regression bugs). The patch solves the subject. It also make
Clang sliiiightly faster..
The second patch - vector_size_of_array_SIMPLE.patch - only solves the
subject.
Please review and comment.
--
Anton
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vector_size_of_array.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100721/7fdd45fe/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vector_size_of_array_SIMPLE.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100721/7fdd45fe/attachment-0001.ksh>
More information about the cfe-dev
mailing list