On 10/10/18 4:36 PM, Jeff Law wrote: > On 10/2/18 10:37 AM, Martin Sebor wrote: >> [3/4] - Change sprintf to use new get_range_strlen overload >> >> This change makes use of the new get_range_strlen() overload >> in gimple-ssa-sprintf.c. This necessitated a few changes to >> the API but also enabled the removal of the flexarray member >> from strlen_data_t. >> >> This also patch restores the bool return value for the public >> get_strlen_range function but with a different meaning (to >> indicate whether the computed range is suitable as is to rely >> on for optimization, rather than whether the argument may >> refer to a flexible array member). >> >> The changes to gimple-ssa-sprintf.c involve more indentation >> adjustments than new functionality so to make the review easier >> I attach gcc-99999-3-gimple-ssa-sprintf.c.diff-b with the white >> space changes stripped. >> >> gcc-99999-3.diff >> >> [3/4] - Change sprintf to use new get_range_strlen overload >> >> gcc/ChangeLog: >> >> * gimple-fold.c (get_range_strlen): Avoid clearing minlen after >> recursive call fails for COND_EXPR and GIMPLE_PHI. >> Set minlen to ssize_type rather than size_type. Remove flexarray. >> (get_range_strlen): Return bool. >> (get_range_strlen): Return bool. Clear minmaxlen[0]. >> * gimple-fold.h (strlen_data_t): Remove member. Update comments. >> (get_range_strlen): Return bool. >> * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Reset lenrange[0] >> when maxlen is unbounded. >> * gimple-ssa-sprintf.c (get_string_length): Call new overload of >> get_range_strlen. Adjust max, likely, and unlikely counters for >> strings of unbounded lengths. > This fixes most, but not all of the regressions introduced in patch #2 > (pr79376 continues to regress). However it introduces a bunch of > regressions on warn-sprintf-no-nul.c. I think the warn-sprintf-no-nul.c regressions are just a matter of failing to set res.nonstr when get_range_strlen finds as non-terminated string.
That just leaves pr79376 -- I think the test is bogus given the requirement that we not optimize based on subobject boundaries. We can't use the subobject boundaries to set the output range of the snprintf. Jeff