aboutsummaryrefslogtreecommitdiff
blob: c74a087b7ff1fa066b1eb11f973e11d8c43e1e42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Bug: https://bugs.gentoo.org/664016

From 2a8e2ab2e9e11b679616d80285296ac77ad0920f Mon Sep 17 00:00:00 2001
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
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.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263672 138bc75d-0d04-0410-961f-82ee72b054a4
--- 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 ());