On 2024-09-20 21:42, Siddhesh Poyarekar wrote:
On 2024-09-20 20:20, Sam James wrote:
Siddhesh Poyarekar <siddh...@gotplt.org> writes:

This series makes a few improvements to get static object size estimates in
more cases, thus improving the success rate of the static
__builtin_object_size.  This should fully fix PR116556 and also covers a bulk of use cases for PR77608.  I started to try and fix PR77608 fully, but in the end it looks like too much work in the pass for what seems like a very small set of uses, i.e. handling volatile offsets.  If that is a desirable end goal
then it could be done in a separate patchset since it will need
tree-object-size to handle trees with side-effects.

I could try play with https://github.com/siddhesh/fortify-metrics to see
how much it happens in the wild if you can help me figure out a
condition for when it punts (not tried). But I'm sceptical it's
worth the time.

That's an interesting idea, but unfortunately the very first attempt at folding such a __builtin_object_size () call eliminates it, which AFAICT happens right in the frontend.  Maybe if the compiler is hacked up to move the TREE_SIDE_EFFECTS (ptr) into compute_builtin_object_size like the attached lightly tested patch, you could look for TREE_SIDE_EFFECTS (ptr) in fortify-metrics to identify such lost opportunities.

I forgot to add that I share your scepticism, which is why I stopped exploring too.

Thanks,
Sid

Reply via email to