From b20ba138efe0958dac85df2ec52ca0fc83dbb539 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 24 Jan 2017 17:15:02 +0000 Subject: [PATCH] re PR target/77439 (wrong code for sibcall with longcall, APCS frame and VFP) PR target/77439 * config/arm/arm.c (arm_function_ok_for_sibcall): Add back restriction for long calls with APCS frame and VFP. From-SVN: r244879 --- gcc/ChangeLog | 6 ++++ gcc/config/arm/arm.c | 8 +++++ gcc/testsuite/ChangeLog | 4 +++ .../gcc.target/arm/vfp-longcall-apcs.c | 32 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22eeef5b2a4..c2962bb248f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-24 Eric Botcazou + + PR target/77439 + * config/arm/arm.c (arm_function_ok_for_sibcall): Add back restriction + for long calls with APCS frame and VFP. + 2017-01-24 David Malcolm * cfg.c (original_copy_tables_initialized_p): New function. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 934f5d141f7..944445fc86a 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -7105,6 +7105,14 @@ arm_function_ok_for_sibcall (tree decl, tree exp) if (TARGET_VXWORKS_RTP && flag_pic && decl && !targetm.binds_local_p (decl)) return false; + /* ??? Cannot tail-call to long calls with APCS frame and VFP, because IP + may be used both as target of the call and base register for restoring + the VFP registers */ + if (TARGET_APCS_FRAME && TARGET_ARM + && TARGET_HARD_FLOAT + && decl && arm_is_long_call_p (decl)) + return false; + /* If we are interworking and the function is not declared static then we can't tail-call it unless we know that it exists in this compilation unit (since it might be a Thumb routine). */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02118907ecc..e70200bac57 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-01-24 Eric Botcazou + + * gcc.target/arm/vfp-longcall-apcs.c: New test. + 2017-01-24 David Malcolm * gcc.dg/rtl/aarch64/asr_div1.c: New test case. diff --git a/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c b/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c new file mode 100644 index 00000000000..fa22b4da534 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-mapcs-frame -O -foptimize-sibling-calls -ffunction-sections" } */ + +extern void abort (void); + +static __attribute__((noclone, noinline, long_call)) +int foo (int a, int b, int c, int d, double i) +{ + return a; +} + +static __attribute__((noclone, noinline)) +double baz (double i) +{ + return i; +} + +static __attribute__((noclone, noinline)) +int bar (int a, int b, int c, int d, double i, double j) +{ + double l = baz (i) * j; + return foo (a, b, c, d, l); +} + +int +main (void) +{ + if (bar (0, 0, 0, 0, 0.0, 0.0) != 0) + abort (); + + return 0; +} -- 2.30.2