From 41b9329e73772a9b50806a40f2b06159e0549fc6 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 23 Oct 2014 23:58:41 +0200 Subject: [PATCH] re PR debug/63623 (Lots of functions get -fvar-tracking silently turned off unnecessarily) PR debug/63623 * var-tracking.c (stack_adjust_offset_pre_post_cb): New function. (stack_adjust_offset_pre_post): Use it through for_each_inc_dec, instead of only handling autoinc in dest if it is a MEM. (vt_stack_adjustments): Fix up formatting. From-SVN: r216600 --- gcc/ChangeLog | 8 ++++ gcc/var-tracking.c | 107 ++++++++++++++++++--------------------------- 2 files changed, 50 insertions(+), 65 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33249e5ecb3..a2bc25cdac0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-10-23 Jakub Jelinek + + PR debug/63623 + * var-tracking.c (stack_adjust_offset_pre_post_cb): New function. + (stack_adjust_offset_pre_post): Use it through for_each_inc_dec, + instead of only handling autoinc in dest if it is a MEM. + (vt_stack_adjustments): Fix up formatting. + 2014-10-23 DJ Delorie * config/msp430/msp430.c (msp430_print_operand): 'x' modifier is diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 52b73444580..4c5ae41b248 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -700,6 +700,39 @@ static void vt_add_function_parameters (void); static bool vt_initialize (void); static void vt_finalize (void); +/* Callback for stack_adjust_offset_pre_post, called via for_each_inc_dec. */ + +static int +stack_adjust_offset_pre_post_cb (rtx, rtx op, rtx dest, rtx src, rtx srcoff, + void *arg) +{ + if (dest != stack_pointer_rtx) + return 0; + + switch (GET_CODE (op)) + { + case PRE_INC: + case PRE_DEC: + ((HOST_WIDE_INT *)arg)[0] -= INTVAL (srcoff); + return 0; + case POST_INC: + case POST_DEC: + ((HOST_WIDE_INT *)arg)[1] -= INTVAL (srcoff); + return 0; + case PRE_MODIFY: + case POST_MODIFY: + /* We handle only adjustments by constant amount. */ + gcc_assert (GET_CODE (src) == PLUS + && CONST_INT_P (XEXP (src, 1)) + && XEXP (src, 0) == stack_pointer_rtx); + ((HOST_WIDE_INT *)arg)[GET_CODE (op) == POST_MODIFY] + -= INTVAL (XEXP (src, 1)); + return 0; + default: + gcc_unreachable (); + } +} + /* Given a SET, calculate the amount of stack adjustment it contains PRE- and POST-modifying stack pointer. This function is similar to stack_adjust_offset. */ @@ -725,68 +758,12 @@ stack_adjust_offset_pre_post (rtx pattern, HOST_WIDE_INT *pre, *post += INTVAL (XEXP (src, 1)); else *post -= INTVAL (XEXP (src, 1)); + return; } - else if (MEM_P (dest)) - { - /* (set (mem (pre_dec (reg sp))) (foo)) */ - src = XEXP (dest, 0); - code = GET_CODE (src); - - switch (code) - { - case PRE_MODIFY: - case POST_MODIFY: - if (XEXP (src, 0) == stack_pointer_rtx) - { - rtx val = XEXP (XEXP (src, 1), 1); - /* We handle only adjustments by constant amount. */ - gcc_assert (GET_CODE (XEXP (src, 1)) == PLUS && - CONST_INT_P (val)); - - if (code == PRE_MODIFY) - *pre -= INTVAL (val); - else - *post -= INTVAL (val); - break; - } - return; - - case PRE_DEC: - if (XEXP (src, 0) == stack_pointer_rtx) - { - *pre += GET_MODE_SIZE (GET_MODE (dest)); - break; - } - return; - - case POST_DEC: - if (XEXP (src, 0) == stack_pointer_rtx) - { - *post += GET_MODE_SIZE (GET_MODE (dest)); - break; - } - return; - - case PRE_INC: - if (XEXP (src, 0) == stack_pointer_rtx) - { - *pre -= GET_MODE_SIZE (GET_MODE (dest)); - break; - } - return; - - case POST_INC: - if (XEXP (src, 0) == stack_pointer_rtx) - { - *post -= GET_MODE_SIZE (GET_MODE (dest)); - break; - } - return; - - default: - return; - } - } + HOST_WIDE_INT res[2] = { 0, 0 }; + for_each_inc_dec (pattern, stack_adjust_offset_pre_post_cb, res); + *pre += res[0]; + *post += res[1]; } /* Given an INSN, calculate the amount of stack adjustment it contains @@ -836,10 +813,10 @@ vt_stack_adjustments (void) /* Initialize entry block. */ VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->visited = true; - VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->in.stack_adjust = - INCOMING_FRAME_SP_OFFSET; - VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->out.stack_adjust = - INCOMING_FRAME_SP_OFFSET; + VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->in.stack_adjust + = INCOMING_FRAME_SP_OFFSET; + VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->out.stack_adjust + = INCOMING_FRAME_SP_OFFSET; /* Allocate stack for back-tracking up CFG. */ stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1); -- 2.30.2