Bug 86076 - [7 Regression] ICE: verify_gimple failed (error: location references block not in block tree)
Summary: [7 Regression] ICE: verify_gimple failed (error: location references block no...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: 7.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2018-06-07 02:18 UTC by Arseny Solokha
Modified: 2018-11-26 11:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 7.3.1, 8.1.1, 9.0
Known to fail: 7.1.0, 7.3.0, 8.1.0
Last reconfirmed: 2018-06-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-06-07 02:18:57 UTC
gcc-9.0.0-alpha20180603 snapshot (r261132) ICEs when compiling the following snippet w/ -O2 (-O3, -Ofast) -ftree-parallelize-loops=2 -fno-tree-dce -fno-tree-pre -fno-tree-vrp --param max-loop-header-insns=1:

% gcc-9.0.0-alpha20180603 -O2 -ftree-parallelize-loops=2 -fno-tree-dce -fno-tree-pre -fno-tree-vrp --param max-loop-header-insns=1 -c gjp2o2cc.c
gjp2o2cc.c: In function 'o7':
gjp2o2cc.c:10:1: error: location references block not in block tree
 o7 (int uu)
 ^~
lv.constprop
_2 = lv.constprop ();
during GIMPLE pass: ompexpssa
gjp2o2cc.c:10:1: internal compiler error: verify_gimple failed
0xce3469 verify_gimple_in_cfg(function*, bool)
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180603/work/gcc-9-20180603/gcc/tree-cfg.c:5401
0xbbebaf execute_function_todo
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180603/work/gcc-9-20180603/gcc/passes.c:1994
0xbbfafe execute_todo
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180603/work/gcc-9-20180603/gcc/passes.c:2048
Comment 1 Arseny Solokha 2018-06-07 02:19:37 UTC
int __attribute__ ((noinline))
lv (int tm)
{
  (void) tm;

  return 0;
}

void
o7 (int uu)
{
  while (uu < 1)
    while (uu != 0)
    {
      short int ca;

      ca = lv (0);
      (void) ca;
      ++uu;
    }

  lv (lv (0));
}
Comment 2 Martin Liška 2018-06-07 05:06:38 UTC
Confirmed, note that I see it also on GCC 7 and 8 branches.
Started with an unrelated commit I guess: r241329.
Comment 3 Richard Biener 2018-06-07 08:07:46 UTC
Looks like some issue with autopar outlining.

Note such cases are a recipie for GC issues since the referenced BLOCK isn't
kept live by references from locations.  The BLOCK in the other function can
get removed/GCed.  Those issues are hard to track down which is why we have
this verifier...
Comment 4 paulhua 2018-06-13 06:50:44 UTC
Author: paulhua
Date: Wed Jun 13 06:50:12 2018
New Revision: 261538

URL: https://gcc.gnu.org/viewcvs?rev=261538&root=gcc&view=rev
Log:
2018-06-13  Chenghua Xu <paul.hua.gm@gmail.com>

	PR target/86076
	* config/mips/loongson.md (vec_setv4hi): Gen_lowpart for
	operands[2] instead of operands[1].

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/mips/loongson.md
Comment 5 Richard Biener 2018-06-14 13:03:24 UTC
I have a patch.

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5f6defa6fe7..e7d16ca0a14 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6742,7 +6742,16 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
        ;
       else if (block == p->orig_block
               || p->orig_block == NULL_TREE)
-       TREE_SET_BLOCK (t, p->new_block);
+       {
+         /* tree_node_can_be_shared says we can share invariant
+            addresses but unshare_expr copies them anyways.  Make sure
+            to unshare before adjusting the block in place - we do not
+            always see a copy here.  */
+         if (TREE_CODE (t) == ADDR_EXPR
+             && is_gimple_min_invariant (t))
+           *tp = t = unshare_expr (t);
+         TREE_SET_BLOCK (t, p->new_block);
+       }
       else if (flag_checking)
        {
          while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
Comment 6 Richard Biener 2018-06-15 07:25:46 UTC
Author: rguenth
Date: Fri Jun 15 07:25:13 2018
New Revision: 261620

URL: https://gcc.gnu.org/viewcvs?rev=261620&root=gcc&view=rev
Log:
2018-06-15  Richard Biener  <rguenther@suse.de>

	PR middle-end/86076
	* tree-cfg.c (move_stmt_op): unshare invariant addresses
	before adjusting their block.

	* gcc.dg/pr86076.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/pr86076.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
Comment 7 Wilco 2018-06-18 12:17:43 UTC
Author: wilco
Date: Mon Jun 18 12:17:10 2018
New Revision: 261699

URL: https://gcc.gnu.org/viewcvs?rev=261699&root=gcc&view=rev
Log:
[testsuite] Add target pthread to pr86076.c

Add missing target pthread to ensure test doesn't fail on bare-metal
targets. Committed as obvious.

    testsuite/
	PR tree-optimization/86076
	* gcc.dg/pr86076.c: Add target pthread for bare-metal targets.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/pr86076.c
Comment 8 Richard Biener 2018-07-16 11:02:25 UTC
Author: rguenth
Date: Mon Jul 16 11:01:48 2018
New Revision: 262690

URL: https://gcc.gnu.org/viewcvs?rev=262690&root=gcc&view=rev
Log:
2018-07-16  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2018-07-13  Richard Biener  <rguenther@suse.de>

	PR middle-end/85974
	* match.pd (addr1 - addr2): Allow either of the operand to
	have a conversion.

	* gcc.c-torture/compile/930326-1.c: Adjust to cover widening.

	2018-06-15  Richard Biener  <rguenther@suse.de>

	PR middle-end/86076
	* tree-cfg.c (move_stmt_op): unshare invariant addresses
	before adjusting their block.

	* gcc.dg/pr86076.c: New testcase.

	2018-06-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/85935
	* graphite-scop-detection.c (find_params_in_bb): Analyze
	condition operands with respect to the correct loop.  Assert
	the analysis doesn't fail.

	* gcc.dg/graphite/pr85935.c: New testcase.

Added:
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/graphite/pr85935.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr86076.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/graphite-scop-detection.c
    branches/gcc-8-branch/gcc/match.pd
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
    branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/compile/930326-1.c
    branches/gcc-8-branch/gcc/tree-cfg.c
Comment 9 Richard Biener 2018-11-26 11:59:22 UTC
Fixed.
Comment 10 Richard Biener 2018-11-26 11:59:37 UTC
Author: rguenth
Date: Mon Nov 26 11:59:05 2018
New Revision: 266458

URL: https://gcc.gnu.org/viewcvs?rev=266458&root=gcc&view=rev
Log:
2018-11-26  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2018-06-14  Richard Biener  <rguenther@suse.de>

	PR middle-end/86139
	* tree-vect-generic.c (build_word_mode_vector_type): Remove
	duplicate and harmful type_hash_canon.

	2018-06-15  Richard Biener  <rguenther@suse.de>

	PR middle-end/86076
	* tree-cfg.c (move_stmt_op): unshare invariant addresses
	before adjusting their block.

	* gcc.dg/pr86076.c: New testcase.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/pr86076.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/tree-cfg.c
    branches/gcc-7-branch/gcc/tree-vect-generic.c