FYI,

 I will shortly be submitting , and presumable committing, this patch as part of a series to improve VRP time for 117467..

So it may be in place by the time you need it

Andrew

On 11/18/24 09:31, Andrew MacLeod wrote:
Attached is a pre-approved patch which adds a range_query to the inferred range mechanism.

The only change you will need to make is to replace "get_range_query (cfun)->"  with "q->" which is passed in.

This regstraps on x86 without your patch, and I got as far as a bootstrap with your patches..

Andfrew

On 11/15/24 04:36, Jakub Jelinek wrote:
On Thu, Nov 14, 2024 at 06:25:49PM +0100, Jakub Jelinek wrote:
On Thu, Nov 14, 2024 at 10:05:05AM -0500, Andrew MacLeod wrote:
The inferred range mechanism is also initialized using cfun, so again
introducing a use of cfun shouldnt be an issue.

Something like this ought to work I think?
2024-11-14  Jakub Jelinek  <ja...@redhat.com>
        Andrew MacLeod  <amacl...@redhat.com>

    PR c/117023
    * gimple-range-infer.cc (gimple_infer_range::gimple_infer_range):
    Handle also nonnull_if_nonzero attributes.

    * gcc.dg/tree-ssa/pr78154-2.c: New test.
Unfortunately that broke bootstrap.
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668699.html
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668700.html
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668711.html
bootstrap/regtest fine, but if
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668700.html
in there is replaced with
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668818.html
I get ICE on e.g. opts-common.cc.

Reduced testcase:

void foo (int *, __SIZE_TYPE__);
char *a, b[64], c;

void
bar (void)
{
   for (int i = 0; i < 42; ++i)
     {
       char *d = &a[i];
       int e;
       if (c)
    foo (&e, 1);
       __SIZE_TYPE__ f = __builtin_strlen (d);
       if (f)
    __builtin_memcpy (b, d, f);
     }
}

/home/jakub/src/gcc/obj72x/prev-gcc/cc1 -quiet -O2 fbc-ice.c
during GIMPLE pass: wrestrict
fbc-ice.c: In function ‘bar’:
fbc-ice.c:5:1: internal compiler error: in fill_block_cache, at gimple-range-cache.cc:1565
     5 | bar (void)
       | ^~~
0x44ebf97 internal_error(char const*, ...)
    ../../gcc/diagnostic-global-context.cc:518
0x44bc0ef fancy_abort(char const*, int, char const*)
    ../../gcc/diagnostic.cc:1696
0x41d186f ranger_cache::fill_block_cache(tree_node*, basic_block_def*, basic_block_def*)
    ../../gcc/gimple-range-cache.cc:1565
0x41d07be ranger_cache::block_range(vrange&, basic_block_def*, tree_node*, bool)
    ../../gcc/gimple-range-cache.cc:1304
0x41c95f4 gimple_ranger::range_on_entry(vrange&, basic_block_def*, tree_node*)
    ../../gcc/gimple-range.cc:175
0x41c93f3 gimple_ranger::range_of_expr(vrange&, tree_node*, gimple*)
    ../../gcc/gimple-range.cc:147
0x41e2c8c gimple_infer_range::gimple_infer_range(gimple*, bool)
    ../../gcc/gimple-range-infer.cc:205
0x41e3f52 infer_range_manager::register_all_uses(tree_node*)
    ../../gcc/gimple-range-infer.cc:476
0x41e35ec infer_range_manager::has_range_p(basic_block_def*, tree_node*)
    ../../gcc/gimple-range-infer.cc:356
0x41d1a64 ranger_cache::fill_block_cache(tree_node*, basic_block_def*, basic_block_def*)
    ../../gcc/gimple-range-cache.cc:1604
0x41d07be ranger_cache::block_range(vrange&, basic_block_def*, tree_node*, bool)
    ../../gcc/gimple-range-cache.cc:1304
0x41c95f4 gimple_ranger::range_on_entry(vrange&, basic_block_def*, tree_node*)
    ../../gcc/gimple-range.cc:175
0x41c93f3 gimple_ranger::range_of_expr(vrange&, tree_node*, gimple*)
    ../../gcc/gimple-range.cc:147
0x41d5d5b fur_stmt::get_operand(vrange&, tree_node*)
    ../../gcc/gimple-range-fold.cc:143
0x41d7cb5 fold_using_range::range_of_range_op(vrange&, gimple_range_op_handler&, fur_source&)
    ../../gcc/gimple-range-fold.cc:718
0x41d770e fold_using_range::fold_stmt(vrange&, gimple*, fur_source&, tree_node*)
    ../../gcc/gimple-range-fold.cc:649
0x41c9d03 gimple_ranger::fold_range_internal(vrange&, gimple*, tree_node*)
    ../../gcc/gimple-range.cc:278
0x41ca03c gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*)
    ../../gcc/gimple-range.cc:339
0x41c95b5 gimple_ranger::range_on_entry(vrange&, basic_block_def*, tree_node*)
    ../../gcc/gimple-range.cc:172
0x41c93f3 gimple_ranger::range_of_expr(vrange&, tree_node*, gimple*)
    ../../gcc/gimple-range.cc:147
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

    Jakub


Reply via email to