Bug 52547 - [4.6 Regression] ICE with openmp with nested function which requires a trampoline
Summary: [4.6 Regression] ICE with openmp with nested function which requires a trampo...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.1
: P2 normal
Target Milestone: 4.6.4
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2012-03-09 20:57 UTC by Rohit Banga
Modified: 2013-04-03 18:16 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.5
Known to fail: 4.4.0, 4.6.3, 4.7.0
Last reconfirmed: 2012-03-12 00:00:00


Attachments
Preprocessed Source (28.63 KB, application/octet-stream)
2012-03-09 20:57 UTC, Rohit Banga
Details
gcc47-pr52547.patch (1.02 KB, patch)
2012-03-22 15:04 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rohit Banga 2012-03-09 20:57:49 UTC
Created attachment 26868 [details]
Preprocessed Source

I get the following error when trying to compile a piece of software. Commenting out the call to qsort in the original source file (the corresponding line number in the attached preprocessed file is 7176) does not produce any error.

gcc -std=gnu9x -fopenmp   -g -O2 -Iinclude -o main main.c src/stinger.c src/stinger-utils.c src/timer.c src/xmalloc.c \
		 -lm -lrt
src/stinger-utils.c: In function ‘stinger_to_sorted_csr’:
src/stinger-utils.c:450:13: internal compiler error: in create_tmp_var, at gimplify.c:465
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccAzPZP8.out file, please attach this to your bugreport.
make: *** [main] Error 1
Comment 1 Rohit Banga 2012-03-09 21:59:25 UTC
Removing -fopenmp resolves the problem. That piece of information should be helpful in solving the bug.
Comment 2 Richard Biener 2012-03-12 14:07:03 UTC
src/stinger-utils.c:440:7: warning: ISO C forbids nested functions [-pedantic]

so the testcase is probably out-of-scope for OpenMP.  Didn't ever work, so
no regression.
Comment 3 Andrew Pinski 2012-03-15 09:27:32 UTC
Reduced testcase:
stinger_to_sorted_csr ( const int nv )
{
  int * vtxids;
  int i;
#pragma omp parallel for
    for (i = 0; i < nv; ++i) 
    {
      int i64cmp_local (const int *ap)
      {
	return ap - vtxids;
      }
      f (&vtxids[i], i64cmp_local);
    }
}
Comment 4 Andrew Pinski 2012-03-15 09:31:31 UTC
This used to work in 4.3.5.  The reason why it worked there is because __builtin_adjust_trampoline is outside of the "#pragma omp".
Comment 5 Jakub Jelinek 2012-03-22 15:04:00 UTC
Created attachment 26957 [details]
gcc47-pr52547.patch

Untested fix.  Note the nested fn in OpenMP is only barely supported, it will very likely not do what you expect (the nested function will be accessing the copy of the variables of the function, not the possibly privatized copies of the omp region (as if all the vars were shared), and e.g. non-local gotos in them will not even compile.
Comment 6 Jakub Jelinek 2012-03-22 19:25:44 UTC
Author: jakub
Date: Thu Mar 22 19:25:36 2012
New Revision: 185707

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185707
Log:
	PR middle-end/52547
	* tree-nested.c (convert_tramp_reference_stmt): Call declare_vars
	on any new_local_var_chain vars declared during recursing on
	GIMPLE_OMP_PARALLEL or GIMPLE_OMP_TASK body.

	* testsuite/libgomp.c/pr52547.c: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c/pr52547.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-nested.c
    trunk/libgomp/ChangeLog
Comment 7 Jakub Jelinek 2012-03-22 19:28:01 UTC
Author: jakub
Date: Thu Mar 22 19:27:52 2012
New Revision: 185708

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185708
Log:
	PR middle-end/52547
	* tree-nested.c (convert_tramp_reference_stmt): Call declare_vars
	on any new_local_var_chain vars declared during recursing on
	GIMPLE_OMP_PARALLEL or GIMPLE_OMP_TASK body.

	* testsuite/libgomp.c/pr52547.c: New test.

Added:
    branches/gcc-4_7-branch/libgomp/testsuite/libgomp.c/pr52547.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-nested.c
    branches/gcc-4_7-branch/libgomp/ChangeLog
Comment 8 Jakub Jelinek 2012-03-22 19:43:41 UTC
Fixed for 4.7.1+ so far.
Comment 9 Richard Biener 2012-07-02 11:16:26 UTC
The 4.5 branch is being closed, adjusting target milestone.
Comment 10 Jakub Jelinek 2013-04-03 18:16:22 UTC
Author: jakub
Date: Wed Apr  3 17:52:33 2013
New Revision: 197441

URL: http://gcc.gnu.org/viewcvs?rev=197441&root=gcc&view=rev
Log:
	Backported from mainline
	2012-03-22  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/52547
	* tree-nested.c (convert_tramp_reference_stmt): Call declare_vars
	on any new_local_var_chain vars declared during recursing on
	GIMPLE_OMP_PARALLEL or GIMPLE_OMP_TASK body.

	* testsuite/libgomp.c/pr52547.c: New test.

Added:
    branches/gcc-4_6-branch/libgomp/testsuite/libgomp.c/pr52547.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-nested.c
    branches/gcc-4_6-branch/libgomp/ChangeLog