* [gomp] Add langhook, so that Fortran can privatize variables by reference @ 2005-10-18 7:01 Jakub Jelinek 2005-10-18 9:10 ` Richard Henderson 2019-05-26 17:46 ` Thomas Schwinge 0 siblings, 2 replies; 11+ messages in thread From: Jakub Jelinek @ 2005-10-18 7:01 UTC (permalink / raw) To: gcc-patches, fortran Hi! From my testing so far, all Fortran user vars that have POINTER_TYPE type (in addition to the already handled REFERENCE_TYPE) are supposed to be privatized with the type they point to rather than just as a pointer type (Fortran POINTER, ALLOCATABLE and from what I saw, also Cray pointers in the patch that is floating around, use either an aggregate type or a simple INTEGER_TYPE). Fixes reference2.f90 (and some tests in openmpbench_F_v2, though there are still unrelated problems), approved privately by Richard, committed. 2005-10-18 Jakub Jelinek <jakub@redhat.com> * langhooks.h (struct lang_hooks_for_decls): Add omp_privatize_by_reference hook. * langhooks-def.h (lhd_omp_privatize_by_reference): New prototype. (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Define. (LANG_HOOKS_DECLS): Add LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE. * langhooks.c (lhd_omp_privatize_by_reference): New function. * omp-low.c (is_reference): Call omp_privatize_by_reference langhook. fortran/ * trans.h (gfc_omp_privatize_by_reference): New prototype. * f95-lang.c (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Redefine to gfc_omp_privatize_by_reference. * trans-openmp.c (gfc_omp_privatize_by_reference): New function. * trans-stmt.h (gfc_trans_omp_directive): Add comment. --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 @@ -126,7 +126,7 @@ is_variable_sized (tree expr) static inline bool is_reference (tree decl) { - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; + return lang_hooks.decls.omp_privatize_by_reference (decl); } /* Lookup variables in the decl or field splay trees. The "maybe" form --- gcc/langhooks.h.jj 2005-09-13 15:12:55.000000000 +0200 +++ gcc/langhooks.h 2005-10-18 08:46:23.000000000 +0200 @@ -192,6 +192,10 @@ struct lang_hooks_for_decls value will be the string already stored in an IDENTIFIER_NODE.) */ const char * (*comdat_group) (tree); + + /* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + bool (*omp_privatize_by_reference) (tree); }; /* Language-specific hooks. See langhooks-def.h for defaults. */ --- gcc/fortran/trans.h.jj 2005-10-17 09:04:27.000000000 +0200 +++ gcc/fortran/trans.h 2005-10-18 08:46:23.000000000 +0200 @@ -440,6 +440,9 @@ tree gfc_truthvalue_conversion (tree); tree builtin_function (const char *, tree, int, enum built_in_class, const char *, tree); +/* In trans-openmp.c */ +bool gfc_omp_privatize_by_reference (tree); + /* Runtime library function decls. */ extern GTY(()) tree gfor_fndecl_internal_malloc; extern GTY(()) tree gfor_fndecl_internal_malloc64; --- gcc/fortran/trans-openmp.c.jj 2005-10-12 15:29:25.000000000 +0200 +++ gcc/fortran/trans-openmp.c 2005-10-18 08:46:23.000000000 +0200 @@ -37,6 +37,24 @@ Software Foundation, 51 Franklin Street, #include "arith.h" +/* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + +bool +gfc_omp_privatize_by_reference (tree decl) +{ + tree type = TREE_TYPE (decl); + + if (TREE_CODE (type) == REFERENCE_TYPE) + return true; + + /* POINTER/ALLOCATABLE have aggregate types, all user variables + that have POINTER_TYPE type are supposed to be privatized + by reference. */ + return !DECL_ARTIFICIAL (decl) && TREE_CODE (type) == POINTER_TYPE; +} + + static inline tree gfc_trans_add_clause (tree node, tree tail) { --- gcc/fortran/trans-stmt.h.jj 2005-09-20 10:25:18.000000000 +0200 +++ gcc/fortran/trans-stmt.h 2005-10-18 08:46:23.000000000 +0200 @@ -50,6 +50,8 @@ tree gfc_trans_where (gfc_code *); tree gfc_trans_allocate (gfc_code *); tree gfc_trans_deallocate (gfc_code *); tree gfc_trans_deallocate_array (tree); + +/* trans-openmp.c */ tree gfc_trans_omp_directive (gfc_code *); /* trans-io.c */ --- gcc/fortran/f95-lang.c.jj 2005-10-17 09:04:26.000000000 +0200 +++ gcc/fortran/f95-lang.c 2005-10-18 08:46:23.000000000 +0200 @@ -116,6 +116,7 @@ static void gfc_expand_function (tree); #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #undef LANG_HOOKS_CLEAR_BINDING_STACK +#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE /* Define lang hooks. */ #define LANG_HOOKS_NAME "GNU F95" @@ -134,6 +135,7 @@ static void gfc_expand_function (tree); #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gfc_signed_or_unsigned_type #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function #define LANG_HOOKS_CLEAR_BINDING_STACK gfc_clear_binding_stack +#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; --- gcc/langhooks.c.jj 2005-09-17 20:43:39.000000000 +0200 +++ gcc/langhooks.c 2005-10-18 08:50:13.000000000 +0200 @@ -456,6 +456,15 @@ lhd_comdat_group (tree decl) return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); } +/* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ + +bool +lhd_omp_privatize_by_reference (tree decl ATTRIBUTE_UNUSED) +{ + return false; +} + /* lang_hooks.decls.final_write_globals: perform final processing on global variables. */ void --- gcc/langhooks-def.h.jj 2005-09-13 15:12:55.000000000 +0200 +++ gcc/langhooks-def.h 2005-10-18 08:46:23.000000000 +0200 @@ -70,6 +70,7 @@ extern tree lhd_expr_size (tree); extern size_t lhd_tree_size (enum tree_code); extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT); extern tree lhd_expr_to_decl (tree, bool *, bool *, bool *); +extern bool lhd_omp_privatize_by_reference (tree); /* Declarations of default tree inlining hooks. */ extern tree lhd_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn, @@ -239,6 +240,7 @@ extern tree lhd_make_node (enum tree_cod #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall #define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group +#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE lhd_omp_privatize_by_reference #define LANG_HOOKS_DECLS { \ LANG_HOOKS_GLOBAL_BINDINGS_P, \ @@ -249,7 +251,8 @@ extern tree lhd_make_node (enum tree_cod LANG_HOOKS_WRITE_GLOBALS, \ LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \ LANG_HOOKS_DECL_OK_FOR_SIBCALL, \ - LANG_HOOKS_COMDAT_GROUP \ + LANG_HOOKS_COMDAT_GROUP, \ + LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE \ } /* The whole thing. The structure is defined in langhooks.h. */ Jakub ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 7:01 [gomp] Add langhook, so that Fortran can privatize variables by reference Jakub Jelinek @ 2005-10-18 9:10 ` Richard Henderson 2005-10-18 9:49 ` Jakub Jelinek 2019-05-26 17:46 ` Thomas Schwinge 1 sibling, 1 reply; 11+ messages in thread From: Richard Henderson @ 2005-10-18 9:10 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, fortran On Tue, Oct 18, 2005 at 03:01:40AM -0400, Jakub Jelinek wrote: > +bool > +lhd_omp_privatize_by_reference (tree decl ATTRIBUTE_UNUSED) > +{ > + return false; > +} Preferably, hook_bool_tree_false. r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 9:10 ` Richard Henderson @ 2005-10-18 9:49 ` Jakub Jelinek 2005-10-18 9:54 ` Richard Henderson 0 siblings, 1 reply; 11+ messages in thread From: Jakub Jelinek @ 2005-10-18 9:49 UTC (permalink / raw) To: Richard Henderson, gcc-patches On Tue, Oct 18, 2005 at 02:10:33AM -0700, Richard Henderson wrote: > On Tue, Oct 18, 2005 at 03:01:40AM -0400, Jakub Jelinek wrote: > > +bool > > +lhd_omp_privatize_by_reference (tree decl ATTRIBUTE_UNUSED) > > +{ > > + return false; > > +} > > Preferably, hook_bool_tree_false. lhd_bool_tree_false or hook_bool_tree_false? Also, shouldn't e.g. bool lhd_decl_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED) { return true; } be changed to lhd_bool_tree_true too? Jakub ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 9:49 ` Jakub Jelinek @ 2005-10-18 9:54 ` Richard Henderson 2005-10-18 10:28 ` Jakub Jelinek 0 siblings, 1 reply; 11+ messages in thread From: Richard Henderson @ 2005-10-18 9:54 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches On Tue, Oct 18, 2005 at 05:48:52AM -0400, Jakub Jelinek wrote: > lhd_bool_tree_false or hook_bool_tree_false? hook_bool_tree_false, which already exists. > Also, shouldn't e.g. > bool > lhd_decl_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED) > { > return true; > } > be changed to lhd_bool_tree_true too? I hadn't noticed that one. It should be hook_bool_tree_true, which also already exists. r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 9:54 ` Richard Henderson @ 2005-10-18 10:28 ` Jakub Jelinek 2005-10-18 10:46 ` Richard Henderson 0 siblings, 1 reply; 11+ messages in thread From: Jakub Jelinek @ 2005-10-18 10:28 UTC (permalink / raw) To: Richard Henderson, gcc-patches On Tue, Oct 18, 2005 at 02:54:34AM -0700, Richard Henderson wrote: > On Tue, Oct 18, 2005 at 05:48:52AM -0400, Jakub Jelinek wrote: > > lhd_bool_tree_false or hook_bool_tree_false? > > hook_bool_tree_false, which already exists. > > > Also, shouldn't e.g. > > bool > > lhd_decl_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED) > > { > > return true; > > } > > be changed to lhd_bool_tree_true too? > > I hadn't noticed that one. It should be hook_bool_tree_true, > which also already exists. There are actually many more lhd_* hooks which have corresponding hook_* in hooks.c. Now, would this be ok for HEAD (of course except the LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE), or should I commit this just to gomp and let 4.2 clean up during gomp->HEAD merge after 4.1 branches, or should I just change LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE and create a PR with the patch, so that it is cleaned up later? 2005-10-18 Jakub Jelinek <jakub@redhat.com> * langhooks.c (lhd_do_nothing, lhd_do_nothing_t, lhd_can_use_bit_fields_p, lhd_expand_decl, lhd_tree_inlining_anon_aggr_type_p, lhd_decl_ok_for_sibcall, lhd_tree_inlining_end_inlining, lhd_omp_privatize_by_reference): Removed. * langhooks-def.h (lhd_do_nothing, lhd_do_nothing_t, lhd_can_use_bit_fields_p, lhd_expand_decl, lhd_tree_inlining_anon_aggr_type_p, lhd_decl_ok_for_sibcall, lhd_tree_inlining_end_inlining, lhd_omp_privatize_by_reference): Remove prototypes. (LANG_HOOKS_FINISH, LANG_HOOKS_CLEAR_BINDING_STACK, LANG_HOOKS_EXPAND_DECL, LANG_HOOKS_FINISH_INCOMPLETE_DECL, LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, LANG_HOOKS_CAN_USE_BIT_FIELDS_P, LANG_HOOKS_PRINT_STATISTICS, LANG_HOOKS_INIT_TS, LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P, LANG_HOOKS_TREE_INLINING_END_INLINING, LANG_HOOKS_DECL_OK_FOR_SIBCALL, LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Use hooks.c hooks rather than lhd_* specific ones. --- gcc/langhooks.c.jj 2005-10-18 08:50:13.000000000 +0200 +++ gcc/langhooks.c 2005-10-18 12:13:24.000000000 +0200 @@ -37,20 +37,6 @@ Boston, MA 02110-1301, USA. */ #include "ggc.h" #include "diagnostic.h" -/* Do nothing; in many cases the default hook. */ - -void -lhd_do_nothing (void) -{ -} - -/* Do nothing (tree). */ - -void -lhd_do_nothing_t (tree ARG_UNUSED (t)) -{ -} - /* Do nothing (int). */ void @@ -185,13 +171,6 @@ lhd_set_decl_assembler_name (tree decl) } } -/* By default we always allow bit-field based optimizations. */ -bool -lhd_can_use_bit_fields_p (void) -{ - return true; -} - /* Type promotion for variable arguments. */ tree lhd_type_promotes_to (tree ARG_UNUSED (type)) @@ -243,18 +222,6 @@ lhd_expand_expr (tree ARG_UNUSED (t), rt gcc_unreachable (); } -/* The default language-specific function for expanding a decl. After - the language-independent cases are handled, this function will be - called. If this function is not defined, it is assumed that - declarations other than those for variables and labels do not require - any RTL generation. */ - -int -lhd_expand_decl (tree ARG_UNUSED (t)) -{ - return 0; -} - /* This is the default decl_printable_name function. */ const char * @@ -348,16 +315,6 @@ lhd_tree_inlining_auto_var_in_fn_p (tree || TREE_CODE (var) == RESULT_DECL)); } -/* lang_hooks.tree_inlining.anon_aggr_type_p determines whether T is a - type node representing an anonymous aggregate (union, struct, etc), - i.e., one whose members are in the same scope as the union itself. */ - -int -lhd_tree_inlining_anon_aggr_type_p (tree t ATTRIBUTE_UNUSED) -{ - return 0; -} - /* lang_hooks.tree_inlining.start_inlining and end_inlining perform any language-specific bookkeeping necessary for processing FN. start_inlining returns nonzero if inlining should proceed, zero if @@ -372,11 +329,6 @@ lhd_tree_inlining_start_inlining (tree f return 1; } -void -lhd_tree_inlining_end_inlining (tree fn ATTRIBUTE_UNUSED) -{ -} - /* lang_hooks.tree_inlining.convert_parm_for_inlining performs any language-specific conversion before assigning VALUE to PARM. */ @@ -439,15 +391,6 @@ lhd_tree_size (enum tree_code c ATTRIBUT gcc_unreachable (); } -/* Return true if decl, which is a function decl, may be called by a - sibcall. */ - -bool -lhd_decl_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED) -{ - return true; -} - /* Return the COMDAT group into which DECL should be placed. */ const char * @@ -456,15 +399,6 @@ lhd_comdat_group (tree decl) return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); } -/* True if OpenMP should privatize what this DECL points to rather - than the DECL itself. */ - -bool -lhd_omp_privatize_by_reference (tree decl ATTRIBUTE_UNUSED) -{ - return false; -} - /* lang_hooks.decls.final_write_globals: perform final processing on global variables. */ void --- gcc/cp/cp-objcp-common.h.jj 2005-09-13 15:16:03.000000000 +0200 +++ gcc/cp/cp-objcp-common.h 2005-10-18 12:10:08.000000000 +0200 @@ -82,7 +82,7 @@ extern tree objcp_tsubst_copy_and_build #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl #undef LANG_HOOKS_WRITE_GLOBALS -#define LANG_HOOKS_WRITE_GLOBALS lhd_do_nothing +#define LANG_HOOKS_WRITE_GLOBALS hook_void_void #undef LANG_HOOKS_COMDAT_GROUP #define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group --- gcc/langhooks-def.h.jj 2005-10-18 08:46:23.000000000 +0200 +++ gcc/langhooks-def.h 2005-10-18 12:13:45.000000000 +0200 @@ -39,8 +39,6 @@ extern HOST_WIDE_INT hook_get_alias_set_ /* See langhooks.h for the definition and documentation of each hook. */ -extern void lhd_do_nothing (void); -extern void lhd_do_nothing_t (tree); extern void lhd_do_nothing_i (int); extern void lhd_do_nothing_f (struct function *); extern bool lhd_post_options (const char **); @@ -55,22 +53,18 @@ extern void lhd_print_tree_nothing (FILE extern const char *lhd_decl_printable_name (tree, int); extern int lhd_types_compatible_p (tree, tree); extern rtx lhd_expand_expr (tree, rtx, enum machine_mode, int, rtx *); -extern int lhd_expand_decl (tree); extern void lhd_print_error_function (struct diagnostic_context *, const char *); extern void lhd_set_decl_assembler_name (tree); -extern bool lhd_can_use_bit_fields_p (void); extern bool lhd_warn_unused_global_decl (tree); extern void lhd_incomplete_type_error (tree, tree); extern tree lhd_type_promotes_to (tree); extern void lhd_register_builtin_type (tree, const char *); -extern bool lhd_decl_ok_for_sibcall (tree); extern const char *lhd_comdat_group (tree); extern tree lhd_expr_size (tree); extern size_t lhd_tree_size (enum tree_code); extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT); extern tree lhd_expr_to_decl (tree, bool *, bool *, bool *); -extern bool lhd_omp_privatize_by_reference (tree); /* Declarations of default tree inlining hooks. */ extern tree lhd_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn, @@ -79,9 +73,7 @@ extern int lhd_tree_inlining_cannot_inli extern int lhd_tree_inlining_disregard_inline_limits (tree); extern tree lhd_tree_inlining_add_pending_fn_decls (void *, tree); extern int lhd_tree_inlining_auto_var_in_fn_p (tree, tree); -extern int lhd_tree_inlining_anon_aggr_type_p (tree); extern int lhd_tree_inlining_start_inlining (tree); -extern void lhd_tree_inlining_end_inlining (tree); extern tree lhd_tree_inlining_convert_parm_for_inlining (tree, tree, tree, int); extern void lhd_initialize_diagnostics (struct diagnostic_context *); extern tree lhd_callgraph_analyze_expr (tree *, int *, tree); @@ -93,9 +85,9 @@ extern int lhd_gimplify_expr (tree *, tr #define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) #define LANG_HOOKS_INIT hook_bool_void_false -#define LANG_HOOKS_FINISH lhd_do_nothing +#define LANG_HOOKS_FINISH hook_void_void #define LANG_HOOKS_PARSE_FILE lhd_do_nothing_i -#define LANG_HOOKS_CLEAR_BINDING_STACK lhd_do_nothing +#define LANG_HOOKS_CLEAR_BINDING_STACK hook_void_void #define LANG_HOOKS_INIT_OPTIONS hook_uint_uint_constcharptrptr_0 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics #define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constcharptr_int_0 @@ -104,16 +96,16 @@ extern int lhd_gimplify_expr (tree *, tr #define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree #define LANG_HOOKS_EXPAND_EXPR lhd_expand_expr -#define LANG_HOOKS_EXPAND_DECL lhd_expand_decl +#define LANG_HOOKS_EXPAND_DECL hook_int_tree_0 #define LANG_HOOKS_SAFE_FROM_P lhd_safe_from_p -#define LANG_HOOKS_FINISH_INCOMPLETE_DECL lhd_do_nothing_t +#define LANG_HOOKS_FINISH_INCOMPLETE_DECL hook_void_tree #define LANG_HOOKS_STATICP lhd_staticp -#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t +#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL hook_void_tree #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lhd_set_decl_assembler_name -#define LANG_HOOKS_CAN_USE_BIT_FIELDS_P lhd_can_use_bit_fields_p +#define LANG_HOOKS_CAN_USE_BIT_FIELDS_P hook_bool_void_true #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS false #define LANG_HOOKS_NO_BODY_BLOCKS false -#define LANG_HOOKS_PRINT_STATISTICS lhd_do_nothing +#define LANG_HOOKS_PRINT_STATISTICS hook_void_void #define LANG_HOOKS_PRINT_XNODE lhd_print_tree_nothing #define LANG_HOOKS_PRINT_DECL lhd_print_tree_nothing #define LANG_HOOKS_PRINT_TYPE lhd_print_tree_nothing @@ -127,7 +119,7 @@ extern int lhd_gimplify_expr (tree *, tr #define LANG_HOOKS_BUILTIN_FUNCTION builtin_function #define LANG_HOOKS_EXPR_TO_DECL lhd_expr_to_decl #define LANG_HOOKS_TO_TARGET_CHARSET lhd_to_target_charset -#define LANG_HOOKS_INIT_TS lhd_do_nothing +#define LANG_HOOKS_INIT_TS hook_void_void #define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f #define LANG_HOOKS_FUNCTION_FINAL lhd_do_nothing_f @@ -151,13 +143,13 @@ extern int lhd_gimplify_expr (tree *, tr #define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \ lhd_tree_inlining_auto_var_in_fn_p #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ - lhd_tree_inlining_anon_aggr_type_p + hook_int_tree_0 #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \ hook_bool_tree_tree_false #define LANG_HOOKS_TREE_INLINING_START_INLINING \ lhd_tree_inlining_start_inlining #define LANG_HOOKS_TREE_INLINING_END_INLINING \ - lhd_tree_inlining_end_inlining + hook_void_tree #define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \ lhd_tree_inlining_convert_parm_for_inlining @@ -238,9 +230,9 @@ extern tree lhd_make_node (enum tree_cod #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL -#define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall +#define LANG_HOOKS_DECL_OK_FOR_SIBCALL hook_bool_tree_true #define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group -#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE lhd_omp_privatize_by_reference +#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_tree_false #define LANG_HOOKS_DECLS { \ LANG_HOOKS_GLOBAL_BINDINGS_P, \ Jakub ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 10:28 ` Jakub Jelinek @ 2005-10-18 10:46 ` Richard Henderson 0 siblings, 0 replies; 11+ messages in thread From: Richard Henderson @ 2005-10-18 10:46 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches On Tue, Oct 18, 2005 at 06:28:49AM -0400, Jakub Jelinek wrote: > ... or should I just change LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE > and create a PR with the patch, so that it is cleaned up later? This option, please. r~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2005-10-18 7:01 [gomp] Add langhook, so that Fortran can privatize variables by reference Jakub Jelinek 2005-10-18 9:10 ` Richard Henderson @ 2019-05-26 17:46 ` Thomas Schwinge 2019-05-27 16:51 ` Jakub Jelinek 1 sibling, 1 reply; 11+ messages in thread From: Thomas Schwinge @ 2019-05-26 17:46 UTC (permalink / raw) To: Jakub Jelinek, gcc-patches [-- Attachment #1: Type: text/plain, Size: 1009 bytes --] Hi! On Tue, 18 Oct 2005 03:01:40 -0400, Jakub Jelinek <jakub@redhat.com> wrote: > --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 > +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 > @@ -126,7 +126,7 @@ is_variable_sized (tree expr) > static inline bool > is_reference (tree decl) > { > - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; > + return lang_hooks.decls.omp_privatize_by_reference (decl); > } With the same implementation, this function nowadays is known as 'omp_is_reference' ('gcc/omp-general.c'), and is used in 'omp-*' files only. The gimplifier directly calls 'lang_hooks.decls.omp_privatize_by_reference'. Will it be OK to commit the obvious patch to get rid of the 'omp_is_reference' function? Whenever I see it used in 'omp-*' files, I wonder and have to look up what special things it might be doing -- but it actually isn't. gcc/ * omp-general.c (omp_is_reference): Don't define. Adjust all users. Grüße Thomas [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 658 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2019-05-26 17:46 ` Thomas Schwinge @ 2019-05-27 16:51 ` Jakub Jelinek 2019-05-29 17:12 ` Thomas Schwinge 0 siblings, 1 reply; 11+ messages in thread From: Jakub Jelinek @ 2019-05-27 16:51 UTC (permalink / raw) To: Thomas Schwinge; +Cc: gcc-patches On Sun, May 26, 2019 at 07:43:04PM +0200, Thomas Schwinge wrote: > On Tue, 18 Oct 2005 03:01:40 -0400, Jakub Jelinek <jakub@redhat.com> wrote: > > --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 > > +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 > > @@ -126,7 +126,7 @@ is_variable_sized (tree expr) > > static inline bool > > is_reference (tree decl) > > { > > - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; > > + return lang_hooks.decls.omp_privatize_by_reference (decl); > > } > > With the same implementation, this function nowadays is known as > 'omp_is_reference' ('gcc/omp-general.c'), and is used in 'omp-*' files > only. The gimplifier directly calls > 'lang_hooks.decls.omp_privatize_by_reference'. > > Will it be OK to commit the obvious patch to get rid of the > 'omp_is_reference' function? Whenever I see it used in 'omp-*' files, I No, omp_is_reference (something) is certainly more readable from lang_hooks.decls.omp_privatize_by_reference (something), which is quite long and would cause major issues in formatting etc. What advantage do you see in removing that? > wonder and have to look up what special things it might be doing -- but > it actually isn't. > > gcc/ > * omp-general.c (omp_is_reference): Don't define. Adjust all users. Jakub ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2019-05-27 16:51 ` Jakub Jelinek @ 2019-05-29 17:12 ` Thomas Schwinge 2021-08-31 14:28 ` Thomas Schwinge 0 siblings, 1 reply; 11+ messages in thread From: Thomas Schwinge @ 2019-05-29 17:12 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches [-- Attachment #1: Type: text/plain, Size: 2303 bytes --] Hi Jakub! On Mon, 27 May 2019 18:49:20 +0200, Jakub Jelinek <jakub@redhat.com> wrote: > On Sun, May 26, 2019 at 07:43:04PM +0200, Thomas Schwinge wrote: > > On Tue, 18 Oct 2005 03:01:40 -0400, Jakub Jelinek <jakub@redhat.com> wrote: > > > --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 > > > +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 > > > @@ -126,7 +126,7 @@ is_variable_sized (tree expr) > > > static inline bool > > > is_reference (tree decl) > > > { > > > - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; > > > + return lang_hooks.decls.omp_privatize_by_reference (decl); > > > } > > > > With the same implementation, this function nowadays is known as > > 'omp_is_reference' ('gcc/omp-general.c'), and is used in 'omp-*' files > > only. The gimplifier directly calls > > 'lang_hooks.decls.omp_privatize_by_reference'. > > > > Will it be OK to commit the obvious patch to get rid of the > > 'omp_is_reference' function? Whenever I see it used in 'omp-*' files, I > > No, omp_is_reference (something) is certainly more readable from > lang_hooks.decls.omp_privatize_by_reference (something) Yes, better readable because it's shorter, but you have to look up its meaning, whereas with 'lang_hooks.decls.omp_privatize_by_reference' you directly see what it's about. > which is quite > long and would cause major issues in formatting etc. Well, we have rules about how to deal with the formatting issues. > What advantage do you see in removing that? For me, it's confusing, when looking at, say, 'OMP_CLAUSE_FIRSTPRIVATE' code, that in 'gcc/gimplify.c' we call 'lang_hooks.decls.omp_privatize_by_reference', whereas in 'gcc/omp-*.c' files we call 'omp_is_reference' -- but both actually mean the same thing. > > wonder and have to look up what special things it might be doing -- but > > it actually isn't. > > > > gcc/ > > * omp-general.c (omp_is_reference): Don't define. Adjust all users. Or, of course, the other way round: gcc/ * gimplify.c: Use omp_is_reference. Or, even more preferably: gcc/ * omp-general.c (omp_is_reference): Rename to... (omp_privatize_by_reference): ... this. Adjust all users. * gimplify.c: Use it. Grüße Thomas [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 658 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2019-05-29 17:12 ` Thomas Schwinge @ 2021-08-31 14:28 ` Thomas Schwinge 2021-08-31 14:45 ` Jakub Jelinek 0 siblings, 1 reply; 11+ messages in thread From: Thomas Schwinge @ 2021-08-31 14:28 UTC (permalink / raw) To: Jakub Jelinek, gcc-patches [-- Attachment #1: Type: text/plain, Size: 3113 bytes --] Hi Jakub! We never finished this dicussion here -- but I ran into this again, last week: On 2019-05-29T18:59:46+0200, I wrote: > On Mon, 27 May 2019 18:49:20 +0200, Jakub Jelinek <jakub@redhat.com> wrote: >> On Sun, May 26, 2019 at 07:43:04PM +0200, Thomas Schwinge wrote: >> > On Tue, 18 Oct 2005 03:01:40 -0400, Jakub Jelinek <jakub@redhat.com> wrote: >> > > --- gcc/omp-low.c.jj 2005-10-15 12:00:06.000000000 +0200 >> > > +++ gcc/omp-low.c 2005-10-18 08:46:23.000000000 +0200 >> > > @@ -126,7 +126,7 @@ is_variable_sized (tree expr) >> > > static inline bool >> > > is_reference (tree decl) >> > > { >> > > - return TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE; >> > > + return lang_hooks.decls.omp_privatize_by_reference (decl); >> > > } >> > >> > With the same implementation, this function nowadays is known as >> > 'omp_is_reference' ('gcc/omp-general.c'), and is used in 'omp-*' files >> > only. The gimplifier directly calls >> > 'lang_hooks.decls.omp_privatize_by_reference'. >> > >> > Will it be OK to commit the obvious patch to get rid of the >> > 'omp_is_reference' function? Whenever I see it used in 'omp-*' files, I >> >> No, omp_is_reference (something) is certainly more readable from >> lang_hooks.decls.omp_privatize_by_reference (something) > > Yes, better readable because it's shorter, but you have to look up its > meaning, whereas with 'lang_hooks.decls.omp_privatize_by_reference' you > directly see what it's about. > >> which is quite >> long and would cause major issues in formatting etc. (Actually, my proposed change: 'omp_is_reference' -> 'lang_hooks.decls.omp_privatize_by_reference' would not "cause major issues in formatting etc.": very most of the affected source code lines are not going to overflow.) >> What advantage do you see in removing that? > > For me, it's confusing, when looking at, say, 'OMP_CLAUSE_FIRSTPRIVATE' > code, that in 'gcc/gimplify.c' we call > 'lang_hooks.decls.omp_privatize_by_reference', whereas in 'gcc/omp-*.c' > files we call 'omp_is_reference' -- but both actually mean the same > thing. > >> > wonder and have to look up what special things it might be doing -- but >> > it actually isn't. >> > >> > gcc/ >> > * omp-general.c (omp_is_reference): Don't define. Adjust all users. > > Or, of course, the other way round: > > gcc/ > * gimplify.c: Use omp_is_reference. > > Or, even more preferably: > > gcc/ > * omp-general.c (omp_is_reference): Rename to... > (omp_privatize_by_reference): ... this. Adjust all users. > * gimplify.c: Use it. The latter one is what I had implemented and now tested: is the attached "[OMP] Standardize on 'omp_privatize_by_reference'" OK to push to master branch? Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-OMP-Standardize-on-omp_privatize_by_reference.patch --] [-- Type: text/x-diff, Size: 33170 bytes --] From fb29fe81b4c8e880b32d68351385d8a42c97934b Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Wed, 29 May 2019 18:59:46 +0200 Subject: [PATCH] [OMP] Standardize on 'omp_privatize_by_reference' ... instead of 'omp_is_reference' vs. 'lang_hooks.decls.omp_privatize_by_reference'. gcc/ * omp-general.h (omp_is_reference): Rename to... (omp_privatize_by_reference): ... this. Adjust all users... * omp-general.c: ... here, ... * gimplify.c: ... here, ... * omp-expand.c: ... here, ... * omp-low.c: ... here. --- gcc/gimplify.c | 17 ++--- gcc/omp-expand.c | 9 +-- gcc/omp-general.c | 5 +- gcc/omp-general.h | 2 +- gcc/omp-low.c | 154 ++++++++++++++++++++++++---------------------- 5 files changed, 98 insertions(+), 89 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 070d0e4df45..cab4089192a 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1831,7 +1831,8 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) gimplify_and_add (init, seq_p); ggc_free (init); /* Clear TREE_READONLY if we really have an initialization. */ - if (!DECL_INITIAL (decl) && !omp_is_reference (decl)) + if (!DECL_INITIAL (decl) + && !omp_privatize_by_reference (decl)) TREE_READONLY (decl) = 0; } else @@ -7064,7 +7065,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags) omp_notice_variable (ctx, TYPE_SIZE_UNIT (TREE_TYPE (decl)), true); } else if ((flags & (GOVD_MAP | GOVD_LOCAL)) == 0 - && lang_hooks.decls.omp_privatize_by_reference (decl)) + && omp_privatize_by_reference (decl)) { omp_firstprivatize_type_sizes (ctx, TREE_TYPE (decl)); @@ -7322,7 +7323,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) bool declared = is_oacc_declared (decl); tree type = TREE_TYPE (decl); - if (lang_hooks.decls.omp_privatize_by_reference (decl)) + if (omp_privatize_by_reference (decl)) type = TREE_TYPE (type); /* For Fortran COMMON blocks, only used variables in those blocks are @@ -7586,7 +7587,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) tree type = TREE_TYPE (decl); if (gimplify_omp_ctxp->target_firstprivatize_array_bases - && lang_hooks.decls.omp_privatize_by_reference (decl)) + && omp_privatize_by_reference (decl)) type = TREE_TYPE (type); if (!lang_hooks.types.omp_mappable_type (type)) { @@ -7660,7 +7661,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t); n2->value |= GOVD_SEEN; } - else if (lang_hooks.decls.omp_privatize_by_reference (decl) + else if (omp_privatize_by_reference (decl) && TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))) && (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl)))) != INTEGER_CST)) @@ -7785,7 +7786,7 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate) if (copyprivate) return true; - if (lang_hooks.decls.omp_privatize_by_reference (decl)) + if (omp_privatize_by_reference (decl)) return false; /* Treat C++ privatized non-static data members outside @@ -10373,7 +10374,7 @@ omp_shared_to_firstprivate_optimizable_decl_p (tree decl) HOST_WIDE_INT len = int_size_in_bytes (type); if (len == -1 || len > 4 * POINTER_SIZE / BITS_PER_UNIT) return false; - if (lang_hooks.decls.omp_privatize_by_reference (decl)) + if (omp_privatize_by_reference (decl)) return false; return true; } @@ -10698,7 +10699,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) OMP_CLAUSE_CHAIN (clause) = nc; } else if (gimplify_omp_ctxp->target_firstprivatize_array_bases - && lang_hooks.decls.omp_privatize_by_reference (decl)) + && omp_privatize_by_reference (decl)) { OMP_CLAUSE_DECL (clause) = build_simple_mem_ref (decl); OMP_CLAUSE_SIZE (clause) diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 66c64f5a37b..7ce0663ba70 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -4232,9 +4232,8 @@ expand_omp_for_generic (struct omp_region *region, && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) { tree d = OMP_CLAUSE_DECL (c); - bool is_ref = omp_is_reference (d); tree t = d, a, dest; - if (is_ref) + if (omp_privatize_by_reference (t)) t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); tree type = TREE_TYPE (t); if (POINTER_TYPE_P (type)) @@ -5236,9 +5235,8 @@ expand_omp_for_static_nochunk (struct omp_region *region, && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) { tree d = OMP_CLAUSE_DECL (c); - bool is_ref = omp_is_reference (d); tree t = d, a, dest; - if (is_ref) + if (omp_privatize_by_reference (t)) t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); if (itercnt == NULL_TREE) { @@ -5952,9 +5950,8 @@ expand_omp_for_static_chunk (struct omp_region *region, && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) { tree d = OMP_CLAUSE_DECL (c); - bool is_ref = omp_is_reference (d); tree t = d, a, dest; - if (is_ref) + if (omp_privatize_by_reference (t)) t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); tree type = TREE_TYPE (t); if (POINTER_TYPE_P (type)) diff --git a/gcc/omp-general.c b/gcc/omp-general.c index b46a537e281..cc6aecb1d66 100644 --- a/gcc/omp-general.c +++ b/gcc/omp-general.c @@ -79,10 +79,11 @@ omp_check_optional_argument (tree decl, bool for_present_check) return lang_hooks.decls.omp_check_optional_argument (decl, for_present_check); } -/* Return true if DECL is a reference type. */ +/* True if OpenMP should privatize what this DECL points to rather + than the DECL itself. */ bool -omp_is_reference (tree decl) +omp_privatize_by_reference (tree decl) { return lang_hooks.decls.omp_privatize_by_reference (decl); } diff --git a/gcc/omp-general.h b/gcc/omp-general.h index 5c3e0f0e205..6a1468d2798 100644 --- a/gcc/omp-general.h +++ b/gcc/omp-general.h @@ -93,7 +93,7 @@ struct omp_for_data extern tree omp_find_clause (tree clauses, enum omp_clause_code kind); extern bool omp_is_allocatable_or_ptr (tree decl); extern tree omp_check_optional_argument (tree decl, bool for_present_check); -extern bool omp_is_reference (tree decl); +extern bool omp_privatize_by_reference (tree decl); extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code, tree *n2, tree v, tree step); extern tree omp_get_for_step_from_incr (location_t loc, tree incr); diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a0b41afa3eb..bbade6f1eb8 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -736,7 +736,7 @@ build_outer_var_ref (tree var, omp_context *ctx, } else if (outer) x = lookup_decl (var, outer); - else if (omp_is_reference (var)) + else if (omp_privatize_by_reference (var)) /* This can happen with orphaned constructs. If var is reference, it is possible it is shared and as such valid. */ x = var; @@ -759,7 +759,7 @@ build_outer_var_ref (tree var, omp_context *ctx, } } - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) x = build_simple_mem_ref (x); return x; @@ -824,7 +824,8 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx) } else if (by_ref) type = build_pointer_type (type); - else if ((mask & (32 | 3)) == 1 && omp_is_reference (var)) + else if ((mask & (32 | 3)) == 1 + && omp_privatize_by_reference (var)) type = TREE_TYPE (type); field = build_decl (DECL_SOURCE_LOCATION (var), @@ -1217,7 +1218,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) if ((! TREE_READONLY (decl) && !OMP_CLAUSE_SHARED_READONLY (c)) || TREE_ADDRESSABLE (decl) || by_ref - || omp_is_reference (decl)) + || omp_privatize_by_reference (decl)) { by_ref = use_pointer_for_field (decl, ctx); install_var_field (decl, by_ref, 3, ctx); @@ -1368,7 +1369,10 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) && is_gimple_omp_offloaded (ctx->stmt)) { if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) - install_var_field (decl, !omp_is_reference (decl), 3, ctx); + { + by_ref = !omp_privatize_by_reference (decl); + install_var_field (decl, by_ref, 3, ctx); + } else if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) install_var_field (decl, true, 3, ctx); else @@ -1396,7 +1400,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) by_ref = use_pointer_for_field (decl, NULL); if (is_task_ctx (ctx) - && (global || by_ref || omp_is_reference (decl))) + && (global || by_ref || omp_privatize_by_reference (decl))) { if (ctx->allocate_map && ctx->allocate_map->get (decl)) @@ -1420,7 +1424,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) if (lang_hooks.decls.omp_array_data (decl, true)) install_var_field (decl, false, 19, ctx); else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR - && !omp_is_reference (decl) + && !omp_privatize_by_reference (decl) && !omp_is_allocatable_or_ptr (decl)) || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) install_var_field (decl, true, 11, ctx); @@ -4694,7 +4698,7 @@ lower_private_allocate (tree var, tree new_var, tree &allocator, allocator = *allocatorp; if (allocator == NULL_TREE) return false; - if (!is_ref && omp_is_reference (var)) + if (!is_ref && omp_privatize_by_reference (var)) { allocator = NULL_TREE; return false; @@ -4792,7 +4796,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, case OMP_CLAUSE_LASTPRIVATE: if (is_variable_sized (OMP_CLAUSE_DECL (c))) sctx.max_vf = 1; - else if (omp_is_reference (OMP_CLAUSE_DECL (c))) + else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c))) { tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c))); if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype))) @@ -4804,7 +4808,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF || is_variable_sized (OMP_CLAUSE_DECL (c))) sctx.max_vf = 1; - else if (omp_is_reference (OMP_CLAUSE_DECL (c))) + else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c))) { tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c))); if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype))) @@ -4966,7 +4970,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, original address, it is always the address of the global variable itself. */ if (!DECL_P (var) - || omp_is_reference (var) + || omp_privatize_by_reference (var) || !is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx))) { @@ -5407,10 +5411,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, tree ref = build_outer_var_ref (var, ctx); /* For ref build_outer_var_ref already performs this. */ if (TREE_CODE (d) == INDIRECT_REF) - gcc_assert (omp_is_reference (var)); + gcc_assert (omp_privatize_by_reference (var)); else if (TREE_CODE (d) == ADDR_EXPR) ref = build_fold_addr_expr (ref); - else if (omp_is_reference (var)) + else if (omp_privatize_by_reference (var)) ref = build_fold_addr_expr (ref); ref = fold_convert_loc (clause_loc, ptype, ref); if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) @@ -5557,7 +5561,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, bool by_ref = use_pointer_for_field (var, ctx); x = build_receiver_ref (var, by_ref, ctx); } - if (!omp_is_reference (var)) + if (!omp_privatize_by_reference (var)) x = build_fold_addr_expr (x); x = fold_convert (ptr_type_node, x); unsigned cnt = task_reduction_cnt - 1; @@ -5573,7 +5577,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, else if (pass == 3) { tree type = TREE_TYPE (new_var); - if (!omp_is_reference (var)) + if (!omp_privatize_by_reference (var)) type = build_pointer_type (type); if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION) { @@ -5601,7 +5605,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } x = fold_convert (type, x); tree t; - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gimplify_assign (new_var, x, ilist); t = new_var; @@ -5662,7 +5666,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, gimplify_assign (ptr, x, ilist); } } - else if (omp_is_reference (var) + else if (omp_privatize_by_reference (var) && (c_kind != OMP_CLAUSE_FIRSTPRIVATE || !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c))) { @@ -5827,11 +5831,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, || (gimple_omp_for_index (ctx->stmt, 0) != new_var))) || OMP_CLAUSE_CODE (c) == OMP_CLAUSE__CONDTEMP_ - || omp_is_reference (var)) + || omp_privatize_by_reference (var)) && lower_rec_simd_input_clauses (new_var, ctx, &sctx, ivar, lvar)) { - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); tree new_vard = TREE_OPERAND (new_var, 0); @@ -5917,7 +5921,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } break; } - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); tree new_vard = TREE_OPERAND (new_var, 0); @@ -5987,7 +5991,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, case OMP_CLAUSE_FIRSTPRIVATE: if (is_task_ctx (ctx)) { - if ((omp_is_reference (var) + if ((omp_privatize_by_reference (var) && !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c)) || is_variable_sized (var)) goto do_dtor; @@ -6014,7 +6018,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } } if (OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c) - && omp_is_reference (var)) + && omp_privatize_by_reference (var)) { x = build_outer_var_ref (var, ctx); gcc_assert (TREE_CODE (x) == MEM_REF @@ -6059,7 +6063,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (OMP_CLAUSE_LINEAR_ARRAY (c)) { - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); tree new_vard = TREE_OPERAND (new_var, 0); @@ -6096,11 +6100,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR || TREE_ADDRESSABLE (new_var) - || omp_is_reference (var)) + || omp_privatize_by_reference (var)) && lower_rec_simd_input_clauses (new_var, ctx, &sctx, ivar, lvar)) { - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); tree new_vard = TREE_OPERAND (new_var, 0); @@ -6137,7 +6141,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, gimplify_and_add (x, &llist[1]); break; } - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); tree new_vard = TREE_OPERAND (new_var, 0); @@ -6220,14 +6224,14 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, NULL_TREE); x = build_outer_var_ref (var, ctx); - if (omp_is_reference (var) + if (omp_privatize_by_reference (var) && !useless_type_conversion_p (ptype, TREE_TYPE (x))) x = build_fold_addr_expr_loc (clause_loc, x); } SET_DECL_VALUE_EXPR (placeholder, x); DECL_HAS_VALUE_EXPR_P (placeholder) = 1; tree new_vard = new_var; - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); new_vard = TREE_OPERAND (new_var, 0); @@ -6387,7 +6391,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, for it because it is undesirable if SIMD arrays are used. But if they aren't used, we need to emit the deferred initialization now. */ - else if (omp_is_reference (var) && is_simd) + else if (omp_privatize_by_reference (var) && is_simd) handle_simd_reference (clause_loc, new_vard, ilist); tree lab2 = NULL_TREE; @@ -6582,7 +6586,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, bool is_truth_op = (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR); tree new_vard = new_var; - if (is_simd && omp_is_reference (var)) + if (is_simd && omp_privatize_by_reference (var)) { gcc_assert (TREE_CODE (new_var) == MEM_REF); new_vard = TREE_OPERAND (new_var, 0); @@ -6653,7 +6657,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, lower_private_allocate (var, new_var, allocator, allocate_ptr, ilist, ctx, false, NULL_TREE); - if (omp_is_reference (var) && is_simd) + if (omp_privatize_by_reference (var) && is_simd) handle_simd_reference (clause_loc, new_vard, ilist); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION && OMP_CLAUSE_REDUCTION_INSCAN (c)) @@ -7254,7 +7258,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *body_p, } if (!x) x = build_outer_var_ref (var, ctx, OMP_CLAUSE_LASTPRIVATE); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) new_var = build_simple_mem_ref_loc (clause_loc, new_var); x = lang_hooks.decls.omp_clause_assign_op (c, x, new_var); gimplify_and_add (x, this_stmt_list); @@ -7400,7 +7404,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, && maybe_lookup_field (orig, outer) && !is_private) { ref_to_res = build_receiver_ref (orig, false, outer); - if (omp_is_reference (orig)) + if (omp_privatize_by_reference (orig)) ref_to_res = build_simple_mem_ref (ref_to_res); tree type = TREE_TYPE (var); @@ -7430,7 +7434,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, if (!ref_to_res) ref_to_res = integer_zero_node; - if (omp_is_reference (orig)) + if (omp_privatize_by_reference (orig)) { tree type = TREE_TYPE (var); const char *id = IDENTIFIER_POINTER (DECL_NAME (var)); @@ -7610,7 +7614,8 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, } } new_var = lookup_decl (var, ctx); - if (var == OMP_CLAUSE_DECL (c) && omp_is_reference (var)) + if (var == OMP_CLAUSE_DECL (c) + && omp_privatize_by_reference (var)) new_var = build_simple_mem_ref_loc (clause_loc, new_var); ref = build_outer_var_ref (var, ctx, ccode); code = OMP_CLAUSE_REDUCTION_CODE (c); @@ -7679,7 +7684,8 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, if (TREE_CODE (d) == INDIRECT_REF) { new_var = build_simple_mem_ref_loc (clause_loc, new_var); - gcc_assert (omp_is_reference (var) && var == orig_var); + gcc_assert (omp_privatize_by_reference (var) + && var == orig_var); } else if (TREE_CODE (d) == ADDR_EXPR) { @@ -7692,7 +7698,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, else { gcc_assert (orig_var == var); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) ref = build_fold_addr_expr (ref); } if (DECL_P (v)) @@ -7778,7 +7784,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, { tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); - if (omp_is_reference (var) + if (omp_privatize_by_reference (var) && !useless_type_conversion_p (TREE_TYPE (placeholder), TREE_TYPE (ref))) ref = build_fold_addr_expr_loc (clause_loc, ref); @@ -7864,7 +7870,7 @@ lower_copyprivate_clauses (tree clauses, gimple_seq *slist, gimple_seq *rlist, ref); ref = build_fold_indirect_ref_loc (clause_loc, ref); } - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { ref = fold_convert_loc (clause_loc, TREE_TYPE (new_var), ref); ref = build_simple_mem_ref_loc (clause_loc, ref); @@ -8017,7 +8023,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, break; case OMP_CLAUSE_LASTPRIVATE: - if (by_ref || omp_is_reference (val)) + if (by_ref || omp_privatize_by_reference (val)) { if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c)) continue; @@ -8039,7 +8045,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, if (is_task_ctx (ctx)) by_ref = use_pointer_for_field (val, ctx); else - do_out = !(by_ref || omp_is_reference (val)); + do_out = !(by_ref || omp_privatize_by_reference (val)); } else by_ref = TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE; @@ -8913,7 +8919,7 @@ omp_task_reduction_iterate (int pass, enum tree_code code, } else { - if (omp_is_reference (*decl)) + if (omp_privatize_by_reference (*decl)) *type = TREE_TYPE (*type); if (pass != (!TREE_CONSTANT (TYPE_SIZE_UNIT (*type)))) continue; @@ -9201,7 +9207,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, else { t = ref = maybe_lookup_decl_in_outer_ctx (var, ctx); - if (!omp_is_reference (decl)) + if (!omp_privatize_by_reference (decl)) t = build_fold_addr_expr (t); } t = fold_convert (pointer_sized_int_node, t); @@ -9284,7 +9290,8 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, build_simple_mem_ref (ptr), field, NULL_TREE); enum tree_code rcode = OMP_CLAUSE_REDUCTION_CODE (c); - if (TREE_CODE (decl) != MEM_REF && omp_is_reference (decl)) + if (TREE_CODE (decl) != MEM_REF + && omp_privatize_by_reference (decl)) ref = build_simple_mem_ref (ref); /* reduction(-:var) sums up the partial results, so it acts identically to reduction(+:var). */ @@ -9400,7 +9407,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, gimple_seq_add_stmt (end, g); gimple_seq_add_stmt (end, gimple_build_label (lab5)); } - if (omp_is_reference (decl) + if (omp_privatize_by_reference (decl) && !useless_type_conversion_p (TREE_TYPE (placeholder), TREE_TYPE (ref))) ref = build_fold_addr_expr_loc (OMP_CLAUSE_LOCATION (c), ref); @@ -9414,7 +9421,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, gcc_assert (d); if (DECL_HAS_VALUE_EXPR_P (d)) oldv = DECL_VALUE_EXPR (d); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { tree v = fold_convert (TREE_TYPE (d), build_fold_addr_expr (new_var)); @@ -9986,7 +9993,7 @@ lower_omp_scan (gimple_stmt_iterator *gsi_p, omp_context *ctx) tree var4 = NULL_TREE; tree lane0 = NULL_TREE; tree new_vard = new_var; - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { new_var = build_simple_mem_ref_loc (clause_loc, new_var); val = new_var; @@ -10853,7 +10860,7 @@ lower_omp_for_scan (gimple_seq *body_p, gimple_seq *dlist, gomp_for *stmt, tree new_var = lookup_decl (var, ctx); tree var3 = NULL_TREE; tree new_vard = new_var; - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) new_var = build_simple_mem_ref_loc (clause_loc, new_var); if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) { @@ -12026,7 +12033,8 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) sf = *tcctx.cb.decl_map->get (sf); src = build_simple_mem_ref_loc (loc, sarg); src = omp_build_component_ref (src, sf); - if (use_pointer_for_field (decl, NULL) || omp_is_reference (decl)) + if (use_pointer_for_field (decl, NULL) + || omp_privatize_by_reference (decl)) src = build_simple_mem_ref_loc (loc, src); } else @@ -12646,7 +12654,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) { gcc_assert (is_gimple_omp_oacc (ctx->stmt)); - if (omp_is_reference (new_var) + if (omp_privatize_by_reference (new_var) && (TREE_CODE (TREE_TYPE (new_var)) != POINTER_TYPE || DECL_BY_REFERENCE (var))) { @@ -12684,7 +12692,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) } map_cnt++; var = OMP_CLAUSE_DECL (c); - if (!omp_is_reference (var) + if (!omp_privatize_by_reference (var) && !is_gimple_reg_type (TREE_TYPE (var))) { tree new_var = lookup_decl (var, ctx); @@ -12751,7 +12759,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) DECL_HAS_VALUE_EXPR_P (new_var) = 1; } else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR - && !omp_is_reference (var) + && !omp_privatize_by_reference (var) && !omp_is_allocatable_or_ptr (var) && !lang_hooks.decls.omp_array_data (var, true)) || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE) @@ -12974,7 +12982,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) { gcc_assert (is_gimple_omp_oacc (ctx->stmt)); - if (!omp_is_reference (var)) + if (!omp_privatize_by_reference (var)) { if (is_gimple_reg (var) && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) @@ -13137,7 +13145,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (is_gimple_omp_oacc (ctx->stmt)) goto oacc_firstprivate_map; ovar = OMP_CLAUSE_DECL (c); - if (omp_is_reference (ovar)) + if (omp_privatize_by_reference (ovar)) talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar))); else talign = DECL_ALIGN_UNIT (ovar); @@ -13145,7 +13153,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) x = build_sender_ref (ovar, ctx); tkind = GOMP_MAP_FIRSTPRIVATE; type = TREE_TYPE (ovar); - if (omp_is_reference (ovar)) + if (omp_privatize_by_reference (ovar)) type = TREE_TYPE (type); if ((INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) <= POINTER_SIZE) @@ -13153,7 +13161,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) { tkind = GOMP_MAP_FIRSTPRIVATE_INT; tree t = var; - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) t = build_simple_mem_ref (var); else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) suppress_warning (var); @@ -13162,7 +13170,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) t = fold_convert (TREE_TYPE (x), t); gimplify_assign (x, t, &ilist); } - else if (omp_is_reference (var)) + else if (omp_privatize_by_reference (var)) gimplify_assign (x, var, &ilist); else if (is_gimple_reg (var)) { @@ -13181,7 +13189,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) } if (tkind == GOMP_MAP_FIRSTPRIVATE_INT) s = size_int (0); - else if (omp_is_reference (ovar)) + else if (omp_privatize_by_reference (ovar)) s = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ovar))); else s = TYPE_SIZE_UNIT (TREE_TYPE (ovar)); @@ -13236,13 +13244,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (lang_hooks.decls.omp_array_data (ovar, true)) var = lang_hooks.decls.omp_array_data (ovar, false); else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR - && !omp_is_reference (ovar) + && !omp_privatize_by_reference (ovar) && !omp_is_allocatable_or_ptr (ovar)) || TREE_CODE (type) == ARRAY_TYPE) var = build_fold_addr_expr (var); else { - if (omp_is_reference (ovar) + if (omp_privatize_by_reference (ovar) || omp_check_optional_argument (ovar, false) || omp_is_allocatable_or_ptr (ovar)) { @@ -13251,7 +13259,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) && TREE_CODE (type) != ARRAY_TYPE && ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR && !omp_is_allocatable_or_ptr (ovar)) - || (omp_is_reference (ovar) + || (omp_privatize_by_reference (ovar) && omp_is_allocatable_or_ptr (ovar)))) var = build_simple_mem_ref (var); var = fold_convert (TREE_TYPE (x), var); @@ -13366,13 +13374,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (is_gimple_omp_oacc (ctx->stmt)) break; var = OMP_CLAUSE_DECL (c); - if (omp_is_reference (var) + if (omp_privatize_by_reference (var) || is_gimple_reg_type (TREE_TYPE (var))) { tree new_var = lookup_decl (var, ctx); tree type; type = TREE_TYPE (var); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) type = TREE_TYPE (type); if ((INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) <= POINTER_SIZE) @@ -13384,7 +13392,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) x = fold_convert (type, x); gimplify_expr (&x, &new_body, NULL, is_gimple_val, fb_rvalue); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { tree v = create_tmp_var_raw (type, get_name (var)); gimple_add_tmp_var (v); @@ -13398,7 +13406,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) } else { - x = build_receiver_ref (var, !omp_is_reference (var), ctx); + bool by_ref = !omp_privatize_by_reference (var); + x = build_receiver_ref (var, by_ref, ctx); gimplify_expr (&x, &new_body, NULL, is_gimple_val, fb_rvalue); gimple_seq_add_stmt (&new_body, @@ -13422,7 +13431,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (is_gimple_omp_oacc (ctx->stmt)) break; var = OMP_CLAUSE_DECL (c); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { location_t clause_loc = OMP_CLAUSE_LOCATION (c); tree new_var = lookup_decl (var, ctx); @@ -13465,7 +13474,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (is_array_data) { - bool is_ref = omp_is_reference (var); + bool is_ref = omp_privatize_by_reference (var); do_optional_check = true; /* First, we copy the descriptor data from the host; then we update its data to point to the target address. */ @@ -13509,7 +13518,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple_build_assign (new_var, x)); } else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR - && !omp_is_reference (var) + && !omp_privatize_by_reference (var) && !omp_is_allocatable_or_ptr (var)) || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE) { @@ -13526,13 +13535,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) { tree type = TREE_TYPE (var); new_var = lookup_decl (var, ctx); - if (omp_is_reference (var)) + if (omp_privatize_by_reference (var)) { type = TREE_TYPE (type); if (POINTER_TYPE_P (type) && TREE_CODE (type) != ARRAY_TYPE && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR - || (omp_is_reference (var) + || (omp_privatize_by_reference (var) && omp_is_allocatable_or_ptr (var)))) { tree v = create_tmp_var_raw (type, get_name (var)); @@ -13650,7 +13659,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) offset)); } else - is_ref = omp_is_reference (var); + is_ref = omp_privatize_by_reference (var); if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_REFERENCE) is_ref = false; bool ref_to_array = false; @@ -13730,7 +13739,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple_seq_add_stmt (&new_body, gimple_build_assign (new_pvar, x)); } - else if (omp_is_reference (var) && !is_gimple_omp_oacc (ctx->stmt)) + else if (omp_privatize_by_reference (var) + && !is_gimple_omp_oacc (ctx->stmt)) { location_t clause_loc = OMP_CLAUSE_LOCATION (c); tree new_var = lookup_decl (var, ctx); -- 2.25.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gomp] Add langhook, so that Fortran can privatize variables by reference 2021-08-31 14:28 ` Thomas Schwinge @ 2021-08-31 14:45 ` Jakub Jelinek 0 siblings, 0 replies; 11+ messages in thread From: Jakub Jelinek @ 2021-08-31 14:45 UTC (permalink / raw) To: Thomas Schwinge; +Cc: gcc-patches On Tue, Aug 31, 2021 at 04:28:19PM +0200, Thomas Schwinge wrote: > >From fb29fe81b4c8e880b32d68351385d8a42c97934b Mon Sep 17 00:00:00 2001 > From: Thomas Schwinge <thomas@codesourcery.com> > Date: Wed, 29 May 2019 18:59:46 +0200 > Subject: [PATCH] [OMP] Standardize on 'omp_privatize_by_reference' > > ... instead of 'omp_is_reference' vs. > 'lang_hooks.decls.omp_privatize_by_reference'. > > gcc/ > * omp-general.h (omp_is_reference): Rename to... > (omp_privatize_by_reference): ... this. Adjust all users... > * omp-general.c: ... here, ... > * gimplify.c: ... here, ... > * omp-expand.c: ... here, ... > * omp-low.c: ... here. Ok for trunk. > diff --git a/gcc/gimplify.c b/gcc/gimplify.c > index 070d0e4df45..cab4089192a 100644 > --- a/gcc/gimplify.c > +++ b/gcc/gimplify.c > @@ -1831,7 +1831,8 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) > gimplify_and_add (init, seq_p); > ggc_free (init); > /* Clear TREE_READONLY if we really have an initialization. */ > - if (!DECL_INITIAL (decl) && !omp_is_reference (decl)) > + if (!DECL_INITIAL (decl) > + && !omp_privatize_by_reference (decl)) > TREE_READONLY (decl) = 0; > } > else > @@ -7064,7 +7065,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags) > omp_notice_variable (ctx, TYPE_SIZE_UNIT (TREE_TYPE (decl)), true); > } > else if ((flags & (GOVD_MAP | GOVD_LOCAL)) == 0 > - && lang_hooks.decls.omp_privatize_by_reference (decl)) > + && omp_privatize_by_reference (decl)) > { > omp_firstprivatize_type_sizes (ctx, TREE_TYPE (decl)); > > @@ -7322,7 +7323,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags) > bool declared = is_oacc_declared (decl); > tree type = TREE_TYPE (decl); > > - if (lang_hooks.decls.omp_privatize_by_reference (decl)) > + if (omp_privatize_by_reference (decl)) > type = TREE_TYPE (type); > > /* For Fortran COMMON blocks, only used variables in those blocks are > @@ -7586,7 +7587,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) > tree type = TREE_TYPE (decl); > > if (gimplify_omp_ctxp->target_firstprivatize_array_bases > - && lang_hooks.decls.omp_privatize_by_reference (decl)) > + && omp_privatize_by_reference (decl)) > type = TREE_TYPE (type); > if (!lang_hooks.types.omp_mappable_type (type)) > { > @@ -7660,7 +7661,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) > n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t); > n2->value |= GOVD_SEEN; > } > - else if (lang_hooks.decls.omp_privatize_by_reference (decl) > + else if (omp_privatize_by_reference (decl) > && TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))) > && (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl)))) > != INTEGER_CST)) > @@ -7785,7 +7786,7 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate) > if (copyprivate) > return true; > > - if (lang_hooks.decls.omp_privatize_by_reference (decl)) > + if (omp_privatize_by_reference (decl)) > return false; > > /* Treat C++ privatized non-static data members outside > @@ -10373,7 +10374,7 @@ omp_shared_to_firstprivate_optimizable_decl_p (tree decl) > HOST_WIDE_INT len = int_size_in_bytes (type); > if (len == -1 || len > 4 * POINTER_SIZE / BITS_PER_UNIT) > return false; > - if (lang_hooks.decls.omp_privatize_by_reference (decl)) > + if (omp_privatize_by_reference (decl)) > return false; > return true; > } > @@ -10698,7 +10699,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) > OMP_CLAUSE_CHAIN (clause) = nc; > } > else if (gimplify_omp_ctxp->target_firstprivatize_array_bases > - && lang_hooks.decls.omp_privatize_by_reference (decl)) > + && omp_privatize_by_reference (decl)) > { > OMP_CLAUSE_DECL (clause) = build_simple_mem_ref (decl); > OMP_CLAUSE_SIZE (clause) > diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c > index 66c64f5a37b..7ce0663ba70 100644 > --- a/gcc/omp-expand.c > +++ b/gcc/omp-expand.c > @@ -4232,9 +4232,8 @@ expand_omp_for_generic (struct omp_region *region, > && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) > { > tree d = OMP_CLAUSE_DECL (c); > - bool is_ref = omp_is_reference (d); > tree t = d, a, dest; > - if (is_ref) > + if (omp_privatize_by_reference (t)) > t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); > tree type = TREE_TYPE (t); > if (POINTER_TYPE_P (type)) > @@ -5236,9 +5235,8 @@ expand_omp_for_static_nochunk (struct omp_region *region, > && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) > { > tree d = OMP_CLAUSE_DECL (c); > - bool is_ref = omp_is_reference (d); > tree t = d, a, dest; > - if (is_ref) > + if (omp_privatize_by_reference (t)) > t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); > if (itercnt == NULL_TREE) > { > @@ -5952,9 +5950,8 @@ expand_omp_for_static_chunk (struct omp_region *region, > && !OMP_CLAUSE_LINEAR_NO_COPYIN (c)) > { > tree d = OMP_CLAUSE_DECL (c); > - bool is_ref = omp_is_reference (d); > tree t = d, a, dest; > - if (is_ref) > + if (omp_privatize_by_reference (t)) > t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t); > tree type = TREE_TYPE (t); > if (POINTER_TYPE_P (type)) > diff --git a/gcc/omp-general.c b/gcc/omp-general.c > index b46a537e281..cc6aecb1d66 100644 > --- a/gcc/omp-general.c > +++ b/gcc/omp-general.c > @@ -79,10 +79,11 @@ omp_check_optional_argument (tree decl, bool for_present_check) > return lang_hooks.decls.omp_check_optional_argument (decl, for_present_check); > } > > -/* Return true if DECL is a reference type. */ > +/* True if OpenMP should privatize what this DECL points to rather > + than the DECL itself. */ > > bool > -omp_is_reference (tree decl) > +omp_privatize_by_reference (tree decl) > { > return lang_hooks.decls.omp_privatize_by_reference (decl); > } > diff --git a/gcc/omp-general.h b/gcc/omp-general.h > index 5c3e0f0e205..6a1468d2798 100644 > --- a/gcc/omp-general.h > +++ b/gcc/omp-general.h > @@ -93,7 +93,7 @@ struct omp_for_data > extern tree omp_find_clause (tree clauses, enum omp_clause_code kind); > extern bool omp_is_allocatable_or_ptr (tree decl); > extern tree omp_check_optional_argument (tree decl, bool for_present_check); > -extern bool omp_is_reference (tree decl); > +extern bool omp_privatize_by_reference (tree decl); > extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code, > tree *n2, tree v, tree step); > extern tree omp_get_for_step_from_incr (location_t loc, tree incr); > diff --git a/gcc/omp-low.c b/gcc/omp-low.c > index a0b41afa3eb..bbade6f1eb8 100644 > --- a/gcc/omp-low.c > +++ b/gcc/omp-low.c > @@ -736,7 +736,7 @@ build_outer_var_ref (tree var, omp_context *ctx, > } > else if (outer) > x = lookup_decl (var, outer); > - else if (omp_is_reference (var)) > + else if (omp_privatize_by_reference (var)) > /* This can happen with orphaned constructs. If var is reference, it is > possible it is shared and as such valid. */ > x = var; > @@ -759,7 +759,7 @@ build_outer_var_ref (tree var, omp_context *ctx, > } > } > > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > x = build_simple_mem_ref (x); > > return x; > @@ -824,7 +824,8 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx) > } > else if (by_ref) > type = build_pointer_type (type); > - else if ((mask & (32 | 3)) == 1 && omp_is_reference (var)) > + else if ((mask & (32 | 3)) == 1 > + && omp_privatize_by_reference (var)) > type = TREE_TYPE (type); > > field = build_decl (DECL_SOURCE_LOCATION (var), > @@ -1217,7 +1218,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > if ((! TREE_READONLY (decl) && !OMP_CLAUSE_SHARED_READONLY (c)) > || TREE_ADDRESSABLE (decl) > || by_ref > - || omp_is_reference (decl)) > + || omp_privatize_by_reference (decl)) > { > by_ref = use_pointer_for_field (decl, ctx); > install_var_field (decl, by_ref, 3, ctx); > @@ -1368,7 +1369,10 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > && is_gimple_omp_offloaded (ctx->stmt)) > { > if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) > - install_var_field (decl, !omp_is_reference (decl), 3, ctx); > + { > + by_ref = !omp_privatize_by_reference (decl); > + install_var_field (decl, by_ref, 3, ctx); > + } > else if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) > install_var_field (decl, true, 3, ctx); > else > @@ -1396,7 +1400,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > by_ref = use_pointer_for_field (decl, NULL); > > if (is_task_ctx (ctx) > - && (global || by_ref || omp_is_reference (decl))) > + && (global || by_ref || omp_privatize_by_reference (decl))) > { > if (ctx->allocate_map > && ctx->allocate_map->get (decl)) > @@ -1420,7 +1424,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > if (lang_hooks.decls.omp_array_data (decl, true)) > install_var_field (decl, false, 19, ctx); > else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR > - && !omp_is_reference (decl) > + && !omp_privatize_by_reference (decl) > && !omp_is_allocatable_or_ptr (decl)) > || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) > install_var_field (decl, true, 11, ctx); > @@ -4694,7 +4698,7 @@ lower_private_allocate (tree var, tree new_var, tree &allocator, > allocator = *allocatorp; > if (allocator == NULL_TREE) > return false; > - if (!is_ref && omp_is_reference (var)) > + if (!is_ref && omp_privatize_by_reference (var)) > { > allocator = NULL_TREE; > return false; > @@ -4792,7 +4796,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > case OMP_CLAUSE_LASTPRIVATE: > if (is_variable_sized (OMP_CLAUSE_DECL (c))) > sctx.max_vf = 1; > - else if (omp_is_reference (OMP_CLAUSE_DECL (c))) > + else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c))) > { > tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c))); > if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype))) > @@ -4804,7 +4808,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF > || is_variable_sized (OMP_CLAUSE_DECL (c))) > sctx.max_vf = 1; > - else if (omp_is_reference (OMP_CLAUSE_DECL (c))) > + else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c))) > { > tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c))); > if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype))) > @@ -4966,7 +4970,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > original address, it is always the address of the > global variable itself. */ > if (!DECL_P (var) > - || omp_is_reference (var) > + || omp_privatize_by_reference (var) > || !is_global_var > (maybe_lookup_decl_in_outer_ctx (var, ctx))) > { > @@ -5407,10 +5411,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > tree ref = build_outer_var_ref (var, ctx); > /* For ref build_outer_var_ref already performs this. */ > if (TREE_CODE (d) == INDIRECT_REF) > - gcc_assert (omp_is_reference (var)); > + gcc_assert (omp_privatize_by_reference (var)); > else if (TREE_CODE (d) == ADDR_EXPR) > ref = build_fold_addr_expr (ref); > - else if (omp_is_reference (var)) > + else if (omp_privatize_by_reference (var)) > ref = build_fold_addr_expr (ref); > ref = fold_convert_loc (clause_loc, ptype, ref); > if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) > @@ -5557,7 +5561,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > bool by_ref = use_pointer_for_field (var, ctx); > x = build_receiver_ref (var, by_ref, ctx); > } > - if (!omp_is_reference (var)) > + if (!omp_privatize_by_reference (var)) > x = build_fold_addr_expr (x); > x = fold_convert (ptr_type_node, x); > unsigned cnt = task_reduction_cnt - 1; > @@ -5573,7 +5577,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > else if (pass == 3) > { > tree type = TREE_TYPE (new_var); > - if (!omp_is_reference (var)) > + if (!omp_privatize_by_reference (var)) > type = build_pointer_type (type); > if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION) > { > @@ -5601,7 +5605,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > } > x = fold_convert (type, x); > tree t; > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gimplify_assign (new_var, x, ilist); > t = new_var; > @@ -5662,7 +5666,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > gimplify_assign (ptr, x, ilist); > } > } > - else if (omp_is_reference (var) > + else if (omp_privatize_by_reference (var) > && (c_kind != OMP_CLAUSE_FIRSTPRIVATE > || !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c))) > { > @@ -5827,11 +5831,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > || (gimple_omp_for_index (ctx->stmt, 0) > != new_var))) > || OMP_CLAUSE_CODE (c) == OMP_CLAUSE__CONDTEMP_ > - || omp_is_reference (var)) > + || omp_privatize_by_reference (var)) > && lower_rec_simd_input_clauses (new_var, ctx, &sctx, > ivar, lvar)) > { > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > tree new_vard = TREE_OPERAND (new_var, 0); > @@ -5917,7 +5921,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > } > break; > } > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > tree new_vard = TREE_OPERAND (new_var, 0); > @@ -5987,7 +5991,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > case OMP_CLAUSE_FIRSTPRIVATE: > if (is_task_ctx (ctx)) > { > - if ((omp_is_reference (var) > + if ((omp_privatize_by_reference (var) > && !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c)) > || is_variable_sized (var)) > goto do_dtor; > @@ -6014,7 +6018,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > } > } > if (OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c) > - && omp_is_reference (var)) > + && omp_privatize_by_reference (var)) > { > x = build_outer_var_ref (var, ctx); > gcc_assert (TREE_CODE (x) == MEM_REF > @@ -6059,7 +6063,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > > if (OMP_CLAUSE_LINEAR_ARRAY (c)) > { > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > tree new_vard = TREE_OPERAND (new_var, 0); > @@ -6096,11 +6100,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > > if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR > || TREE_ADDRESSABLE (new_var) > - || omp_is_reference (var)) > + || omp_privatize_by_reference (var)) > && lower_rec_simd_input_clauses (new_var, ctx, &sctx, > ivar, lvar)) > { > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > tree new_vard = TREE_OPERAND (new_var, 0); > @@ -6137,7 +6141,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > gimplify_and_add (x, &llist[1]); > break; > } > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > tree new_vard = TREE_OPERAND (new_var, 0); > @@ -6220,14 +6224,14 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > NULL_TREE); > x = build_outer_var_ref (var, ctx); > > - if (omp_is_reference (var) > + if (omp_privatize_by_reference (var) > && !useless_type_conversion_p (ptype, TREE_TYPE (x))) > x = build_fold_addr_expr_loc (clause_loc, x); > } > SET_DECL_VALUE_EXPR (placeholder, x); > DECL_HAS_VALUE_EXPR_P (placeholder) = 1; > tree new_vard = new_var; > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > new_vard = TREE_OPERAND (new_var, 0); > @@ -6387,7 +6391,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > for it because it is undesirable if SIMD arrays are used. > But if they aren't used, we need to emit the deferred > initialization now. */ > - else if (omp_is_reference (var) && is_simd) > + else if (omp_privatize_by_reference (var) && is_simd) > handle_simd_reference (clause_loc, new_vard, ilist); > > tree lab2 = NULL_TREE; > @@ -6582,7 +6586,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > bool is_truth_op > = (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR); > tree new_vard = new_var; > - if (is_simd && omp_is_reference (var)) > + if (is_simd && omp_privatize_by_reference (var)) > { > gcc_assert (TREE_CODE (new_var) == MEM_REF); > new_vard = TREE_OPERAND (new_var, 0); > @@ -6653,7 +6657,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > lower_private_allocate (var, new_var, allocator, > allocate_ptr, ilist, ctx, > false, NULL_TREE); > - if (omp_is_reference (var) && is_simd) > + if (omp_privatize_by_reference (var) && is_simd) > handle_simd_reference (clause_loc, new_vard, ilist); > if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION > && OMP_CLAUSE_REDUCTION_INSCAN (c)) > @@ -7254,7 +7258,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *body_p, > } > if (!x) > x = build_outer_var_ref (var, ctx, OMP_CLAUSE_LASTPRIVATE); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > new_var = build_simple_mem_ref_loc (clause_loc, new_var); > x = lang_hooks.decls.omp_clause_assign_op (c, x, new_var); > gimplify_and_add (x, this_stmt_list); > @@ -7400,7 +7404,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, > && maybe_lookup_field (orig, outer) && !is_private) > { > ref_to_res = build_receiver_ref (orig, false, outer); > - if (omp_is_reference (orig)) > + if (omp_privatize_by_reference (orig)) > ref_to_res = build_simple_mem_ref (ref_to_res); > > tree type = TREE_TYPE (var); > @@ -7430,7 +7434,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, > if (!ref_to_res) > ref_to_res = integer_zero_node; > > - if (omp_is_reference (orig)) > + if (omp_privatize_by_reference (orig)) > { > tree type = TREE_TYPE (var); > const char *id = IDENTIFIER_POINTER (DECL_NAME (var)); > @@ -7610,7 +7614,8 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, > } > } > new_var = lookup_decl (var, ctx); > - if (var == OMP_CLAUSE_DECL (c) && omp_is_reference (var)) > + if (var == OMP_CLAUSE_DECL (c) > + && omp_privatize_by_reference (var)) > new_var = build_simple_mem_ref_loc (clause_loc, new_var); > ref = build_outer_var_ref (var, ctx, ccode); > code = OMP_CLAUSE_REDUCTION_CODE (c); > @@ -7679,7 +7684,8 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, > if (TREE_CODE (d) == INDIRECT_REF) > { > new_var = build_simple_mem_ref_loc (clause_loc, new_var); > - gcc_assert (omp_is_reference (var) && var == orig_var); > + gcc_assert (omp_privatize_by_reference (var) > + && var == orig_var); > } > else if (TREE_CODE (d) == ADDR_EXPR) > { > @@ -7692,7 +7698,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, > else > { > gcc_assert (orig_var == var); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > ref = build_fold_addr_expr (ref); > } > if (DECL_P (v)) > @@ -7778,7 +7784,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, > { > tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); > > - if (omp_is_reference (var) > + if (omp_privatize_by_reference (var) > && !useless_type_conversion_p (TREE_TYPE (placeholder), > TREE_TYPE (ref))) > ref = build_fold_addr_expr_loc (clause_loc, ref); > @@ -7864,7 +7870,7 @@ lower_copyprivate_clauses (tree clauses, gimple_seq *slist, gimple_seq *rlist, > ref); > ref = build_fold_indirect_ref_loc (clause_loc, ref); > } > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > ref = fold_convert_loc (clause_loc, TREE_TYPE (new_var), ref); > ref = build_simple_mem_ref_loc (clause_loc, ref); > @@ -8017,7 +8023,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, > break; > > case OMP_CLAUSE_LASTPRIVATE: > - if (by_ref || omp_is_reference (val)) > + if (by_ref || omp_privatize_by_reference (val)) > { > if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c)) > continue; > @@ -8039,7 +8045,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, > if (is_task_ctx (ctx)) > by_ref = use_pointer_for_field (val, ctx); > else > - do_out = !(by_ref || omp_is_reference (val)); > + do_out = !(by_ref || omp_privatize_by_reference (val)); > } > else > by_ref = TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE; > @@ -8913,7 +8919,7 @@ omp_task_reduction_iterate (int pass, enum tree_code code, > } > else > { > - if (omp_is_reference (*decl)) > + if (omp_privatize_by_reference (*decl)) > *type = TREE_TYPE (*type); > if (pass != (!TREE_CONSTANT (TYPE_SIZE_UNIT (*type)))) > continue; > @@ -9201,7 +9207,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, > else > { > t = ref = maybe_lookup_decl_in_outer_ctx (var, ctx); > - if (!omp_is_reference (decl)) > + if (!omp_privatize_by_reference (decl)) > t = build_fold_addr_expr (t); > } > t = fold_convert (pointer_sized_int_node, t); > @@ -9284,7 +9290,8 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, > build_simple_mem_ref (ptr), field, NULL_TREE); > > enum tree_code rcode = OMP_CLAUSE_REDUCTION_CODE (c); > - if (TREE_CODE (decl) != MEM_REF && omp_is_reference (decl)) > + if (TREE_CODE (decl) != MEM_REF > + && omp_privatize_by_reference (decl)) > ref = build_simple_mem_ref (ref); > /* reduction(-:var) sums up the partial results, so it acts > identically to reduction(+:var). */ > @@ -9400,7 +9407,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, > gimple_seq_add_stmt (end, g); > gimple_seq_add_stmt (end, gimple_build_label (lab5)); > } > - if (omp_is_reference (decl) > + if (omp_privatize_by_reference (decl) > && !useless_type_conversion_p (TREE_TYPE (placeholder), > TREE_TYPE (ref))) > ref = build_fold_addr_expr_loc (OMP_CLAUSE_LOCATION (c), ref); > @@ -9414,7 +9421,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, > gcc_assert (d); > if (DECL_HAS_VALUE_EXPR_P (d)) > oldv = DECL_VALUE_EXPR (d); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > tree v = fold_convert (TREE_TYPE (d), > build_fold_addr_expr (new_var)); > @@ -9986,7 +9993,7 @@ lower_omp_scan (gimple_stmt_iterator *gsi_p, omp_context *ctx) > tree var4 = NULL_TREE; > tree lane0 = NULL_TREE; > tree new_vard = new_var; > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > new_var = build_simple_mem_ref_loc (clause_loc, new_var); > val = new_var; > @@ -10853,7 +10860,7 @@ lower_omp_for_scan (gimple_seq *body_p, gimple_seq *dlist, gomp_for *stmt, > tree new_var = lookup_decl (var, ctx); > tree var3 = NULL_TREE; > tree new_vard = new_var; > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > new_var = build_simple_mem_ref_loc (clause_loc, new_var); > if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) > { > @@ -12026,7 +12033,8 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) > sf = *tcctx.cb.decl_map->get (sf); > src = build_simple_mem_ref_loc (loc, sarg); > src = omp_build_component_ref (src, sf); > - if (use_pointer_for_field (decl, NULL) || omp_is_reference (decl)) > + if (use_pointer_for_field (decl, NULL) > + || omp_privatize_by_reference (decl)) > src = build_simple_mem_ref_loc (loc, src); > } > else > @@ -12646,7 +12654,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) > { > gcc_assert (is_gimple_omp_oacc (ctx->stmt)); > - if (omp_is_reference (new_var) > + if (omp_privatize_by_reference (new_var) > && (TREE_CODE (TREE_TYPE (new_var)) != POINTER_TYPE > || DECL_BY_REFERENCE (var))) > { > @@ -12684,7 +12692,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > } > map_cnt++; > var = OMP_CLAUSE_DECL (c); > - if (!omp_is_reference (var) > + if (!omp_privatize_by_reference (var) > && !is_gimple_reg_type (TREE_TYPE (var))) > { > tree new_var = lookup_decl (var, ctx); > @@ -12751,7 +12759,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > DECL_HAS_VALUE_EXPR_P (new_var) = 1; > } > else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR > - && !omp_is_reference (var) > + && !omp_privatize_by_reference (var) > && !omp_is_allocatable_or_ptr (var) > && !lang_hooks.decls.omp_array_data (var, true)) > || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE) > @@ -12974,7 +12982,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) > { > gcc_assert (is_gimple_omp_oacc (ctx->stmt)); > - if (!omp_is_reference (var)) > + if (!omp_privatize_by_reference (var)) > { > if (is_gimple_reg (var) > && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) > @@ -13137,7 +13145,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > if (is_gimple_omp_oacc (ctx->stmt)) > goto oacc_firstprivate_map; > ovar = OMP_CLAUSE_DECL (c); > - if (omp_is_reference (ovar)) > + if (omp_privatize_by_reference (ovar)) > talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar))); > else > talign = DECL_ALIGN_UNIT (ovar); > @@ -13145,7 +13153,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > x = build_sender_ref (ovar, ctx); > tkind = GOMP_MAP_FIRSTPRIVATE; > type = TREE_TYPE (ovar); > - if (omp_is_reference (ovar)) > + if (omp_privatize_by_reference (ovar)) > type = TREE_TYPE (type); > if ((INTEGRAL_TYPE_P (type) > && TYPE_PRECISION (type) <= POINTER_SIZE) > @@ -13153,7 +13161,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > { > tkind = GOMP_MAP_FIRSTPRIVATE_INT; > tree t = var; > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > t = build_simple_mem_ref (var); > else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) > suppress_warning (var); > @@ -13162,7 +13170,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > t = fold_convert (TREE_TYPE (x), t); > gimplify_assign (x, t, &ilist); > } > - else if (omp_is_reference (var)) > + else if (omp_privatize_by_reference (var)) > gimplify_assign (x, var, &ilist); > else if (is_gimple_reg (var)) > { > @@ -13181,7 +13189,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > } > if (tkind == GOMP_MAP_FIRSTPRIVATE_INT) > s = size_int (0); > - else if (omp_is_reference (ovar)) > + else if (omp_privatize_by_reference (ovar)) > s = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ovar))); > else > s = TYPE_SIZE_UNIT (TREE_TYPE (ovar)); > @@ -13236,13 +13244,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > if (lang_hooks.decls.omp_array_data (ovar, true)) > var = lang_hooks.decls.omp_array_data (ovar, false); > else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR > - && !omp_is_reference (ovar) > + && !omp_privatize_by_reference (ovar) > && !omp_is_allocatable_or_ptr (ovar)) > || TREE_CODE (type) == ARRAY_TYPE) > var = build_fold_addr_expr (var); > else > { > - if (omp_is_reference (ovar) > + if (omp_privatize_by_reference (ovar) > || omp_check_optional_argument (ovar, false) > || omp_is_allocatable_or_ptr (ovar)) > { > @@ -13251,7 +13259,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > && TREE_CODE (type) != ARRAY_TYPE > && ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR > && !omp_is_allocatable_or_ptr (ovar)) > - || (omp_is_reference (ovar) > + || (omp_privatize_by_reference (ovar) > && omp_is_allocatable_or_ptr (ovar)))) > var = build_simple_mem_ref (var); > var = fold_convert (TREE_TYPE (x), var); > @@ -13366,13 +13374,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > if (is_gimple_omp_oacc (ctx->stmt)) > break; > var = OMP_CLAUSE_DECL (c); > - if (omp_is_reference (var) > + if (omp_privatize_by_reference (var) > || is_gimple_reg_type (TREE_TYPE (var))) > { > tree new_var = lookup_decl (var, ctx); > tree type; > type = TREE_TYPE (var); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > type = TREE_TYPE (type); > if ((INTEGRAL_TYPE_P (type) > && TYPE_PRECISION (type) <= POINTER_SIZE) > @@ -13384,7 +13392,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > x = fold_convert (type, x); > gimplify_expr (&x, &new_body, NULL, is_gimple_val, > fb_rvalue); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > tree v = create_tmp_var_raw (type, get_name (var)); > gimple_add_tmp_var (v); > @@ -13398,7 +13406,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > } > else > { > - x = build_receiver_ref (var, !omp_is_reference (var), ctx); > + bool by_ref = !omp_privatize_by_reference (var); > + x = build_receiver_ref (var, by_ref, ctx); > gimplify_expr (&x, &new_body, NULL, is_gimple_val, > fb_rvalue); > gimple_seq_add_stmt (&new_body, > @@ -13422,7 +13431,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > if (is_gimple_omp_oacc (ctx->stmt)) > break; > var = OMP_CLAUSE_DECL (c); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > location_t clause_loc = OMP_CLAUSE_LOCATION (c); > tree new_var = lookup_decl (var, ctx); > @@ -13465,7 +13474,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > > if (is_array_data) > { > - bool is_ref = omp_is_reference (var); > + bool is_ref = omp_privatize_by_reference (var); > do_optional_check = true; > /* First, we copy the descriptor data from the host; then > we update its data to point to the target address. */ > @@ -13509,7 +13518,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > gimple_build_assign (new_var, x)); > } > else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR > - && !omp_is_reference (var) > + && !omp_privatize_by_reference (var) > && !omp_is_allocatable_or_ptr (var)) > || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE) > { > @@ -13526,13 +13535,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > { > tree type = TREE_TYPE (var); > new_var = lookup_decl (var, ctx); > - if (omp_is_reference (var)) > + if (omp_privatize_by_reference (var)) > { > type = TREE_TYPE (type); > if (POINTER_TYPE_P (type) > && TREE_CODE (type) != ARRAY_TYPE > && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR > - || (omp_is_reference (var) > + || (omp_privatize_by_reference (var) > && omp_is_allocatable_or_ptr (var)))) > { > tree v = create_tmp_var_raw (type, get_name (var)); > @@ -13650,7 +13659,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > offset)); > } > else > - is_ref = omp_is_reference (var); > + is_ref = omp_privatize_by_reference (var); > if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_REFERENCE) > is_ref = false; > bool ref_to_array = false; > @@ -13730,7 +13739,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > gimple_seq_add_stmt (&new_body, > gimple_build_assign (new_pvar, x)); > } > - else if (omp_is_reference (var) && !is_gimple_omp_oacc (ctx->stmt)) > + else if (omp_privatize_by_reference (var) > + && !is_gimple_omp_oacc (ctx->stmt)) > { > location_t clause_loc = OMP_CLAUSE_LOCATION (c); > tree new_var = lookup_decl (var, ctx); > -- > 2.25.1 > Jakub ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-08-31 14:46 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-10-18 7:01 [gomp] Add langhook, so that Fortran can privatize variables by reference Jakub Jelinek 2005-10-18 9:10 ` Richard Henderson 2005-10-18 9:49 ` Jakub Jelinek 2005-10-18 9:54 ` Richard Henderson 2005-10-18 10:28 ` Jakub Jelinek 2005-10-18 10:46 ` Richard Henderson 2019-05-26 17:46 ` Thomas Schwinge 2019-05-27 16:51 ` Jakub Jelinek 2019-05-29 17:12 ` Thomas Schwinge 2021-08-31 14:28 ` Thomas Schwinge 2021-08-31 14:45 ` 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).