]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Always update EH return address in word_mode
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 21 Aug 2018 16:38:17 +0000 (16:38 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Tue, 21 Aug 2018 16:38:17 +0000 (09:38 -0700)
On x86, return address is always popped in word_mode.  eh_return needs
to put EH return address in word_mode on stack.

gcc/

Backport from mainline
PR target/87014
* config/i386/i386.md (eh_return): Always update EH return
address in word_mode.

gcc/testsuite/

Backport from mainline
PR target/87014
* g++.dg/torture/pr87014.C: New file.

From-SVN: r263745

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr87014.C [new file with mode: 0644]

index 2edf549dccca90acc1cf7b1b576f6ce9b8b59b0a..5f36e461958d1113b16004a69ec8a08ed26764ba 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2018-08-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/87014
+       * config/i386/i386.md (eh_return): Always update EH return
+       address in word_mode.
+
 2018-08-17  John David Anglin  <danglin@gcc.gnu.org>
 
        Backport from mainline
index 9db79988ceb9b104fd43bb292fa14da7bfe9517a..925e78329aa4d9c0c421112d733daa586344ebbd 100644 (file)
      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 ());
index e412fe895e1326aaa78967aec9b3a8e5e4250ef0..c8e819b8952326e45809a9dacbec18a2ec846d01 100644 (file)
@@ -1,3 +1,11 @@
+2018-08-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2018-08-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/87014
+       * g++.dg/torture/pr87014.C: New file.
+
 2018-07-12  Richard Biener  <rguenther@suse.de>
 
        PR target/84829
diff --git a/gcc/testsuite/g++.dg/torture/pr87014.C b/gcc/testsuite/g++.dg/torture/pr87014.C
new file mode 100644 (file)
index 0000000..614954e
--- /dev/null
@@ -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;
+}