The following patches have been committed to devel/omp/gcc-12 to fix a bootstrap build of the branch:

29ba2e4eeff Fix mis-merge of 'dwarf: Multi-register CFI address support'
82a3f9f22f7 Build fixes for OG12 on more recent GCC versions
e9ee746093b Fix string formatting issues
b8ecb83d528 Build fix for 'openmp: allow requires unified_shared_memory'

Kwok
From b8ecb83d52884153c2b9b9c44840f933dfaa4dc7 Mon Sep 17 00:00:00 2001
From: Tobias Burnus <tob...@codesourcery.com>
Date: Thu, 30 Jun 2022 08:30:48 +0200
Subject: [PATCH 1/5] Build fix for 'openmp: allow requires
 unified_shared_memory'

OG12 commit fa65fc45972d27f2fd79a44eaba1978348177ee9 added an
error diagnostic (moved around in later commits); this diagnostic
caused bootstrap fails as %<...%> were missing. This commit adds
them.

gcc/c/
        * c-parser.cc (c_parser_omp_requires): Add missing %<...%> in error.

gcc/cp/
        * parser.cc (cp_parser_omp_requires): Add missing %<...%> in error.
---
 gcc/c/c-parser.cc | 8 ++++----
 gcc/cp/parser.cc  | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 363b80ebfeb..5cabcb684e9 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -22872,8 +22872,8 @@ c_parser_omp_requires (c_parser *parser)
              if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
                  && flag_offload_memory != OFFLOAD_MEMORY_NONE)
                error_at (cloc,
-                         "unified_address is incompatible with the "
-                         "selected -foffload-memory option");
+                         "%<unified_address%> is incompatible with the "
+                         "selected %<-foffload-memory%> option");
              flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
            }
          else if (!strcmp (p, "unified_shared_memory"))
@@ -22883,8 +22883,8 @@ c_parser_omp_requires (c_parser *parser)
              if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
                  && flag_offload_memory != OFFLOAD_MEMORY_NONE)
                error_at (cloc,
-                         "unified_shared_memory is incompatible with the "
-                         "selected -foffload-memory option");
+                         "%<unified_shared_memory%> is incompatible with the "
+                         "selected %<-foffload-memory%> option");
              flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
            }
          else if (!strcmp (p, "dynamic_allocators"))
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 563bf4546eb..f8455e30ed8 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -47177,8 +47177,8 @@ cp_parser_omp_requires (cp_parser *parser, cp_token 
*pragma_tok)
              if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
                  && flag_offload_memory != OFFLOAD_MEMORY_NONE)
                error_at (cloc,
-                         "unified_address is incompatible with the "
-                         "selected -foffload-memory option");
+                         "%<unified_address%> is incompatible with the "
+                         "selected %<-foffload-memory%> option");
              flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
            }
          else if (!strcmp (p, "unified_shared_memory"))
@@ -47188,8 +47188,8 @@ cp_parser_omp_requires (cp_parser *parser, cp_token 
*pragma_tok)
              if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
                  && flag_offload_memory != OFFLOAD_MEMORY_NONE)
                error_at (cloc,
-                         "unified_shared_memory is incompatible with the "
-                         "selected -foffload-memory option");
+                         "%<unified_shared_memory%> is incompatible with the "
+                         "selected %<-foffload-memory%> option");
              flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
            }
          else if (!strcmp (p, "dynamic_allocators"))
-- 
2.25.1

From e9ee746093bd989c33685e3197c75b901aef2cc1 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Thu, 30 Jun 2022 15:31:41 +0100
Subject: [PATCH 3/5] Fix string formatting issues

Stricter format-string checking in more recent versions of GCC can cause
build failures.

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * omp-data-optimize.cc (omp_data_optimize_add_candidate): Suppress
        format checking.
        (omp_data_optimize_can_be_private): Likewise.
        (omp_data_optimize_can_be_private): Likewise.

(This should be a fixup to ab53d5a6a27dce2a92f28a62ceb6e184c8356f25: 'openacc:
Add data optimization pass')

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * gimplify.cc (gimplify_scan_omp_clauses): Remove extra
        '%<..%>' pair in format string.

(This should be a fixup to dbc770c4351c8824e8083f8aff6117a6b4ba3c0d: 'openmp:
Implement uses_allocators clause')
---
 gcc/ChangeLog.omp        | 12 ++++++++++++
 gcc/gimplify.cc          |  2 +-
 gcc/omp-data-optimize.cc | 28 ++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 29740139fd2..1455a9605c2 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,15 @@
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * gimplify.cc (gimplify_scan_omp_clauses): Remove extra
+       '%<..%>' pair in format string.
+
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * omp-data-optimize.cc (omp_data_optimize_add_candidate): Suppress
+       format checking.
+       (omp_data_optimize_can_be_private): Likewise.
+       (omp_data_optimize_can_be_private): Likewise.
+
 2022-05-13  Kwok Cheung Yeung  <k...@codesourcery.com>
 
        * omp-expand.cc (expand_omp_target): Gimplify launch dimensions used
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 8e8151cfc35..e0af57058d8 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -11384,7 +11384,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq 
*pre_p,
                      }
                  if (uc == NULL_TREE)
                    {
-                     error_at (OMP_CLAUSE_LOCATION (c), "allocator %<%qE%> "
+                     error_at (OMP_CLAUSE_LOCATION (c), "allocator %qE "
                                "requires %<uses_allocators(%E)%> clause in "
                                "target region", allocator, allocator);
                      remove = true;
diff --git a/gcc/omp-data-optimize.cc b/gcc/omp-data-optimize.cc
index 31f615c1d2b..a64f933b2d4 100644
--- a/gcc/omp-data-optimize.cc
+++ b/gcc/omp-data-optimize.cc
@@ -154,6 +154,10 @@ omp_data_optimize_add_candidate (const 
dump_user_location_t &loc, tree var,
   inhibit_descriptor in;
   in.stmt = NULL;
 
+#if __GNUC__ >= 10
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat"
+#endif
   if (DECL_EXTERNAL (var))
     {
       if (dump_enabled_p () && dump_flags & TDF_DETAILS)
@@ -187,6 +191,9 @@ omp_data_optimize_add_candidate (const dump_user_location_t 
&loc, tree var,
 
       in.kind = INHIBIT_NOT;
     }
+#if __GNUC__ >= 10
+# pragma GCC diagnostic pop
+#endif
 
   if (state->candidates.put (var, in))
     gcc_unreachable ();
@@ -575,6 +582,10 @@ omp_data_optimize_can_be_private (tree var, gimple 
*target_stmt)
       state.bb = *state.scanned_bb.get (root_id);
     }
 
+#if __GNUC__ >= 10
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat"
+#endif
   if (dump_enabled_p () && dump_flags & TDF_DETAILS)
     {
       for (hash_map<const void*,ODO_BB>::iterator it = state.scanned_bb.begin 
();
@@ -613,6 +624,9 @@ omp_data_optimize_can_be_private (tree var, gimple 
*target_stmt)
                      : state.bb.access == ACCESS_UNKNOWN
                      ? "complex control flow"
                      : "unknown reason"));
+#if __GNUC__ >= 10
+# pragma GCC diagnostic pop
+#endif
 
   return state.bb.access == ACCESS_DEF_FIRST;
 }
@@ -698,12 +712,19 @@ omp_data_optimize_stmt_target (gimple *stmt, ODO_State 
*state)
         if (!id) {
           /* The variable was not a parameter or named in any bind, so it
              must be in an external scope, and therefore live-on-exit.  */
+#if __GNUC__ >= 10
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat"
+#endif
           if (dump_enabled_p ())
             dump_printf_loc(MSG_MISSED_OPTIMIZATION, DUMP_LOC (*pc),
                             "%qs not optimized: %<%T%> is unsuitable"
                             " for privatization\n",
                             c_s_prev, var);
           continue;
+#if __GNUC__ >= 10
+# pragma GCC diagnostic pop
+#endif
            }
 
          switch (id->kind)
@@ -746,6 +767,10 @@ omp_data_optimize_stmt_target (gimple *stmt, ODO_State 
*state)
                }
              break;
 
+#if __GNUC__ >= 10
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat"
+#endif
            case INHIBIT_USE:  /* Optimization inhibited by a variable use.  */
              if (dump_enabled_p ())
                {
@@ -776,6 +801,9 @@ omp_data_optimize_stmt_target (gimple *stmt, ODO_State 
*state)
                                   " for privatization\n", c_s_prev, var);
                }
              break;
+#if __GNUC__ >= 10
+# pragma GCC diagnostic pop
+#endif
 
            default:
              gcc_unreachable ();
-- 
2.25.1

From 82a3f9f22f74ddf63aaf65643f4d163d600c7403 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Thu, 30 Jun 2022 16:22:10 +0100
Subject: [PATCH 4/5] Build fixes for OG12 on more recent GCC versions

This fixes a number of minor issues that can cause the build to fail on
recent versions of GCC.

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/fortran/
        * openmp.cc (gfc_resolve_omp_allocate): Initialize tail to NULL.

(This should be a fixup to 491478d12b83e102f72858e8a871a25c951df293: 'Add
parsing support for allocate directive (OpenMP 5.0)')

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * omp-offload.cc (oacc_loop_get_cfg_loop): Cast tail_mark to
        gimple* for dump_printf.
        * tree-scalar-evolution.cc (oacc_ifn_call_extract): Remove
        unused variable 'call'.

(This should be a fixup to 491478d12b83e102f72858e8a871a25c951df293: 'Build
fix for 'openacc: Use Graphite for dependence analysis in "kernels" region')

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * omp-low.cc (usm_transform): Remove unused function argument.

(This should be a fixup to 54c2d861ac62e30ebf34a4e62ee0d55478a742b9: 'Build
fix for 'openmp: Use libgomp memory allocation functions with unified shared
memory')

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * omp-offload.cc (oacc_loop_warn_if_false_independent): Remove extra
        '.' at end of message.

(This should be a fixup to 01e6774b725ffa667efd818a46795189a281addf: 'Build
fix for 'openacc: Warn about "independent" "kernels" loops with
data-dependences')

2022-06-30  Tobias Burnus  <tob...@codesourcery.com>

        gcc/
        * graphite-isl-ast-to-gimple.cc (graphite_oacc_analyze_scop): Update
        arguments of dump_printf.

(This should be a fixup to a7e863fc4d54fb645fef05f01a024250184964bb:
'openacc: Add runtime alias checking for OpenACC kernels')
---
 gcc/ChangeLog.omp                 | 21 +++++++++++++++++++++
 gcc/fortran/ChangeLog.omp         |  4 ++++
 gcc/fortran/openmp.cc             |  2 +-
 gcc/graphite-isl-ast-to-gimple.cc |  5 +++--
 gcc/omp-low.cc                    |  2 +-
 gcc/omp-offload.cc                |  4 ++--
 gcc/tree-scalar-evolution.cc      |  2 --
 7 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 1455a9605c2..af922a6cb1e 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,24 @@
+2022-06-30  Tobias Burnus  <tob...@codesourcery.com>
+
+       * graphite-isl-ast-to-gimple.cc (graphite_oacc_analyze_scop): Update
+       arguments of dump_printf.
+
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * omp-offload.cc (oacc_loop_warn_if_false_independent): Remove extra
+       '.' at end of message.
+
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * omp-low.cc (usm_transform): Remove unused function argument.
+
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * omp-offload.cc (oacc_loop_get_cfg_loop): Cast tail_mark to
+       gimple* for dump_printf.
+       * tree-scalar-evolution.cc (oacc_ifn_call_extract): Remove
+       unused variable 'call'.
+
 2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
 
        * gimplify.cc (gimplify_scan_omp_clauses): Remove extra
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 59f47d73b73..63eba462c43 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,7 @@
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * openmp.cc (gfc_resolve_omp_allocate): Initialize tail to NULL.
+
 2022-05-22  Kwok Cheung Yeung  <k...@codesourcery.com>
 
        * trans-array.cc (gfc_conv_array_ref): Update arguments to
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index b6f070bc876..2ff923af9b5 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -10128,7 +10128,7 @@ gfc_resolve_omp_allocate (gfc_code *code, gfc_namespace 
*ns)
   gfc_alloc *al;
   gfc_omp_namelist *n = NULL;
   gfc_omp_namelist *cn = NULL;
-  gfc_omp_namelist *p, *tail;
+  gfc_omp_namelist *p, *tail = NULL;
   gfc_code *cur;
   hash_set<gfc_symbol*> vars;
 
diff --git a/gcc/graphite-isl-ast-to-gimple.cc 
b/gcc/graphite-isl-ast-to-gimple.cc
index 49cbb9d5cfe..2b825bac3d5 100644
--- a/gcc/graphite-isl-ast-to-gimple.cc
+++ b/gcc/graphite-isl-ast-to-gimple.cc
@@ -1781,7 +1781,7 @@ graphite_oacc_analyze_scop (scop_p scop)
                  if (dump_enabled_p () && dump_flags & TDF_DETAILS)
                    dump_printf (MSG_NOTE,
                                 "Runtime alias condition applied to: %G",
-                                goacc_call);
+                                stmt);
                }
            }
        }
@@ -1793,7 +1793,8 @@ graphite_oacc_analyze_scop (scop_p scop)
             nothing much to do here.  */
          if (dump_enabled_p ())
            dump_printf (MSG_NOTE, "Runtime alias check *not* inserted for"
-                        " bb %d (GOACC_LOOP not found)");
+                        " bb %d (GOACC_LOOP not found)",
+                        goacc_loop_block->index);
 
          /* Unset can_be_parallel, in case something else might use it.  */
          for (unsigned int i = 0; i < region->bbs.length (); i++)
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index bd7515d6b78..dc53373cac7 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -16232,7 +16232,7 @@ make_pass_diagnose_omp_blocks (gcc::context *ctxt)
 
 static tree
 usm_transform (gimple_stmt_iterator *gsi_p, bool *,
-              struct walk_stmt_info *wi)
+              struct walk_stmt_info *)
 {
   gimple *stmt = gsi_stmt (*gsi_p);
   /* ompx_unified_shared_mem_alloc is 10.  */
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index b3f534c579d..6656bc48e95 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -1867,7 +1867,7 @@ oacc_loop_get_cfg_loop (oacc_loop *loop)
 
       if (dump_file && (dump_flags & TDF_DETAILS))
        dump_printf (MSG_OPTIMIZED_LOCATIONS | MSG_PRIORITY_INTERNALS, "%G",
-                    tail_mark);
+                    (gimple *) tail_mark);
 
       loop_p mark_cfg_loop = tail_mark->bb->loop_father;
       loop_p current_cfg_loop = mark_cfg_loop;
@@ -2096,7 +2096,7 @@ oacc_loop_warn_if_false_independent (oacc_loop *loop)
   if (!can_be_parallel)
     warning_at (loop->loc, 0,
                 "loop has \"independent\" clause but data dependences were "
-                "found.");
+               "found");
 }
 
 /* Walk the OpenACC loop hierarchy checking and assigning the
diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc
index 3c01bd608f0..8f4099046de 100644
--- a/gcc/tree-scalar-evolution.cc
+++ b/gcc/tree-scalar-evolution.cc
@@ -614,8 +614,6 @@ oacc_call_analyzable_p (tree t)
 tree
 oacc_ifn_call_extract (gimple *stmt)
 {
-  gcall *call = as_a<gcall *> (stmt);
-
   if (oacc_call_analyzable_p (stmt))
     {
       gcc_assert (gimple_call_internal_p (stmt, IFN_GOACC_LOOP));
-- 
2.25.1

From 29ba2e4eeff0381e04a37a3c471c56cd887d2035 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Thu, 30 Jun 2022 16:49:15 +0100
Subject: [PATCH 5/5] Fix mis-merge of 'dwarf: Multi-register CFI address
 support'

This should be a fixup to 13b6c7639cfdca892a3f02b63596b097e1839f38:
'dwarf: Multi-register CFI address support'.

2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>

        gcc/
        * dwarf2cfi.cc (get_cfa_from_loc_descr): Check op against DW_OP_bregx.
---
 gcc/ChangeLog.omp | 4 ++++
 gcc/dwarf2cfi.cc  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index af922a6cb1e..24e22e19ae8 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,7 @@
+2022-06-30  Kwok Cheung Yeung  <k...@codesourcery.com>
+
+       * dwarf2cfi.cc (get_cfa_from_loc_descr): Check op against DW_OP_bregx.
+
 2022-06-30  Tobias Burnus  <tob...@codesourcery.com>
 
        * graphite-isl-ast-to-gimple.cc (graphite_oacc_analyze_scop): Update
diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
index 8d52622a4cb..1359280f519 100644
--- a/gcc/dwarf2cfi.cc
+++ b/gcc/dwarf2cfi.cc
@@ -626,7 +626,7 @@ get_cfa_from_loc_descr (dw_cfa_location *cfa, struct 
dw_loc_descr_node *loc)
                = (op == DW_OP_bregx
                   ? ptr->dw_loc_oprnd1.v.val_int : op - DW_OP_breg0);
              cfa->reg.set_by_dwreg (regno);
-             cfa->base_offset = (DW_OP_bregx
+             cfa->base_offset = (op == DW_OP_bregx
                                  ? ptr->dw_loc_oprnd2.v.val_int
                                  : ptr->dw_loc_oprnd1.v.val_int);
            }
-- 
2.25.1

Reply via email to