From 6bc088ca0e315896c3efe1ed273f6a345e5418b8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 4 Sep 2018 20:42:06 +0000 Subject: [PATCH] DWARF: Allow hard frame pointer even if frame pointer isn't used r251028 commit cd557ff63f388ad27c376d0a225e74d3594a6f9d Author: hjl 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. frame pointer may not be available even if -fno-omit-frame-pointer is used. When this happened, arg pointer may be eliminated by hard frame pointer. Since hard frame pointer is encoded with DW_OP_fbreg which uses the DW_AT_frame_base attribute, not hard frame pointer directly, we should allow hard frame pointer when generating DWARF info even if frame pointer isn't used. gcc/ PR debug/86593 * dwarf2out.c (based_loc_descr): Allow hard frame pointer even if frame pointer isn't used. (compute_frame_pointer_to_fb_displacement): Likewise. gcc/testsuite/ PR debug/86593 * g++.dg/pr86593.C: New test. From-SVN: r264096 --- gcc/ChangeLog | 7 +++++++ gcc/dwarf2out.c | 25 ++++++++++++------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr86593.C | 11 +++++++++++ 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr86593.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b00a869..4b19487 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-09-04 H.J. Lu + + PR debug/86593 + * dwarf2out.c (based_loc_descr): Allow hard frame pointer even + if frame pointer isn't used. + (compute_frame_pointer_to_fb_displacement): Likewise. + 2018-09-04 Jakub Jelinek PR target/87198 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 77317ed..40cfdf5 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -14325,13 +14325,13 @@ based_loc_descr (rtx reg, poly_int64 offset, if (elim != reg) { + /* Allow hard frame pointer here even if frame pointer + isn't used since hard frame pointer is encoded with + DW_OP_fbreg which uses the DW_AT_frame_base attribute, + not hard frame pointer directly. */ elim = strip_offset_and_add (elim, &offset); - gcc_assert ((SUPPORTS_STACK_ALIGNMENT - && (elim == hard_frame_pointer_rtx - || elim == stack_pointer_rtx)) - || elim == (frame_pointer_needed - ? hard_frame_pointer_rtx - : stack_pointer_rtx)); + gcc_assert (elim == hard_frame_pointer_rtx + || elim == stack_pointer_rtx); /* If drap register is used to align stack, use frame pointer + offset to access stack variables. If stack @@ -20512,14 +20512,13 @@ compute_frame_pointer_to_fb_displacement (poly_int64 offset) in which to eliminate. This is because it's stack pointer isn't directly accessible as a register within the ISA. To work around 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, we won't need one either. We can use + hard frame pointer in debug info even if frame pointer isn't used + since hard frame pointer in debug info is encoded with DW_OP_fbreg + which uses the DW_AT_frame_base attribute, not hard frame pointer + directly. */ frame_pointer_fb_offset_valid - = ((SUPPORTS_STACK_ALIGNMENT - && (elim == hard_frame_pointer_rtx - || elim == stack_pointer_rtx)) - || elim == (frame_pointer_needed - ? hard_frame_pointer_rtx - : stack_pointer_rtx)); + = (elim == hard_frame_pointer_rtx || elim == stack_pointer_rtx); } /* Generate a DW_AT_name attribute given some string value to be included as diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 919c0e0..8b3578f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-04 H.J. Lu + + PR debug/86593 + * g++.dg/pr86593.C: New test. + 2018-09-04 Jakub Jelinek PR target/87198 diff --git a/gcc/testsuite/g++.dg/pr86593.C b/gcc/testsuite/g++.dg/pr86593.C new file mode 100644 index 0000000..feed8c3 --- /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; +} -- 2.7.4