From a31505a339c847f0073c0ce9223a2b3c9bec6cef Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 20 Aug 2018 19:14:04 +0000 Subject: [PATCH] x86: Always update EH return address in word_mode On x86, return address is always popped in word_mode. eh_return needs to put EH return address in word_mode on stack. gcc/ PR target/87014 * config/i386/i386.md (eh_return): Always update EH return address in word_mode. gcc/testsuite/ PR target/87014 * g++.dg/torture/pr87014.C: New file. From-SVN: r263672 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.md | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr87014.C | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr87014.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15bcc7f..eb7ac76 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-20 H.J. Lu + + PR target/87014 + * config/i386/i386.md (eh_return): Always update EH return + address in word_mode. + 2018-08-20 Chung-Lin Tang * targhooks.c (std_gimplify_va_arg_expr): Properly handle case of when diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 918241d..71faa21 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -13612,7 +13612,10 @@ stack address we wish to restore. */ tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa); tmp = plus_constant (Pmode, tmp, -UNITS_PER_WORD); - tmp = gen_rtx_MEM (Pmode, tmp); + /* Return address is always in word_mode. */ + tmp = gen_rtx_MEM (word_mode, tmp); + if (GET_MODE (ra) != word_mode) + ra = convert_to_mode (word_mode, ra, 1); emit_move_insn (tmp, ra); emit_jump_insn (gen_eh_return_internal ()); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0620b1..26cbc08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-20 H.J. Lu + + PR target/87014 + * g++.dg/torture/pr87014.C: New file. + 2018-08-20 Bernd Edlinger PR target/86984 diff --git a/gcc/testsuite/g++.dg/torture/pr87014.C b/gcc/testsuite/g++.dg/torture/pr87014.C new file mode 100644 index 0000000..614954e --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr87014.C @@ -0,0 +1,37 @@ +// { dg-do run } + +void +fillstack () +{ + long long foo[] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; +} + +void +f (long long=-1,long long=-1,long long=-1,long long=-1, + long long=-1,long long=-1,long long arg7_on_stack=-1) +{ + throw 0; +} + +void +g() +{ + try + { + f (); + } + catch (int) + { + } +} + +int +main() +{ + fillstack (); + g (); + return 0; +} -- 2.7.4