public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922
@ 2020-11-02 11:27 asolokha at gmx dot com
  2020-11-02 11:31 ` [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365 marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: asolokha at gmx dot com @ 2020-11-02 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97673
           Summary: [11 Regression] ICE in remap_gimple_stmt, at
                    tree-inline.c:1922
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

gfortran-11.0.0-alpha20201101 snapshot
(g:590febb5f6624f78b36402a7c9a9c318978f1efa) ICEs when compiling the following
testcase, extracted from gcc/testsuite/gfortran.dg/bind_c_usage_14.f03, w/ -O3
-fno-early-inlining --param large-stack-frame=400:

subroutine sub3noiso(a, b)
  use iso_c_binding
  implicit none
  character(len=1,kind=c_char) :: a(*), b
  character(len=1,kind=c_char):: x,z
  integer(c_int) :: y
  value :: b
  print *, a(1:2), b
entry sub3noisoEntry(x,y,z)
  x = 'd'
end subroutine sub3noiso

% powerpc-e300c3-linux-gnu-gfortran-11.0.0 -O3 -fno-early-inlining --param
large-stack-frame=400 -c lvybva48.f03
during IPA pass: inline
lvybva48.f03:9:0:

    9 | entry sub3noisoEntry(x,y,z)
      |
internal compiler error: in remap_gimple_stmt, at tree-inline.c:1922
0xedd483 remap_gimple_stmt
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:1922
0xee1393 copy_bb
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:2023
0xee2862 copy_cfg_body
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:3046
0xee2862 copy_body
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:3294
0xee5d7b expand_call_inline
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:5084
0xee7aac gimple_expand_calls_inline
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:5274
0xee7aac optimize_inline_calls(tree_node*)
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/tree-inline.c:5447
0xc30eee inline_transform(cgraph_node*)
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/ipa-inline-transform.c:763
0xd80fdf execute_one_ipa_transform_pass
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/passes.c:2240
0xd80fdf execute_all_ipa_transforms(bool)
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/passes.c:2287
0x9fb6e2 cgraph_node::expand()
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/cgraphunit.c:1822
0x9fcdae expand_all_functions
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/cgraphunit.c:1997
0x9fcdae symbol_table::compile()
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/cgraphunit.c:2361
0x9fcdae symbol_table::compile()
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/cgraphunit.c:2272
0x9ffa56 symbol_table::finalize_compilation_unit()
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20201101/work/gcc-11-20201101/gcc/cgraphunit.c:2542

(While my target here is powerpc, the ICE should not be target-specific.)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
@ 2020-11-02 11:31 ` marxin at gcc dot gnu.org
  2020-11-04 13:56 ` hubicka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-02 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
      Known to fail|                            |11.0
   Target Milestone|---                         |11.0
            Summary|[11 Regression] ICE in      |[11 Regression] ICE in
                   |remap_gimple_stmt, at       |remap_gimple_stmt, at
                   |tree-inline.c:1922          |tree-inline.c:1922 since
                   |                            |r11-4267-g0e590b68fa374365
   Last reconfirmed|                            |2020-11-02
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |10.2.0
                 CC|                            |hubicka at gcc dot gnu.org
           Priority|P3                          |P1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
One can reproduce that on x86_64 with:
--param large-stack-frame=4000:

started with r11-4267-g0e590b68fa374365.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
  2020-11-02 11:31 ` [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365 marxin at gcc dot gnu.org
@ 2020-11-04 13:56 ` hubicka at gcc dot gnu.org
  2020-11-18 14:24 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hubicka at gcc dot gnu.org @ 2020-11-04 13:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This should be dup of PR97578

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
  2020-11-02 11:31 ` [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365 marxin at gcc dot gnu.org
  2020-11-04 13:56 ` hubicka at gcc dot gnu.org
@ 2020-11-18 14:24 ` jakub at gcc dot gnu.org
  2021-01-19 11:12 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is not, it still ICEs with r11-5128 and
-O3 -fno-early-inlining --param large-stack-frame=4000 on x86_64-linux.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-11-18 14:24 ` jakub at gcc dot gnu.org
@ 2021-01-19 11:12 ` rguenth at gcc dot gnu.org
  2021-01-19 11:24 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-19 11:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the issue is that we are inlining

# .MEM_5 = VDEF <.MEM_1(D)>
master.0.sub3noiso.constprop (1, z_2(D), y_3(D), x_4(D), 0B, 0B, 1, 1, 0, 0);
$12 = void

and duplicate the clones BLOCK tree via

  if (DECL_INITIAL (fn))
    {
      if (gimple_block (stmt))
        {
          tree *var;

          prepend_lexical_block (id->block,
                                 remap_blocks (DECL_INITIAL (fn), id));

but the actual stmts we copy refer to the original function BLOCKs.

That's likely because we ask for the untransformed body but that process
does not "update" the scope tree?  Adding

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index cd3fad1fa98..84f71d9c6cc 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -6513,6 +6513,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
   delete param_body_adjs;
   free_dominance_info (CDI_DOMINATORS);
   free_dominance_info (CDI_POST_DOMINATORS);
+  verify_gimple_in_cfg (cfun, false);

   gcc_assert (!id.debug_stmts.exists ());
   pop_cfun ();

yields

> ./f951 -quiet t.f90 -O3 -fno-early-inlining --param large-stack-frame=4000
t.f90:9:20:

    9 | entry sub3noisoEntry(x,y,z)
      |                    ^
Error: location references block not in block tree
# .MEM_5 = VDEF <.MEM_4(D)>
D.4037 = {};
during IPA pass: inline
t.f90:9:20: internal compiler error: verify_gimple failed
0x157e641 verify_gimple_in_cfg(function*, bool)
        /home/rguenther/src/gcc2/gcc/tree-cfg.c:5467
0x15fd84b tree_function_versioning(tree_node*, tree_node*,
vec<ipa_replace_map*, va_gc, vl_embed>*, ipa_param_adjustments*, bool,
bitmap_head*, basic_block_def*)
        /home/rguenther/src/gcc2/gcc/tree-inline.c:6516
0xd97875 cgraph_node::materialize_clone()
        /home/rguenther/src/gcc2/gcc/cgraphclones.c:1131
0xd7cfb0 cgraph_node::get_untransformed_body()
        /home/rguenther/src/gcc2/gcc/cgraph.c:3903
0x15f727c expand_call_inline
        /home/rguenther/src/gcc2/gcc/tree-inline.c:4850

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2021-01-19 11:12 ` rguenth at gcc dot gnu.org
@ 2021-01-19 11:24 ` rguenth at gcc dot gnu.org
  2021-01-19 12:22 ` cvs-commit at gcc dot gnu.org
  2021-01-19 12:23 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-19 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
And _that_ stmts location is set via

0  gimple_set_location (g=<gimple_assign 0x7ffff660baa0>, location=2147483660)
    at /home/rguenther/src/gcc2/gcc/gimple.h:1890
#1  0x0000000000fcf822 in annotate_one_with_location (gs=<gimple_assign
0x7ffff660baa0>, 
    location=2147483660) at /home/rguenther/src/gcc2/gcc/gimple.c:1354
#2  0x0000000000fcf8bb in annotate_all_with_location_after (seq=0x7ffff660baa0,
gsi=..., 
    location=2147483660) at /home/rguenther/src/gcc2/gcc/gimple.c:1371
#3  0x000000000106ba5f in gimplify_expr (expr_p=0x7fffffffcbc8,
pre_p=0x7fffffffcf58, 
    post_p=0x7fffffffca50, gimple_test_f=0x103d7f1 <is_gimple_stmt(tree)>,
fallback=0)
    at /home/rguenther/src/gcc2/gcc/gimplify.c:14956
#4  0x000000000104263a in gimplify_stmt (stmt_p=0x7fffffffcbc8,
seq_p=0x7fffffffcf58)
    at /home/rguenther/src/gcc2/gcc/gimplify.c:6870
#5  0x000000000102cd4b in gimplify_and_add (t=<tree 0x0>, seq_p=0x7fffffffcf58)
    at /home/rguenther/src/gcc2/gcc/gimplify.c:489
#6  0x000000000102d49a in internal_get_tmp_var (val=<constructor
0x7ffff6612ba0>, pre_p=0x7fffffffcf58, 
    post_p=0x0, is_formal=true, allow_ssa=true) at
/home/rguenther/src/gcc2/gcc/gimplify.c:642
#7  0x000000000102d4e3 in get_formal_tmp_var (val=<constructor 0x7ffff6612ba0>,
pre_p=0x7fffffffcf58)
    at /home/rguenther/src/gcc2/gcc/gimplify.c:663
#8  0x000000000106bf72 in gimplify_expr (expr_p=0x7fffffffcf28,
pre_p=0x7fffffffcf58, 
    post_p=0x7fffffffcdd0, gimple_test_f=0x102ce8c
<is_gimple_mem_rhs_or_call(tree)>, fallback=1)
    at /home/rguenther/src/gcc2/gcc/gimplify.c:15045
#9  0x0000000001073cad in gimple_regimplify_operands (stmt=<gimple_assign
0x7ffff660b410>, 
    gsi_p=0x7fffffffd000) at /home/rguenther/src/gcc2/gcc/gimplify-me.c:235
#10 0x00000000015f394c in insert_init_stmt (id=0x7fffffffd1d0, bb=<basic_block
0x7ffff6815c98 (5)>, 
    init_stmt=<gimple_assign 0x7ffff660b410>) at
/home/rguenther/src/gcc2/gcc/tree-inline.c:3397
#11 0x00000000015fd0f7 in tree_function_versioning (
    old_decl=<function_decl 0x7ffff69e0200 master.0.sub3noiso>, 
    new_decl=<function_decl 0x7ffff69f6600 master.0.sub3noiso.constprop>, 
    tree_map=0x7ffff69f52d0 = {...}, param_adjustments=0x0, update_clones=true,
blocks_to_copy=0x0, 
    new_entry=<basic_block 0x0>) at
/home/rguenther/src/gcc2/gcc/tree-inline.c:6399

from 'input_location' (meh) which is set by expand_call_inline and then
"used" via tree_function_versioning.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2021-01-19 11:24 ` rguenth at gcc dot gnu.org
@ 2021-01-19 12:22 ` cvs-commit at gcc dot gnu.org
  2021-01-19 12:23 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-19 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:7d6f7e92c3b737736a2d8ff97a71af9f230c2f88

commit r11-6788-g7d6f7e92c3b737736a2d8ff97a71af9f230c2f88
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jan 19 12:29:18 2021 +0100

    ipa/97673 - fix input_location leak

    This fixes input_location leaking with an invalid BLOCK from
    expand_call_inline to tree_function_versioning via clone
    materialization.

    2021-01-19  Richard Biener  <rguenther@suse.de>

            PR ipa/97673
            * tree-inline.c (tree_function_versioning): Set input_location
            to UNKNOWN_LOCATION throughout the function.

            * gfortran.dg/pr97673.f90: New testcase.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365
  2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2021-01-19 12:22 ` cvs-commit at gcc dot gnu.org
@ 2021-01-19 12:23 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-19 12:23 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-19 12:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02 11:27 [Bug ipa/97673] New: [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 asolokha at gmx dot com
2020-11-02 11:31 ` [Bug ipa/97673] [11 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1922 since r11-4267-g0e590b68fa374365 marxin at gcc dot gnu.org
2020-11-04 13:56 ` hubicka at gcc dot gnu.org
2020-11-18 14:24 ` jakub at gcc dot gnu.org
2021-01-19 11:12 ` rguenth at gcc dot gnu.org
2021-01-19 11:24 ` rguenth at gcc dot gnu.org
2021-01-19 12:22 ` cvs-commit at gcc dot gnu.org
2021-01-19 12:23 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).