diff options
author | Andrew Stubbs <ams@codesourcery.com> | 2018-09-21 11:25:39 +0000 |
---|---|---|
committer | Andrew Stubbs <ams@gcc.gnu.org> | 2018-09-21 11:25:39 +0000 |
commit | b6895597cd59f77077ccdecdacfdd34bf77b5a07 (patch) | |
tree | 740793b57e11715479275df79c102045b79d2820 /gcc/builtins.c | |
parent | 518196cb3fce647789ff4c9f4679bb7087030158 (diff) | |
download | gcc-b6895597cd59f77077ccdecdacfdd34bf77b5a07.zip gcc-b6895597cd59f77077ccdecdacfdd34bf77b5a07.tar.gz gcc-b6895597cd59f77077ccdecdacfdd34bf77b5a07.tar.bz2 |
Propagate address spaces to builtins.
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-21 Andrew Stubbs <ams@codesourcery.com>
Julian Brown <julian@codesourcery.com>
gcc/
* builtins.c (get_builtin_sync_mem): Handle address spaces.
Co-Authored-By: Julian Brown <julian@codesourcery.com>
From-SVN: r264467
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 3f39d10..1d4de09 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5863,14 +5863,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); - addr = expand_expr (loc, NULL_RTX, ptr_mode, EXPAND_SUM); - 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), |