From d0ee17a526119f45b7f2a593fa54c82dfffe5629 Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Wed, 5 Apr 2017 08:28:18 +0000 Subject: [PATCH] PR target/79890: S/390: Fix crash. builtin_eh_return requires the return address to be saved on the stack. The patch prevents using an FPR for that. gcc/ChangeLog: 2017-04-05 Dominik Vogt PR target/79890 * config/s390/s390.c (s390_register_info_gprtofpr): Return if call_eh_return is true. gcc/testsuite/ChangeLog: 2017-04-05 Dominik Vogt PR target/79890 * gcc.target/s390/pr79890.c: New test case. From-SVN: r246701 --- gcc/ChangeLog | 6 ++++++ gcc/config/s390/s390.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/s390/pr79890.c | 11 +++++++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.target/s390/pr79890.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e6839ca45b..b29311a651d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-05 Dominik Vogt + + PR target/79890 + * config/s390/s390.c (s390_register_info_gprtofpr): Return if + call_eh_return is true. + 2017-04-05 Andreas Krebbel * config/s390/s390-c.c (s390_resolve_overloaded_builtin): diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 51b3d46924b..2cb8947e5a6 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -9512,6 +9512,12 @@ s390_register_info_gprtofpr () if (!TARGET_Z10 || !TARGET_HARD_FLOAT || !crtl->is_leaf) return; + /* builtin_eh_return needs to be able to modify the return address + on the stack. It could also adjust the FPR save slot instead but + is it worth the trouble?! */ + if (crtl->calls_eh_return) + return; + for (i = 15; i >= 6; i--) { if (cfun_gpr_save_slot (i) == SAVE_SLOT_NONE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b030d22daf0..98aa5c0b6da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-05 Dominik Vogt + + PR target/79890 + * gcc.target/s390/pr79890.c: New test case. + 2017-04-05 Jakub Jelinek PR target/80310 diff --git a/gcc/testsuite/gcc.target/s390/pr79890.c b/gcc/testsuite/gcc.target/s390/pr79890.c new file mode 100644 index 00000000000..e9894df6c63 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr79890.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-pedantic" } */ + +void bar (void); + +void +foo (int x) +{ + __builtin_unwind_init (); + __builtin_eh_return (x, bar); +} -- 2.30.2