From d5d94b80c320319263b0bba3083f8bc80bf6ef4b Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 21 Sep 2018 10:01:16 +0000 Subject: [PATCH] rs6000.c (rs6000_function_ok_for_sibcall): Return false if the call takes a static chain. * config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Return false if the call takes a static chain. From-SVN: r264463 --- gcc/ChangeLog | 5 ++++ gcc/config/rs6000/rs6000.c | 6 +++++ gcc/testsuite/ChangeLog | 7 ++++++ gcc/testsuite/gcc.dg/nested-func-11.c | 34 +++++++++++++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 7 +----- 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/nested-func-11.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97e75ec34b2..d33af3eb895 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-09-21 Eric Botcazou + + * config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Return false + if the call takes a static chain. + 2018-09-21 Martin Liska * auto-profile.c (autofdo_source_profile::read): Do not diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 340490c46e9..79dd2f648e8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24331,6 +24331,12 @@ rs6000_function_ok_for_sibcall (tree decl, tree exp) { tree fntype; + /* The sibcall epilogue may clobber the static chain register. + ??? We could work harder and avoid that, but it's probably + not worth the hassle in practice. */ + if (CALL_EXPR_STATIC_CHAIN (exp)) + return false; + if (decl) fntype = TREE_TYPE (decl); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c68e2c61871..b0664206895 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-09-21 Eric Botcazou + + * gcc.dg/nested-func-11.c: New test. + + * lib/target-supports.exp (check_effective_target_tls_runtime): Make + more robust and remove target-specific handling. + 2018-09-21 Eric Botcazou * gcc.c-torture/execute/20180921-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/nested-func-11.c b/gcc/testsuite/gcc.dg/nested-func-11.c new file mode 100644 index 00000000000..01096b4147f --- /dev/null +++ b/gcc/testsuite/gcc.dg/nested-func-11.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ + +int __attribute__((noipa)) foo (int i) +{ + int a; + + void __attribute__((noipa)) nested2 (int i) + { + a = i; + } + + void __attribute__((noipa)) nested1 (int i) + { + int b[32]; + + for (int j = 0; j < 32; j++) + b[j] = i + j; + + nested2 (b[i]); + } + + nested1 (i); + + return a; +} + +int main (void) +{ + if (foo (4) != 8) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 94f61c58df9..57bfe9ccd2f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -879,13 +879,8 @@ proc check_effective_target_tls_emulated {} { # Return 1 if TLS executables can run correctly, 0 otherwise. proc check_effective_target_tls_runtime {} { - # The runtime does not have TLS support, but just - # running the test below is insufficient to show this. - if { [istarget msp430-*-*] || [istarget visium-*-*] } { - return 0 - } return [check_runtime tls_runtime { - __thread int thr = 0; + __thread int thr __attribute__((tls_model("global-dynamic"))) = 0; int main (void) { return thr; } } [add_options_for_tls ""]] } -- 2.30.2