[LLVMdev] Constant::getAllOnesValue(): expected behaviour or bug?

Gabriel Quadros gabrielquadros at hotmail.com
Sun Jun 3 13:23:06 PDT 2012


Hi,
I was playing with the Constant::getAllOnesValue() method and found that it doesn't handlesPointerTypes correctly. When receiving a "i32*" argument, it was returning with some big integer vector, such as <12113216 x i32>.
When you call this method passing a PointerType, the following code is executed:
00152   VectorType *VTy = cast<VectorType>(Ty);00153   return ConstantVector::getSplat(VTy->getNumElements(),00154                                   getAllOnesValue(VTy->getElementType()
When VTy->getNumElements() is called, it returns the value of the instance variable NumElementspresent in VectorType objects, but we passed in a PointerType (SequentialType), which doesn't havethis variable but have at the same position one variable representing the type of the pointed thing.
00309 class SequentialType : public CompositeType {00310   Type *ContainedType; 
So getNumElements() will return some part of the value of ContainedType (an address), whichexplains that big integer vectors.
Do you think this is an expected behaviour or a bug?
Regards,Gabriel
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120603/0f01acce/attachment.html>


More information about the llvm-dev mailing list