* [committed] Avoid some -Wuninitialized OpenMP false positives (PR middle-end/72781)
@ 2016-08-08 19:55 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2016-08-08 19:55 UTC (permalink / raw)
To: gcc-patches
Hi!
The control structure is too hard to understand in certain cases for the
uninit pass - the test for the last iteration compares against a specific
value, while in the loop it tests for the particular assigned chunks.
So, this patch marks the private vars for lastprivate or for simd linear
iterators as TREE_NO_WARNING.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
2016-08-08 Jakub Jelinek <jakub@redhat.com>
PR middle-end/72781
* omp-low.c (lower_lastprivate_clauses): Set TREE_NO_WARNING on the
private vars for lastprivate and for linear iterator.
* gcc.dg/gomp/pr72781.c: New test.
--- gcc/omp-low.c.jj 2016-07-21 18:11:00.000000000 +0200
+++ gcc/omp-low.c 2016-08-08 14:21:30.319798379 +0200
@@ -5455,7 +5455,15 @@ lower_lastprivate_clauses (tree clauses,
new_var = lookup_decl (var, ctx->outer);
}
else
- new_var = lookup_decl (var, ctx);
+ {
+ new_var = lookup_decl (var, ctx);
+ /* Avoid uninitialized warnings for lastprivate and
+ for linear iterators. */
+ if (predicate
+ && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
+ || OMP_CLAUSE_LINEAR_NO_COPYIN (c)))
+ TREE_NO_WARNING (new_var) = 1;
+ }
if (simduid && DECL_HAS_VALUE_EXPR_P (new_var))
{
--- gcc/testsuite/gcc.dg/gomp/pr72781.c.jj 2016-08-08 14:27:09.481617344 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr72781.c 2016-08-08 14:27:50.582110675 +0200
@@ -0,0 +1,23 @@
+/* PR middle-end/72781 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -Wuninitialized" } */
+
+int u;
+
+void
+foo (int *p)
+{
+ int i;
+ #pragma omp for simd lastprivate(u) schedule (static, 32) /* { dg-bogus "may be used uninitialized in this function" } */
+ for (i = 0; i < 1024; i++)
+ u = p[i];
+}
+
+void
+bar (int *p)
+{
+ int i;
+ #pragma omp taskloop simd lastprivate(u) /* { dg-bogus "may be used uninitialized in this function" } */
+ for (i = 0; i < 1024; i++)
+ u = p[i];
+}
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-08 19:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08 19:55 [committed] Avoid some -Wuninitialized OpenMP false positives (PR middle-end/72781) Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).