Bug 38153 - ICE in testcase when compiled with -ftree-parallelize-loops
Summary: ICE in testcase when compiled with -ftree-parallelize-loops
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
: 38154 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-16 10:08 UTC by razya
Modified: 2017-11-26 18:41 UTC (History)
7 users (show)

See Also:
Host: powerpc64*-*-linux
Target: powerpc64*-*-linux
Build: powerpc64*-*-linux
Known to work: 5.5.0, 6.4.1, 7.2.1, 8.0
Known to fail: 4.9.3, 5.1.0, 5.4.0, 6.1.0, 6.4.0, 7.1.0, 7.2.0
Last reconfirmed: 2008-12-28 18:24:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description razya 2008-11-16 10:08:19 UTC
when compiling :
/Develop/mainline_parallel/gcc/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c -w -O1 -ftree-parallelize-loops=4 
We get compiler error during verify_flow_info
comp-goto-1.c:57: error: label 
sim_base_addr has incorrect context in bb 8

The context for sim_base_addr is the new outlined function, simulator_kernel._loopfn.0 and not simulator_kernel as expected.

while
Comment 1 Volker Reichelt 2008-12-28 18:24:47 UTC
Confirmed. Shorter testcase that crashes with "-O -ftree-parallelize-loops=2"
(on i686-pc-linux-gnu):

=============================
void foo(int n, void** p)
{
  int i;
  for (i = 0; i < n; ++i)
    p[i] = &&L;

  L: goto **p;
}
=============================

The crash happens since GCC 4.3.0 where -ftree-parallelize-loops was
introduced.
Comment 2 Volker Reichelt 2008-12-28 18:40:10 UTC
Btw, the error message is a little hosed:

bug.c: In function 'foo':
bug.c:2: error: label 
L has incorrect context in bb 8bug.c:7: internal compiler error: verify_flow_info failed
Please submit a full bug report, [etc.]

It looks like most of the fprintf statements in gimple_verify_flow_info
lack a trailing "\n".
Comment 3 Volker Reichelt 2008-12-29 03:34:19 UTC
*** Bug 38154 has been marked as a duplicate of this bug. ***
Comment 4 Zdenek Sojka 2010-10-20 14:52:32 UTC
A bit different testcase, crashes on x86_64-pc-linux-gnu, r165719

----- testcase.c -----
void
foo (void **a, int i)
{
  while (i--)
    a[i] = &&label;
label:;
}
----------------------

$ gcc -O -ftree-parallelize-loops=2 testcase.c
testcase.c: In function 'foo':
testcase.c:2:1: error: label 
label has incorrect context in bb 6testcase.c:2:1: internal compiler error: verify_flow_info failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

-ftree-parallelize-loops=N, crashes for N>=2
Comment 5 Martin Sebor 2016-01-19 22:41:58 UTC
Still fails with the latest trunk on both powerpc64 and powerpc64le:

$ cat a.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -O -Wall -ftree-parallelize-loops=2 a.c
void foo(int n, void** p)
{
  int i;
  for (i = 0; i < n; ++i)
    p[i] = &&L;

  L: goto **p;
}
a.c: In function ‘foo’:
a.c:1:6: error: label 
 void foo(int n, void** p)
      ^~~

L has incorrect context in bb 9a.c:1:6: internal compiler error: verify_flow_info failed
0x1055b0fb verify_flow_info()
	/src/gcc-trunk/gcc/cfghooks.c:260
0x10d7ec33 checking_verify_flow_info
	/src/gcc-trunk/gcc/cfghooks.h:198
0x10d81a87 cleanup_tree_cfg_noloop
	/src/gcc-trunk/gcc/tree-cfgcleanup.c:766
0x10d81bd3 cleanup_tree_cfg()
	/src/gcc-trunk/gcc/tree-cfgcleanup.c:812
0x10af0f47 execute_expand_omp
	/src/gcc-trunk/gcc/omp-low.c:13929
0x10af120f execute
	/src/gcc-trunk/gcc/omp-low.c:14012
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 6 Volker Reichelt 2017-11-26 18:41:44 UTC
This was fixed with Jakub's patch for PR81867 which was applied to trunk and the GCC 7, GCC 6, and GCC 5 branches:

https://gcc.gnu.org/ml/gcc-cvs/2017-08/msg00266.html

Author: jakub
Date: Thu Aug 10 00:33:20 2017
New Revision: 251019

URL: https://gcc.gnu.org/viewcvs?rev=251019&root=gcc&view=rev
Log:
	PR c/81687
	* omp-low.c (omp_copy_decl): Don't remap FORCED_LABEL or DECL_NONLOCAL
	LABEL_DECLs.
	* tree-cfg.c (move_stmt_op): Don't adjust DECL_CONTEXT of FORCED_LABEL
	or DECL_NONLOCAL labels.
	(move_stmt_r) <case GIMPLE_LABEL>: Adjust DECL_CONTEXT of FORCED_LABEL
	or DECL_NONLOCAL labels here.

	* testsuite/libgomp.c/pr81687-1.c: New test.
	* testsuite/libgomp.c/pr81687-2.c: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c/pr81687-1.c
    trunk/libgomp/testsuite/libgomp.c/pr81687-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/tree-cfg.c
    trunk/libgomp/ChangeLog


Jakub, do you want to add the testcase from comment #1 to the testsuite (which fails more reliably than the original testcase or the testcase from comment #4  at least on x86_64-pc-linux-gnu). Or do you think the testcases you added are sufficient?