diff mbox

[gomp4,committed,8/9] Release_defs in expand_omp_atomic_fetch_op

Message ID 563B3CBA.1080605@mentor.com
State New
Headers show

Commit Message

Tom de Vries Nov. 5, 2015, 11:25 a.m. UTC
On 05/11/15 11:16, Tom de Vries wrote:
> Hi,
>
> now that we have committed -foffload-alias in gomp-4_0-branch (
> https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00214.html ), we no longer
> need the kernels region to be a part of the original function when doing
> alias analysis.
>
> So, we no longer have the need to postpone splitting off the kernels
> region into a seperate function until after alias analysis, but we can
> do this at the same time as when we expand the parallel region.
>
> The following patch series implements that:
>
>       1    Move expansion of kernels region back to first omp-expand
>       2    Update gate_oacc_kernels to handle oacc function
>       3    Revert "Add skip_stmt parm to pass_dominator::get_sese ()"
>       4    Revert "Add pass_dominator::sese_mode_p ()"
>       5    Handle oacc function in parloops
>       6    Update goacc kernels C testcases
>       7    Update goacc kernels Fortran testcases
>       8    Release_defs in expand_omp_atomic_fetch_op
>       9    Remove BUILT_IN_GOACC_KERNELS_INTERNAL
>
> [ The patch series is broken up into logical bits, but intended as
> single commit. Various things in kernels support will be broken in
> intermediate stages. ]
>
> Committed to gomp-4_0-branch.
>
> I'll post the patches in reply to this message.
>

The parloops pass constructs an atomic update:
...
   #pragma omp atomic_load
   D.1839_59 = *&.paral_data_load.33_51->reduction.23;
   D.1840_60 = sum.27_56 + D.1839_59;
   #pragma omp atomic_store (D.1840_60);
...

The expand_omp_atomic_fetch_op function removes the update statement but 
doesn't release the ssa-name D.1840_60 defined by the update statement.

This causes an error when running ccp in lto1. We run into trouble here 
for this unreleased ssa-name, because SSA_NAME_VAR (var) == NULL_TREE 
and TREE_CODE (NULL_TREE) causes a sigsegv:
...
get_default_value (tree var)
{
   ccp_prop_value_t val = { UNINITIALIZED, NULL_TREE, 0 };
   gimple *stmt;

   stmt = SSA_NAME_DEF_STMT (var);

   if (gimple_nop_p (stmt))
     {
       /* Variables defined by an empty statement are those used
	 before being initialized.  If VAR is a local variable, we
	 can assume initially that it is UNDEFINED, otherwise we must
	 consider it VARYING.  */
       if (!virtual_operand_p (var)
	  && TREE_CODE (SSA_NAME_VAR (var)) == VAR_DECL)
	val.lattice_val = UNDEFINED;
...

This patch fixes the problem by releasing the ssa-name in 
expand_omp_atomic_fetch_op function.

Thanks,
- Tom
diff mbox

Patch

Release_defs in expand_omp_atomic_fetch_op

2015-11-04  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (expand_omp_atomic_fetch_op):  Release defs of update stmt.
---
 gcc/omp-low.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 58cb959..84accd9 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11914,10 +11914,14 @@  expand_omp_atomic_fetch_op (basic_block load_bb,
   gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_ATOMIC_STORE);
   gsi_remove (&gsi, true);
   gsi = gsi_last_bb (store_bb);
+  stmt = gsi_stmt (gsi);
   gsi_remove (&gsi, true);
 
   if (gimple_in_ssa_p (cfun))
-    update_ssa (TODO_update_ssa_no_phi);
+    {
+      release_defs (stmt);
+      update_ssa (TODO_update_ssa_no_phi);
+    }
 
   return true;
 }
-- 
1.9.1