[LLVMdev] Question about intrinsic function llvm.objectsize

Shuxin Yang shuxin.llvm at gmail.com
Wed Feb 27 10:57:03 PST 2013


I take one more look of the code, seems like we have to implement 
getSizeOfEntireObject(p).
The reason is the that we have no idea if the value returned from 
getUnderlyingObject() points to a legal object or not,

On 2/27/13 10:53 AM, Shuxin Yang wrote:
>
>> In the "llvm.objectsize" context we pass an object "based on p" to 
>> getObjectSize: "p+50". In the basicaa context, we wanna know whether 
>> an access is beyond the bounds of an underlying object (undefined 
>> behavior land) so we pass the underlying object (which in your 
>> example would be the "p" returned from malloc) to the getObjectSize 
>> function.
>>
>> In the first case (passing "p+50" to getObjectSize) ObjSize should be 
>> 56 and the Offset will be 50 yielding 6 in the second case your 
>> ObjSize will be 56 and the offset is zero because basicaa passed the 
>> underlying object "p".
> you figured out an alternative to fix the problem.  In the context of 
> alias analysis, it is up to the caller to pass
> the base addr of the "object" to getObjectSize() by calling 
> getUnderlyingObject().
>
> However,  if the base-addr is bit complicated, say, one needs to go 
> through U-D chain (including phi node).
> In this situation, a helper class ObjectSizeOffsetVisitor will help.
>
> My take is to implement another function, call getEntireObjectSize(p) 
> which returns the size of the entire object
> no matter where the p is pointing to. How does this sound to you?
>
> Thanks
>
>




More information about the llvm-dev mailing list