diff mbox series

Relax SUPPORTS_STACK_ALIGNMENT with !crtl->stack_realign_tried

Message ID 20180808133208.21617-1-hjl.tools@gmail.com
State New
Headers show
Series Relax SUPPORTS_STACK_ALIGNMENT with !crtl->stack_realign_tried | expand

Commit Message

H.J. Lu Aug. 8, 2018, 1:32 p.m. UTC
Assert for SUPPORTS_STACK_ALIGNMENT was added for dynamic stack
alignment.  At the time, arg_pointer_rtx would only be eliminated
by either hard_frame_pointer_rtx or stack_pointer_rtx only when
dynamic stack alignment is supported.  With

commit cd557ff63f388ad27c376d0a225e74d3594a6f9d
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Aug 10 15:29:05 2017 +0000

    i386: Don't use frame pointer without stack access

    When there is no stack access, there is no need to use frame pointer
    even if -fno-omit-frame-pointer is used and caller's frame pointer is
    unchanged.

this can happen when there is no dynamic stack alignment.  This patch
relaxes SUPPORTS_STACK_ALIGNMENT with !crtl->stack_realign_tried to
allow arg_pointer_rtx to be eliminated by either hard_frame_pointer_rtx
or stack_pointer_rtx when there is no dynamic stack alignment at all.

gcc/

	PR debug/86593
	* dwarf2out.c (based_loc_descr): Replace SUPPORTS_STACK_ALIGNMENT
	with (SUPPORTS_STACK_ALIGNMENT || !crtl->stack_realign_tried).
	(compute_frame_pointer_to_fb_displacement): Likewise.

gcc/testsuite/

	PR debug/86593
	* g++.dg/pr86593.C: New test.
---
 gcc/dwarf2out.c                |  6 ++++--
 gcc/testsuite/g++.dg/pr86593.C | 11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr86593.C
diff mbox series

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b67481dd2db..6ecdc4562d0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -14304,7 +14304,8 @@  based_loc_descr (rtx reg, poly_int64 offset,
       if (elim != reg)
 	{
 	  elim = strip_offset_and_add (elim, &offset);
-	  gcc_assert ((SUPPORTS_STACK_ALIGNMENT
+	  gcc_assert (((SUPPORTS_STACK_ALIGNMENT
+			|| !crtl->stack_realign_tried)
 		       && (elim == hard_frame_pointer_rtx
 			   || elim == stack_pointer_rtx))
 	              || elim == (frame_pointer_needed
@@ -20492,7 +20493,8 @@  compute_frame_pointer_to_fb_displacement (poly_int64 offset)
      this, assume that while we cannot provide a proper value for
      frame_pointer_fb_offset, we won't need one either.  */
   frame_pointer_fb_offset_valid
-    = ((SUPPORTS_STACK_ALIGNMENT
+    = (((SUPPORTS_STACK_ALIGNMENT
+	 || !crtl->stack_realign_tried)
 	&& (elim == hard_frame_pointer_rtx
 	    || elim == stack_pointer_rtx))
        || elim == (frame_pointer_needed
diff --git a/gcc/testsuite/g++.dg/pr86593.C b/gcc/testsuite/g++.dg/pr86593.C
new file mode 100644
index 00000000000..f4de0c1166a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr86593.C
@@ -0,0 +1,11 @@ 
+// { dg-options "-O -g -fno-omit-frame-pointer" }
+
+struct Foo
+{
+    int bar(int a, int b, int c, int i1, int i2, int i3, int d);
+};
+
+int Foo::bar(int a, int b, int c, int i1, int i2, int i3, int d)
+{
+  return 0;
+}