https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85175

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're now warning on the loop body

<bb 4> [local count: 1073741824]:
# RANGE [irange] int [-2147483647, +INF]
# prephitmp_13 = PHI <0(2), _2(3)>
i = prephitmp_13;
if (prephitmp_13 <= 3)
  goto <bb 3>; [89.00%]
else
  goto <bb 5>; [11.00%]

<bb 3> [local count: 955630224]:
# USE = nonlocal escaped null const-pool { D.2963 D.2964 } (escaped)
# CLB = nonlocal escaped null const-pool { D.2963 D.2964 } (escaped)
__builtin_sprintf (&clkname, "di%d_sel", prephitmp_13);
clkname ={v} {CLOBBER(eos)};
i.1_1 = i;
# RANGE [irange] int [-2147483647, +INF]
_2 = i.1_1 + 1;

where most definitely using ranger would help.  Ranger is already enabled
in the strlen pass, but compute_format_length doesn't seem to use it?

#0  0x000000000346972b in (anonymous namespace)::maybe_warn (dirloc=..., 
    argloc=0, info=..., avail_range=..., res=..., dir=...)
    at ../../src/gcc/gcc/gimple-ssa-sprintf.cc:2973
#1  0x000000000346a154 in (anonymous namespace)::format_directive (info=..., 
    res=0x7fffffffcfa0, dir=..., ptr_qry=...)
    at ../../src/gcc/gcc/gimple-ssa-sprintf.cc:3203
#2  0x000000000346c7f3 in (anonymous namespace)::compute_format_length (
    info=..., res=0x7fffffffcfa0, ptr_qry=...)
    at ../../src/gcc/gcc/gimple-ssa-sprintf.cc:4077
#3  0x000000000346e19a in handle_printf_call (gsi=0x7fffffffd430, ptr_qry=...)
    at ../../src/gcc/gcc/gimple-ssa-sprintf.cc:4748
#4  0x0000000001d74cb6 in strlen_pass::check_and_optimize_call (
    this=0x7fffffffd3e0, zero_write=0x7fffffffd223)
    at ../../src/gcc/gcc/tree-ssa-strlen.cc:5479

Reply via email to