> On Nov 17, 2017, at 7:32 PM, Jeff Law <l...@redhat.com> wrote:
> 
> On 11/17/2017 03:45 PM, Qing Zhao wrote:
>>>> do you think using this routine is good? or do you have other
>>>> suggestions (since I am still not very familiar with the internals of
>>>> GCC, might not find the best available one now…)
>>> The range information attached to an SSA_NAME is global data.  ie, it
>>> must hold at all locations where the object in question might be
>>> referenced.  This implies that it will sometimes (often?) be less
>>> precise than you might like.
>> 
>> do you mean the “value_range” attached to SSA_NAME?
>> 
>> For my purpose, I’d like to get the maximum length of char array s[100] is 
>> 100, which is larger than the size of constant string “abc”, then
>> I can safely apply the transformation to memcmp. 
>> 
>> can “value_range” info serve this purpose?
> No it can't.  Sorry for leading you the wrong direction.  What you're
> looking for is the object size interfaces.
> 
> See tree-object-size.[ch]
> 
> That's a pass that tries to compute the sizes of various objects
> referenced by the IL.
> 
> Note that the object size is different than say the length of a string
> stored in an object for which you'll probably be looking at
> tree-ssa-strlen's interfaces.

thanks for the info. 

Yes, during my current implementation for B, I tried to use the interface for 
“tree-object-size”, i.e, “compute_builtin_object_size”
to decide the maximum length of the arrays, I noticed that it did not provide 
the information for the simple cases. then I switched to use 
“get_range_strlen”.

I will double check on this. 

> Ranges are more for integer objects.  ie, i has the value [0,25] or ~[0,0].

Okay, I see.
> 
>>> 
>>> I am currently working towards an embeddable context sensitive range
>>> analyzer that in theory could be used within tree-ssa-strlen pass to
>>> give more precise range information.  I'm hoping to wrap that work up in
>>> the next day or so so that folks can use it in gcc-8.
>> 
>> such context sensitive range info should be useful when we relax the 
>> constant “N” to be an expression whose Min value is larger than the length
>> of constant string, with it, we can catch more opportunities. 
>> let me know when this info is available.
> Hoping to have the basics into the trunk within the next few days as
> reviews flow in.

thanks.

Qing
> 
> jeff

Reply via email to