re PR middle-end/70550 (-Wuninitialized false positives in OpenMP code)
PR middle-end/70550 * tree.h (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT): Define. * gimplify.c (gimplify_adjust_omp_clauses_1): Set it for implicit firstprivate clauses. * omp-low.c (lower_send_clauses): Set TREE_NO_WARNING for OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT !by_ref vars in task contexts. (lower_omp_target): Set TREE_NO_WARNING for non-addressable possibly uninitialized vars which are copied into addressable temporaries or copied for GOMP_MAP_FIRSTPRIVATE_INT. * c-c++-common/gomp/pr70550-1.c: New test. * c-c++-common/gomp/pr70550-2.c: New test. From-SVN: r234779
This commit is contained in:
parent
ce043b0c1c
commit
ec35ea455c
@ -1,3 +1,15 @@
|
|||||||
|
2016-04-06 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR middle-end/70550
|
||||||
|
* tree.h (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT): Define.
|
||||||
|
* gimplify.c (gimplify_adjust_omp_clauses_1): Set it for implicit
|
||||||
|
firstprivate clauses.
|
||||||
|
* omp-low.c (lower_send_clauses): Set TREE_NO_WARNING for
|
||||||
|
OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT !by_ref vars in task contexts.
|
||||||
|
(lower_omp_target): Set TREE_NO_WARNING for
|
||||||
|
non-addressable possibly uninitialized vars which are copied into
|
||||||
|
addressable temporaries or copied for GOMP_MAP_FIRSTPRIVATE_INT.
|
||||||
|
|
||||||
2016-04-05 John David Anglin <danglin@gcc.gnu.org>
|
2016-04-05 John David Anglin <danglin@gcc.gnu.org>
|
||||||
|
|
||||||
* config/pa/predicates.md (integer_store_memory_operand): Accept
|
* config/pa/predicates.md (integer_store_memory_operand): Accept
|
||||||
|
@ -7742,6 +7742,8 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
|
|||||||
&& (flags & GOVD_WRITTEN) == 0
|
&& (flags & GOVD_WRITTEN) == 0
|
||||||
&& omp_shared_to_firstprivate_optimizable_decl_p (decl))
|
&& omp_shared_to_firstprivate_optimizable_decl_p (decl))
|
||||||
OMP_CLAUSE_SHARED_READONLY (clause) = 1;
|
OMP_CLAUSE_SHARED_READONLY (clause) = 1;
|
||||||
|
else if (code == OMP_CLAUSE_FIRSTPRIVATE && (flags & GOVD_EXPLICIT) == 0)
|
||||||
|
OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (clause) = 1;
|
||||||
else if (code == OMP_CLAUSE_MAP && (flags & GOVD_MAP_0LEN_ARRAY) != 0)
|
else if (code == OMP_CLAUSE_MAP && (flags & GOVD_MAP_0LEN_ARRAY) != 0)
|
||||||
{
|
{
|
||||||
tree nc = build_omp_clause (input_location, OMP_CLAUSE_MAP);
|
tree nc = build_omp_clause (input_location, OMP_CLAUSE_MAP);
|
||||||
|
@ -6107,8 +6107,15 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist,
|
|||||||
|
|
||||||
switch (OMP_CLAUSE_CODE (c))
|
switch (OMP_CLAUSE_CODE (c))
|
||||||
{
|
{
|
||||||
case OMP_CLAUSE_PRIVATE:
|
|
||||||
case OMP_CLAUSE_FIRSTPRIVATE:
|
case OMP_CLAUSE_FIRSTPRIVATE:
|
||||||
|
if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
|
||||||
|
&& !by_ref
|
||||||
|
&& is_task_ctx (ctx))
|
||||||
|
TREE_NO_WARNING (var) = 1;
|
||||||
|
do_in = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OMP_CLAUSE_PRIVATE:
|
||||||
case OMP_CLAUSE_COPYIN:
|
case OMP_CLAUSE_COPYIN:
|
||||||
case OMP_CLAUSE__LOOPTEMP_:
|
case OMP_CLAUSE__LOOPTEMP_:
|
||||||
do_in = true;
|
do_in = true;
|
||||||
@ -16083,7 +16090,16 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
|
|||||||
|| map_kind == GOMP_MAP_POINTER
|
|| map_kind == GOMP_MAP_POINTER
|
||||||
|| map_kind == GOMP_MAP_TO_PSET
|
|| map_kind == GOMP_MAP_TO_PSET
|
||||||
|| map_kind == GOMP_MAP_FORCE_DEVICEPTR)
|
|| map_kind == GOMP_MAP_FORCE_DEVICEPTR)
|
||||||
gimplify_assign (avar, var, &ilist);
|
{
|
||||||
|
/* If we need to initialize a temporary
|
||||||
|
with VAR because it is not addressable, and
|
||||||
|
the variable hasn't been initialized yet, then
|
||||||
|
we'll get a warning for the store to avar.
|
||||||
|
Don't warn in that case, the mapping might
|
||||||
|
be implicit. */
|
||||||
|
TREE_NO_WARNING (var) = 1;
|
||||||
|
gimplify_assign (avar, var, &ilist);
|
||||||
|
}
|
||||||
avar = build_fold_addr_expr (avar);
|
avar = build_fold_addr_expr (avar);
|
||||||
gimplify_assign (x, avar, &ilist);
|
gimplify_assign (x, avar, &ilist);
|
||||||
if ((GOMP_MAP_COPY_FROM_P (map_kind)
|
if ((GOMP_MAP_COPY_FROM_P (map_kind)
|
||||||
@ -16252,6 +16268,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
|
|||||||
tree t = var;
|
tree t = var;
|
||||||
if (is_reference (var))
|
if (is_reference (var))
|
||||||
t = build_simple_mem_ref (var);
|
t = build_simple_mem_ref (var);
|
||||||
|
else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
|
||||||
|
TREE_NO_WARNING (var) = 1;
|
||||||
if (TREE_CODE (type) != POINTER_TYPE)
|
if (TREE_CODE (type) != POINTER_TYPE)
|
||||||
t = fold_convert (pointer_sized_int_node, t);
|
t = fold_convert (pointer_sized_int_node, t);
|
||||||
t = fold_convert (TREE_TYPE (x), t);
|
t = fold_convert (TREE_TYPE (x), t);
|
||||||
@ -16263,6 +16281,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
|
|||||||
{
|
{
|
||||||
tree avar = create_tmp_var (TREE_TYPE (var));
|
tree avar = create_tmp_var (TREE_TYPE (var));
|
||||||
mark_addressable (avar);
|
mark_addressable (avar);
|
||||||
|
if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
|
||||||
|
TREE_NO_WARNING (var) = 1;
|
||||||
gimplify_assign (avar, var, &ilist);
|
gimplify_assign (avar, var, &ilist);
|
||||||
avar = build_fold_addr_expr (avar);
|
avar = build_fold_addr_expr (avar);
|
||||||
gimplify_assign (x, avar, &ilist);
|
gimplify_assign (x, avar, &ilist);
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2016-04-06 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR middle-end/70550
|
||||||
|
* c-c++-common/gomp/pr70550-1.c: New test.
|
||||||
|
* c-c++-common/gomp/pr70550-2.c: New test.
|
||||||
|
|
||||||
2016-04-05 Nathan Sidwell <nathan@acm.org>
|
2016-04-05 Nathan Sidwell <nathan@acm.org>
|
||||||
|
|
||||||
PR c++/70512
|
PR c++/70512
|
||||||
|
81
gcc/testsuite/c-c++-common/gomp/pr70550-1.c
Normal file
81
gcc/testsuite/c-c++-common/gomp/pr70550-1.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/* PR middle-end/70550 */
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-additional-options "-Wuninitialized" } */
|
||||||
|
|
||||||
|
#ifdef __SIZEOF_INT128__
|
||||||
|
typedef __int128 T;
|
||||||
|
#else
|
||||||
|
typedef long long T;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void bar (T);
|
||||||
|
#pragma omp declare target (bar)
|
||||||
|
|
||||||
|
void
|
||||||
|
foo (void)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
#pragma omp target defaultmap(tofrom:scalar) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
i = 26;
|
||||||
|
bar (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
T j;
|
||||||
|
#pragma omp target defaultmap(tofrom:scalar) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
j = 37;
|
||||||
|
bar (j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
#pragma omp target /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
i = 26;
|
||||||
|
bar (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
T j;
|
||||||
|
#pragma omp target /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
j = 37;
|
||||||
|
bar (j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
#pragma omp target firstprivate (i) /* { dg-warning "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
i = 26;
|
||||||
|
bar (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
T j;
|
||||||
|
#pragma omp target firstprivate (j) /* { dg-warning "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
j = 37;
|
||||||
|
bar (j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
#pragma omp target private (i) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
i = 26;
|
||||||
|
bar (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
T j;
|
||||||
|
#pragma omp target private (j) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
j = 37;
|
||||||
|
bar (j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
gcc/testsuite/c-c++-common/gomp/pr70550-2.c
Normal file
55
gcc/testsuite/c-c++-common/gomp/pr70550-2.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* PR middle-end/70550 */
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-additional-options "-Wuninitialized" } */
|
||||||
|
|
||||||
|
void bar (int);
|
||||||
|
|
||||||
|
void
|
||||||
|
foo (void)
|
||||||
|
{
|
||||||
|
int i, j, k, l, m, n, o, p, q;
|
||||||
|
#pragma omp task /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
i = 2;
|
||||||
|
bar (i);
|
||||||
|
}
|
||||||
|
#pragma omp taskloop /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
for (j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
k = 7;
|
||||||
|
bar (k);
|
||||||
|
}
|
||||||
|
#pragma omp task firstprivate (l) /* { dg-warning "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
l = 2;
|
||||||
|
bar (l);
|
||||||
|
}
|
||||||
|
#pragma omp taskloop firstprivate (m) /* { dg-warning "is used uninitialized in this function" } */
|
||||||
|
for (j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
m = 7;
|
||||||
|
bar (m);
|
||||||
|
}
|
||||||
|
#pragma omp task shared (n) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
n = 2;
|
||||||
|
bar (n);
|
||||||
|
}
|
||||||
|
#pragma omp taskloop shared (o) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
for (j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
o = 7;
|
||||||
|
bar (o);
|
||||||
|
}
|
||||||
|
#pragma omp task private (p) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
{
|
||||||
|
p = 2;
|
||||||
|
bar (p);
|
||||||
|
}
|
||||||
|
#pragma omp taskloop shared (q) /* { dg-bogus "is used uninitialized in this function" } */
|
||||||
|
for (j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
q = 7;
|
||||||
|
bar (q);
|
||||||
|
}
|
||||||
|
}
|
@ -1430,6 +1430,10 @@ extern void protected_set_expr_location (tree, location_t);
|
|||||||
#define OMP_CLAUSE_PRIVATE_TASKLOOP_IV(NODE) \
|
#define OMP_CLAUSE_PRIVATE_TASKLOOP_IV(NODE) \
|
||||||
TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
|
TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
|
||||||
|
|
||||||
|
/* True on a FIRSTPRIVATE clause if it has been added implicitly. */
|
||||||
|
#define OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT(NODE) \
|
||||||
|
(OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FIRSTPRIVATE)->base.public_flag)
|
||||||
|
|
||||||
/* True on a LASTPRIVATE clause if a FIRSTPRIVATE clause for the same
|
/* True on a LASTPRIVATE clause if a FIRSTPRIVATE clause for the same
|
||||||
decl is present in the chain. */
|
decl is present in the chain. */
|
||||||
#define OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE(NODE) \
|
#define OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE(NODE) \
|
||||||
|
Loading…
Reference in New Issue
Block a user