From 985f6c7969f7dd815c84f012486f17de978813b9 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 9 Dec 2015 23:15:47 +0100 Subject: trans.c (gfc_allocate_using_lib,gfc_deallocate_with_status): Introducing __asm__ __volatile__ ("":::"memory") after image control statements. 2015-12-09 Tobias Burnus Alessandro Fanfarillo * trans.c (gfc_allocate_using_lib,gfc_deallocate_with_status): Introducing __asm__ __volatile__ ("":::"memory") after image control statements. * trans-stmt.c (gfc_trans_sync, gfc_trans_event_post_wait, gfc_trans_lock_unlock, gfc_trans_critical): Ditto. * trans-intrinsic.c (gfc_conv_intrinsic_caf_get, conv_caf_send): Introducing __asm__ __volatile__ ("":::"memory") after send, before get and around sendget. 2015-12-09 Tobias Burnus Alessandro Fanfarillo * gfortran.dg/coarray_40.f90: New. Co-Authored-By: Alessandro Fanfarillo From-SVN: r231476 --- gcc/fortran/trans-intrinsic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gcc/fortran/trans-intrinsic.c') diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 21efe44..31bad35 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -1211,6 +1211,14 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind, if (lhs == NULL_TREE) may_require_tmp = boolean_false_node; + /* It guarantees memory consistency within the same segment */ + tmp = gfc_build_string_const (strlen ("memory")+1, "memory"), + tmp = build5_loc (input_location, ASM_EXPR, void_type_node, + gfc_build_string_const (1, ""), NULL_TREE, NULL_TREE, + tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE); + ASM_VOLATILE_P (tmp) = 1; + gfc_add_expr_to_block (&se->pre, tmp); + tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_get, 9, token, offset, image_index, argse.expr, vec, dst_var, kind, lhs_kind, may_require_tmp); @@ -1375,6 +1383,14 @@ conv_caf_send (gfc_code *code) { { tree rhs_token, rhs_offset, rhs_image_index; + /* It guarantees memory consistency within the same segment */ + tmp = gfc_build_string_const (strlen ("memory")+1, "memory"), + tmp = build5_loc (input_location, ASM_EXPR, void_type_node, + gfc_build_string_const (1, ""), NULL_TREE, NULL_TREE, + tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE); + ASM_VOLATILE_P (tmp) = 1; + gfc_add_expr_to_block (&block, tmp); + caf_decl = gfc_get_tree_for_caf_expr (rhs_expr); if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE) caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl); @@ -1390,6 +1406,15 @@ conv_caf_send (gfc_code *code) { gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &lhs_se.post); gfc_add_block_to_block (&block, &rhs_se.post); + + /* It guarantees memory consistency within the same segment */ + tmp = gfc_build_string_const (strlen ("memory")+1, "memory"), + tmp = build5_loc (input_location, ASM_EXPR, void_type_node, + gfc_build_string_const (1, ""), NULL_TREE, NULL_TREE, + tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE); + ASM_VOLATILE_P (tmp) = 1; + gfc_add_expr_to_block (&block, tmp); + return gfc_finish_block (&block); } -- cgit v1.1