This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix debug info with crtl->stack_realign_tried (PR debug/40596)


Hi!

based_loc_descr has:
          /* If drap register is used to align stack, use frame
             pointer + offset to access stack variables.  If stack
             is aligned without drap, use stack pointer + offset to
             access stack variables.  */
          if (crtl->stack_realign_tried
              && cfa.reg == HARD_FRAME_POINTER_REGNUM
              && reg == frame_pointer_rtx)
            {
              int base_reg
                = DWARF_FRAME_REGNUM (cfa.indirect
                                      ? HARD_FRAME_POINTER_REGNUM
                                      : STACK_POINTER_REGNUM);
              return new_reg_loc_descr (base_reg, offset);
            }
            
          offset += frame_pointer_fb_offset;
          return new_loc_descr (DW_OP_fbreg, offset, 0);
which got broken by epilogue unwinding support; before epilogue unwinding
was added cfa variable at the point where based_loc_descr is called (after
assembly for the function has been emitted) contained the CFA state after
prologue, but that is no longer true if epilogue has unwind info and isn't
followed by other code.  Attached are two different fixes.
The first patch changes dwarf2out_{begin,end}_epilogue, so that even when
epilogue has unwind info, but isn't followed by anything else, cfa variable
is restored to the state in the middle of the function.

I've bootstrapped/regtested this patch on x86_64-linux and i686-linux with
the second patch on top of it and the assert never triggered, so I'm
assuming if crtl->stack_realign_tried is true, cfa.reg in the middle of
function is always HARD_FRAME_POINTER_REGNUM (if stack is dynamically
realigned, I think frame pointer is always forced) and cfa.indirect is true
iff fde->drap_reg is not invalid.

If so, then we could as well use the third patch instead of the first, never
rely on cfa content after function has been emitted into assembly.

Both the first and third patch fix the testcase in the PR:
 	.uleb128 0xd	# (DIE (0xef) DW_TAG_variable)
 	.ascii "a3\0"	# DW_AT_name
 	.byte	0x1	# DW_AT_decl_file (pr40596.c)
 	.byte	0x18	# DW_AT_decl_line
 	.long	0x46	# DW_AT_type
 	.byte	0x2	# DW_AT_location
-	.byte	0x91	# DW_OP_fbreg
-	.sleb128 20
+	.byte	0x74	# DW_OP_breg4
+	.sleb128 28

	Jakub

Attachment: Y347a
Description: Text document

Attachment: Y347b
Description: Text document

Attachment: Y347c
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]