From: Renlin Li Date: Thu, 1 Feb 2018 21:33:05 +0000 (+0000) Subject: [PR83370][AARCH64]Use tighter register constraint for sibcall patterns. X-Git-Tag: releases/gcc-6.5.0~548 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2c7c39542ae491bc364e3bdb7bfa4ef0cb601c0;p=thirdparty%2Fgcc.git [PR83370][AARCH64]Use tighter register constraint for sibcall patterns. gcc/ backport from mainline 2018-02-01 Renlin Li PR target/83370 * config/aarch64/aarch64.c (aarch64_class_max_nregs): Handle TAILCALL_ADDR_REGS. (aarch64_register_move_cost): Likewise. * config/aarch64/aarch64.h (reg_class): Rename CALLER_SAVE_REGS to TAILCALL_ADDR_REGS. (REG_CLASS_NAMES): Likewise. (REG_CLASS_CONTENTS): Rename CALLER_SAVE_REGS to TAILCALL_ADDR_REGS. Remove IP registers. * config/aarch64/aarch64.md (Ucs): Update register constraint. gcc/testsuite/ backport from mainline 2018-02-01 Richard Sandiford PR target/83370 * gcc.target/aarch64/pr83370.c: New. From-SVN: r257315 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2e4e8180e3a..e6061b95a89b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2018-02-01 Renlin Li + + Backport from mainline + 2018-02-01 Renlin Li + + PR target/83370 + * config/aarch64/aarch64.c (aarch64_class_max_nregs): Handle + TAILCALL_ADDR_REGS. + (aarch64_register_move_cost): Likewise. + * config/aarch64/aarch64.h (reg_class): Rename CALLER_SAVE_REGS to + TAILCALL_ADDR_REGS. + (REG_CLASS_NAMES): Likewise. + (REG_CLASS_CONTENTS): Rename CALLER_SAVE_REGS to + TAILCALL_ADDR_REGS. Remove IP registers. + * config/aarch64/aarch64.md (Ucs): Update register constraint. + 2018-02-01 Bin Cheng Backport from mainline diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b2f0958abab4..cce8cf89b3c0 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -5337,7 +5337,7 @@ aarch64_class_max_nregs (reg_class_t regclass, machine_mode mode) { switch (regclass) { - case CALLER_SAVE_REGS: + case TAILCALL_ADDR_REGS: case POINTER_REGS: case GENERAL_REGS: case ALL_REGS: @@ -7383,10 +7383,10 @@ aarch64_register_move_cost (machine_mode mode, = aarch64_tune_params.regmove_cost; /* Caller save and pointer regs are equivalent to GENERAL_REGS. */ - if (to == CALLER_SAVE_REGS || to == POINTER_REGS) + if (to == TAILCALL_ADDR_REGS || to == POINTER_REGS) to = GENERAL_REGS; - if (from == CALLER_SAVE_REGS || from == POINTER_REGS) + if (from == TAILCALL_ADDR_REGS || from == POINTER_REGS) from = GENERAL_REGS; /* Moving between GPR and stack cost is the same as GP2GP. */ diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 24defeb13282..a8c0fac340aa 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -420,7 +420,7 @@ extern unsigned aarch64_architecture_version; enum reg_class { NO_REGS, - CALLER_SAVE_REGS, + TAILCALL_ADDR_REGS, GENERAL_REGS, STACK_REG, POINTER_REGS, @@ -435,7 +435,7 @@ enum reg_class #define REG_CLASS_NAMES \ { \ "NO_REGS", \ - "CALLER_SAVE_REGS", \ + "TAILCALL_ADDR_REGS", \ "GENERAL_REGS", \ "STACK_REG", \ "POINTER_REGS", \ @@ -447,7 +447,7 @@ enum reg_class #define REG_CLASS_CONTENTS \ { \ { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ - { 0x0007ffff, 0x00000000, 0x00000000 }, /* CALLER_SAVE_REGS */ \ + { 0x0004ffff, 0x00000000, 0x00000000 }, /* TAILCALL_ADDR_REGS */\ { 0x7fffffff, 0x00000000, 0x00000003 }, /* GENERAL_REGS */ \ { 0x80000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \ { 0xffffffff, 0x00000000, 0x00000003 }, /* POINTER_REGS */ \ diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index d64a7ebe36fc..8c279cb62b33 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -21,8 +21,8 @@ (define_register_constraint "k" "STACK_REG" "@internal The stack register.") -(define_register_constraint "Ucs" "CALLER_SAVE_REGS" - "@internal The caller save registers.") +(define_register_constraint "Ucs" "TAILCALL_ADDR_REGS" + "@internal Registers suitable for an indirect tail call") (define_register_constraint "w" "FP_REGS" "Floating point and SIMD vector registers.") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9e4fffebe700..7b73816e9ed7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-02-01 Renlin Li + + Backport from mainline + 2018-02-01 Richard Sandiford + + PR target/83370 + * gcc.target/aarch64/pr83370.c: New. + 2018-02-01 Bin Cheng Backport from mainline diff --git a/gcc/testsuite/gcc.target/aarch64/pr83370.c b/gcc/testsuite/gcc.target/aarch64/pr83370.c new file mode 100644 index 000000000000..001373c4d397 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr83370.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +typedef void (*fun) (void); + +void +f (fun x1) +{ + register fun x2 asm ("x16"); + int arr[5000]; + int *volatile ptr = arr; + asm ("mov %0, %1" : "=r" (x2) : "r" (x1)); + x2 (); +} + +void g (void) {} + +int +main (void) +{ + f (g); +}