Thanks a lot for Wilco’s help on this bug. Yes, Aarch64 does NOT do anything wrong.
The implementation of __builtin_update_setjmp_buf is not correct. It takes a pointer as an operand and treats the Mode of the pointer as Pmode, which is not correct. a conversion from ptr_mode to Pmode is needed for this pointer. bootstrapped on aarch64-unknown-linux-gnu. testing on aarch64-unknown-linux-gnu is running. the new patch is: ===== gcc/ChangeLog * builtins.c (expand_builtin_update_setjmp_buf): Add a converstion to Pmode from the buf_addr. gcc/testsuite/ChangeLog PR middle-end/80295 * gcc.target/aarch64/pr80295.c: New test. --- gcc/builtins.c | 1 + gcc/testsuite/gcc.target/aarch64/pr80295.c | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/pr80295.c diff --git a/gcc/builtins.c b/gcc/builtins.c index c8a5ea6..01fb08b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1199,6 +1199,7 @@ void expand_builtin_update_setjmp_buf (rtx buf_addr) { machine_mode sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL); + buf_addr = convert_memory_address (Pmode, buf_addr); rtx stack_save = gen_rtx_MEM (sa_mode, memory_address diff --git a/gcc/testsuite/gcc.target/aarch64/pr80295.c b/gcc/testsuite/gcc.target/aarch64/pr80295.c new file mode 100644 index 0000000..b3866d8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr80295.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=ilp32" } */ + +void f (void *b) +{ + __builtin_update_setjmp_buf (b); +} + -- 1.9.1 > >> On Oct 5, 2017, at 11:50 AM, Richard Earnshaw (lists) >> <richard.earns...@arm.com> wrote: >> >> On 25/09/17 17:35, Qing Zhao wrote: >>> >>> --- a/gcc/config/aarch64/aarch64.h >>> +++ b/gcc/config/aarch64/aarch64.h >>> @@ -782,7 +782,7 @@ typedef struct >>> /* Specify the machine mode that the hardware addresses have. >>> After generation of rtl, the compiler makes no further distinction >>> between pointers and any other objects of this machine mode. */ >>> -#define Pmode DImode >>> +#define Pmode (TARGET_ILP32 ? SImode : DImode) >> >> This is wrong. AArch64 has both ptr_mode and Pmode. Pmode must always >> be DImode as (internally) all addresses must be 64-bit. ptr_mode >> reflects the ABI choice of 32/64-bit language level addresses. The >> register SP must always be a 64-bit value, even when all the top 32 bits >> are zero. >