From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 318503839805; Wed, 11 May 2022 06:24:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 318503839805 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-10129] openmp: Make finalize_task_copyfn order reproduceable [PR104517] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 87cd4bc02f602226922e6c8099a2f4687664bed9 X-Git-Newrev: 57e0795a44639d1cc84abbdd46c507cc64dfa2f8 Message-Id: <20220511062452.318503839805@sourceware.org> Date: Wed, 11 May 2022 06:24:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2022 06:24:52 -0000 https://gcc.gnu.org/g:57e0795a44639d1cc84abbdd46c507cc64dfa2f8 commit r9-10129-g57e0795a44639d1cc84abbdd46c507cc64dfa2f8 Author: Jakub Jelinek Date: Tue Feb 15 10:22:30 2022 +0100 openmp: Make finalize_task_copyfn order reproduceable [PR104517] The following testcase fails -fcompare-debug, because finalize_task_copyfn was invoked from splay tree destruction, whose order can in some cases depend on -g/-g0. The fix is to queue the task stmts that need copyfn in a vector and run finalize_task_copyfn on elements of that vector. 2022-02-15 Jakub Jelinek PR debug/104517 * omp-low.c (task_cpyfns): New variable. (delete_omp_context): Don't call finalize_task_copyfn from here. (create_task_copyfn): Push task_stmt into task_cpyfns. (execute_lower_omp): Call finalize_task_copyfn here on entries from task_cpyfns vector and release the vector. (cherry picked from commit 6a0d6e7ca9b9e338e82572db79c26168684a7441) Diff: --- gcc/omp-low.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 0b79500ca2c..23ef347657a 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -141,6 +141,7 @@ static int target_nesting_level; static bitmap task_shared_vars; static bitmap global_nonaddressable_vars; static vec taskreg_contexts; +static vec task_cpyfns; static void scan_omp (gimple_seq *, omp_context *); static tree scan_omp_1_op (tree *, int *, void *); @@ -980,9 +981,6 @@ delete_omp_context (splay_tree_value value) DECL_ABSTRACT_ORIGIN (t) = NULL; } - if (is_task_ctx (ctx)) - finalize_task_copyfn (as_a (ctx->stmt)); - if (ctx->task_reduction_map) { ctx->task_reductions.release (); @@ -8648,6 +8646,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) size_t looptempno = 0; child_fn = gimple_omp_task_copy_fn (task_stmt); + task_cpyfns.safe_push (task_stmt); child_cfun = DECL_STRUCT_FUNCTION (child_fn); gcc_assert (child_cfun->cfg == NULL); DECL_SAVED_TREE (child_fn) = alloc_stmt_list (); @@ -10724,6 +10723,12 @@ execute_lower_omp (void) && (TREE_CODE (TREE_TYPE (DECL_ARGUMENTS (current_function_decl))) == POINTER_TYPE)) remove_member_access_dummy_vars (DECL_INITIAL (current_function_decl)); + + gomp_task *task_stmt; + unsigned j; + FOR_EACH_VEC_ELT (task_cpyfns, j, task_stmt) + finalize_task_copyfn (task_stmt); + task_cpyfns.release (); return 0; }