https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86539
Bug ID: 86539
Summary: OpenMP wrong-code with taskloop and references
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
int a[384];
__attribute__((noipa)) void
foo (int &b, int &c)
{
#pragma omp taskloop shared (a) collapse(3)
for (int i = 0; i < 1; i++)
for (int *p = &b; p < &c; p++)
for (int j = 0; j < 1; j++)
if (p < &a[128] || p >= &a[256])
__builtin_abort ();
else
p[0]++;
}
int
main ()
{
#pragma omp parallel
#pragma omp single
foo (a[128], a[256]);
for (int i = 0; i < 384; i++)
if (a[i] != (i >= 128 && i < 256))
__builtin_abort ();
return 0;
}
is miscompiled with -fopenmp. It internally wants to firstprivatize a few
temporaries, but as reference to pointer conversions are considered useless
during gimplification and later, the temporaries that are created for it have
reference type rather than pointer type. Firstprivate clause with reference
type decls is handled by creating a new decl for what it points to as well as
the reference (pointer), rather than just privatizing the reference (pointer)
itself.