Bug 91216 - [9 Regression] OpenMP ICE starting with r265930
Summary: [9 Regression] OpenMP ICE starting with r265930
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 9.1.1
: P3 normal
Target Milestone: 9.2
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-20 08:15 UTC by Jakub Jelinek
Modified: 2019-08-01 06:32 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-07-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2019-07-20 08:15:37 UTC
int r;

void
foo (int *a)
{
  int i;
  #pragma omp for reduction(+:r)
  for (i = 0; i < 64; i++)
    a[i] = i;
  #pragma omp for private (r)
  for (i = 0; i < 64; i++)
    {
      r = 0;
      #pragma omp parallel shared(r)
      #pragma omp master
      r = r + 1;
    }
}

ICEs with -fopenmp starting with r265930, most likely due to the  	 be passing an address in this case?  Should we simply assert
 	 this to be false, or should we have a cleanup pass that removes
 	 these from the list of mappings?  */
-      if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
+      if (is_global_var (maybe_lookup_decl_in_outer_ctx (decl, shared_ctx)))
 	return true;
 
       /* For variables with DECL_HAS_VALUE_EXPR_P set, we cannot tell
omp-low.c hunk.
r is a global decl, initially not TREE_ADDRESSABLE and turned into TREE_ADDRESSABLE during the reduction handling of the first worksharing loop,
which means that the scaning of the parallel clauses and later lowering disagree on whether shared(r) is passed by reference or through copy-in/out.
Comment 1 Jakub Jelinek 2019-07-30 07:28:53 UTC
Author: jakub
Date: Tue Jul 30 07:28:22 2019
New Revision: 273898

URL: https://gcc.gnu.org/viewcvs?rev=273898&root=gcc&view=rev
Log:
	PR middle-end/91216
	* omp-low.c (global_nonaddressable_vars): New variable.
	(use_pointer_for_field): For global decls, if they are non-addressable,
	remember it in the global_nonaddressable_vars bitmap, if they are
	addressable and in the global_nonaddressable_vars bitmap, ignore their
	TREE_ADDRESSABLE bit.
	(omp_copy_decl_2): Clear TREE_ADDRESSABLE also on private copies of
	vars in global_nonaddressable_vars bitmap.
	(execute_lower_omp): Free global_nonaddressable_vars bitmap.

	* gcc.dg/gomp/pr91216.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/gomp/pr91216.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jakub Jelinek 2019-08-01 06:30:58 UTC
Author: jakub
Date: Thu Aug  1 06:30:26 2019
New Revision: 273965

URL: https://gcc.gnu.org/viewcvs?rev=273965&root=gcc&view=rev
Log:
	Backported from mainline
	2019-07-30  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/91216
	* omp-low.c (global_nonaddressable_vars): New variable.
	(use_pointer_for_field): For global decls, if they are non-addressable,
	remember it in the global_nonaddressable_vars bitmap, if they are
	addressable and in the global_nonaddressable_vars bitmap, ignore their
	TREE_ADDRESSABLE bit.
	(omp_copy_decl_2): Clear TREE_ADDRESSABLE also on private copies of
	vars in global_nonaddressable_vars bitmap.
	(execute_lower_omp): Free global_nonaddressable_vars bitmap.

	* gcc.dg/gomp/pr91216.c: New test.

Added:
    branches/gcc-9-branch/gcc/testsuite/gcc.dg/gomp/pr91216.c
Modified:
    branches/gcc-9-branch/gcc/ChangeLog
    branches/gcc-9-branch/gcc/omp-low.c
    branches/gcc-9-branch/gcc/testsuite/ChangeLog
Comment 3 Jakub Jelinek 2019-08-01 06:32:50 UTC
Fixed.