This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/25] Propagate address spaces to builtins.

Hi all,

On 9/5/18 12:48 PM, wrote:

At present, pointers passed to builtin functions, including atomic operators,
are stripped of their address space properties.  This doesn't seem to be
deliberate, it just omits to copy them.

Not only that, but it forces pointer sizes to Pmode, which isn't appropriate
for all address spaces.

This patch attempts to correct both issues.  It works for GCN atomics and
GCN OpenACC gang-private variables.

2018-09-05  Andrew Stubbs  <>
            Julian Brown  <>

        * builtins.c (get_builtin_sync_mem): Handle address spaces.

Sorry for responding to this so late. I'm testing a rebased version of Richard's OOL atomic patches [1] and am hitting an ICE building the -mabi=ilp32 libgfortran multilib for aarch64-none-elf:

0x7284db emit_library_call_value_1(int, rtx_def*, rtx_def*, libcall_type, machine_mode, int, std::pair<rtx_def*, machine_mode>*)
0x1037817 emit_library_call_value(rtx_def*, rtx_def*, libcall_type, machine_mode, rtx_def*, machine_mode, rtx_def*, machine_mode, rtx_def*, machine_mode)
0x1037817 aarch64_expand_compare_and_swap(rtx_def**)
0x1353a43 gen_atomic_compare_and_swapsi(rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*)
0xb1f9f1 insn_gen_fn::operator()(rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*, rtx_def*) const
0xb1f9f1 maybe_gen_insn(insn_code, unsigned int, expand_operand*)
0xb1fa78 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
0xb21024 expand_atomic_compare_and_swap(rtx_def**, rtx_def**, rtx_def*, rtx_def*, rtx_def*, bool, memmodel, memmodel)
0x709bd3 expand_builtin_atomic_compare_exchange
0x71a4e9 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
0x88b746 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
0x88cce6 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
0x74cb47 expand_expr
0x74cb47 expand_call_stmt
0x74cb47 expand_gimple_stmt_1
0x74cb47 expand_gimple_stmt
0x75439b expand_gimple_basic_block
0x7563ab execute
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <> for instructions.

A MEM rtx now uses a DImode address where for ILP32 we expect SImode.

This looks to be because....


 gcc/builtins.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)


diff --git a/gcc/builtins.c b/gcc/builtins.c
index 58ea747..361361c 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5781,14 +5781,21 @@ static rtx
 get_builtin_sync_mem (tree loc, machine_mode mode)
   rtx addr, mem;
+  int addr_space = TYPE_ADDR_SPACE (POINTER_TYPE_P (TREE_TYPE (loc))
+				    ? TREE_TYPE (TREE_TYPE (loc))
+				    : TREE_TYPE (loc));
+  scalar_int_mode addr_mode = targetm.addr_space.address_mode (addr_space);
... This now returns Pmode (the default for the hook) for aarch64 ILP32, which is always DImode.

-  addr = expand_expr (loc, NULL_RTX, ptr_mode, EXPAND_SUM);

Before this patch we used ptr_mode, which does the right thing for AArch64 ILP32.
Do you think we should just be implementing targetm.addr_space.address_mode for AArch64 to return SImode for ILP32?


-  addr = convert_memory_address (Pmode, addr);
+  addr = expand_expr (loc, NULL_RTX, addr_mode, EXPAND_SUM);
/* Note that we explicitly do not want any alias information for this
      memory, so that we kill all other live memories.  Otherwise we don't
      satisfy the full barrier semantics of the intrinsic.  */
-  mem = validize_mem (gen_rtx_MEM (mode, addr));
+  mem = gen_rtx_MEM (mode, addr);
+  set_mem_addr_space (mem, addr_space);
+  mem = validize_mem (mem);
/* The alignment needs to be at least according to that of the mode. */
   set_mem_align (mem, MAX (GET_MODE_ALIGNMENT (mode),

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]