This patch fixes a bug observed on amdgcn in which the Fortran frontend
creates function calls using the 32-bit parameters where they ought to
be 64-bit, resulting in UB.
The issue is caused by the use of "integer_zero_node" where the
definition of the function calls for "size_zero_node". I presume this
works on other architectures because the types are the same size, or
else because parameters are always 64-bit wide.
OK to commit?
Andrew
Fix fortran size_t parameter passing.
2019-05-22 Andrew Stubbs <a...@codesourcery.com>
gcc/fortran/
* trans-stmt.c (gfc_trans_critical): Use size_zero_node for
gfor_fndecl_caf_lock and gfor_fndecl_caf_unlock calls.
(gfc_trans_allocate): Use size_zero_node for gfor_fndecl_caf_sync_all
call.
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 5fa182bf05a..4314a1edb90 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -1579,9 +1579,9 @@ gfc_trans_critical (gfc_code *code)
token = gfc_get_symbol_decl (code->resolved_sym);
token = GFC_TYPE_ARRAY_CAF_TOKEN (TREE_TYPE (token));
tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7,
- token, integer_zero_node, integer_one_node,
+ token, size_zero_node, integer_one_node,
null_pointer_node, null_pointer_node,
- null_pointer_node, integer_zero_node);
+ null_pointer_node, size_zero_node);
gfc_add_expr_to_block (&block, tmp);
/* It guarantees memory consistency within the same segment */
@@ -1602,9 +1602,9 @@ gfc_trans_critical (gfc_code *code)
if (flag_coarray == GFC_FCOARRAY_LIB)
{
tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_unlock, 6,
- token, integer_zero_node, integer_one_node,
+ token, size_zero_node, integer_one_node,
null_pointer_node, null_pointer_node,
- integer_zero_node);
+ size_zero_node);
gfc_add_expr_to_block (&block, tmp);
/* It guarantees memory consistency within the same segment */
@@ -6774,7 +6774,7 @@ gfc_trans_allocate (gfc_code * code)
/* Add a sync all after the allocation has been executed. */
tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all,
3, null_pointer_node, null_pointer_node,
- integer_zero_node);
+ size_zero_node);
gfc_add_expr_to_block (&post, tmp);
}