Bootstrapped and regression tested with --with-arch=z14 and
--with-arch=z900.  Glibc build is clean with that patch using
-mindirect-branch=thunk and -mfunction-return=thunk.

gcc/ChangeLog:

2018-02-09  Andreas Krebbel  <kreb...@linux.vnet.ibm.com>

        PR target/PR84295
        * config/s390/s390.c (s390_set_current_function): Invoke
        s390_indirect_branch_settings also if fndecl didn't change.

gcc/testsuite/ChangeLog:

2018-02-09  Andreas Krebbel  <kreb...@linux.vnet.ibm.com>

        PR target/PR84295
        * gcc.target/s390/pr84295.c: New test.
---
 gcc/config/s390/s390.c                  |  5 ++++-
 gcc/testsuite/gcc.target/s390/pr84295.c | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/s390/pr84295.c

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 62a60e2..298fdd1 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -16135,7 +16135,10 @@ s390_set_current_function (tree fndecl)
      several times in the course of compiling a function, and we don't want to
      slow things down too much or call target_reinit when it isn't safe.  */
   if (fndecl == s390_previous_fndecl)
-    return;
+    {
+      s390_indirect_branch_settings (fndecl);
+      return;
+    }
 
   tree old_tree;
   if (s390_previous_fndecl == NULL_TREE)
diff --git a/gcc/testsuite/gcc.target/s390/pr84295.c 
b/gcc/testsuite/gcc.target/s390/pr84295.c
new file mode 100644
index 0000000..4da43c3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr84295.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z900 -fgnu89-inline --save-temps 
-mfunction-return-reg=thunk -mindirect-branch-table" } */
+
+extern void foo (void);
+extern __inline  void foo (void) {}
+void foo (void) {}
+
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 1 } } */
+/* { dg-final { scan-assembler "ex\t" } } */
+
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
+/* { dg-final { scan-assembler     "section\t.s390_return_reg" } } */
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
-- 
2.9.1

Reply via email to