On Tue, Oct 24, 2017 at 8:26 PM, Jason Merrill <ja...@redhat.com> wrote: > On Thu, Jul 27, 2017 at 3:50 PM, H.J. Lu <hongjiu...@intel.com> wrote: >> execute_dwarf2_frame is called for each funtion. But create_cie_data >> is called only once to initialize cie_cfi_row for all functions. Since >> INCOMING_FRAME_SP_OFFSET may be different for each function, we can't >> use the same INCOMING_FRAME_SP_OFFSET in cie_cfi_row for all functions. >> This patch sets cie_cfi_row->cfa.offset to INCOMING_FRAME_SP_OFFSET in >> create_pseudo_cfg which is called for each function. >> >> Tested on x86-64. OK for trunk? > > This looks wrong. cie_cfi_row is the state produced by the > instructions in the CIE, which don't vary between functions. If
/* The state of the first row of the FDE table, which includes the state provided by the CIE. */ static GTY(()) dw_cfi_row *cie_cfi_row; cie_cfi_row is created by cie_cfi_row = cur_row = new_cfi_row (); /* On entry, the Canonical Frame Address is at SP. */ memset (&loc, 0, sizeof (loc)); loc.reg = dw_stack_pointer_regnum; loc.offset = INCOMING_FRAME_SP_OFFSET; def_cfa_1 (&loc); and used by create_pseudo_cfg ti.beg_row = cie_cfi_row; ti.cfa_store = cie_cfi_row->cfa; The problem is that the offset field in cie_cfi_row->cfa may not be the same for all functions. cie_cfi_row does change in this case. My patch simply corrects the offset in CFA of the first row of the FDE table. > INCOMING_FRAME_SP_OFFSET varies, we need to add actual FDE > instructions to reflect that, not just clobber our current model of > what the CIE means. > > Jason -- H.J.