From: Jakub Jelinek Date: Wed, 3 Jan 2018 20:58:48 +0000 (+0100) Subject: re PR debug/83645 (ICE: in get_insn_template, at final.c:2100 with -gstatement-frontiers) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3a174d0d1eef07442fca5867cfcdd05f3b845f8;p=gcc.git re PR debug/83645 (ICE: in get_insn_template, at final.c:2100 with -gstatement-frontiers) PR debug/83645 * var-tracking.c (delete_vta_debug_insn): New inline function. (delete_vta_debug_insns): Add USE_CFG argument, if true, walk just insns from get_insns () to NULL instead of each bb separately. Use delete_vta_debug_insn. No longer static. (vt_debug_insns_local, variable_tracking_main_1): Adjust delete_vta_debug_insns callers. * rtl.h (delete_vta_debug_insns): Declare. * final.c (rest_of_handle_final): Call delete_vta_debug_insns instead of variable_tracking_main. * gcc.dg/pr83645.c: New test. From-SVN: r256189 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8786a911087..62856ceaa26 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2018-01-03 Jakub Jelinek + + PR debug/83645 + * var-tracking.c (delete_vta_debug_insn): New inline function. + (delete_vta_debug_insns): Add USE_CFG argument, if true, walk just + insns from get_insns () to NULL instead of each bb separately. + Use delete_vta_debug_insn. No longer static. + (vt_debug_insns_local, variable_tracking_main_1): Adjust + delete_vta_debug_insns callers. + * rtl.h (delete_vta_debug_insns): Declare. + * final.c (rest_of_handle_final): Call delete_vta_debug_insns + instead of variable_tracking_main. + 2018-01-03 Martin Sebor PR c/83559 diff --git a/gcc/final.c b/gcc/final.c index b80693cae93..db3095c5526 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4544,7 +4544,7 @@ rest_of_handle_final (void) /* Turn debug markers into notes if the var-tracking pass has not been invoked. */ if (!flag_var_tracking && MAY_HAVE_DEBUG_MARKER_INSNS) - variable_tracking_main (); + delete_vta_debug_insns (false); assemble_start_function (current_function_decl, fnname); final_start_function (get_insns (), asm_out_file, optimize); diff --git a/gcc/rtl.h b/gcc/rtl.h index 96513f4c3c2..e2a9c06193c 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -4254,6 +4254,7 @@ extern GTY(()) rtx stack_limit_rtx; /* In var-tracking.c */ extern unsigned int variable_tracking_main (void); +extern void delete_vta_debug_insns (bool); /* In stor-layout.c. */ extern void get_mode_bounds (scalar_int_mode, int, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 23c5d1ccbd8..e4d16a590cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Jakub Jelinek + + PR debug/83645 + * gcc.dg/pr83645.c: New test. + 2018-01-03 Martin Sebor PR c/83559 diff --git a/gcc/testsuite/gcc.dg/pr83645.c b/gcc/testsuite/gcc.dg/pr83645.c new file mode 100644 index 00000000000..4ac2be2d612 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83645.c @@ -0,0 +1,14 @@ +/* PR debug/83645 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fno-var-tracking" } */ + +int a, b, c[1]; + +void +foo (void) +{ + int i = 0; + b = a; + for (;;) + c[i++] = 7; +} diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index e768c2d176d..98d09c0544c 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -10271,11 +10271,40 @@ vt_initialize (void) static int debug_label_num = 1; +/* Remove from the insn stream a single debug insn used for + variable tracking at assignments. */ + +static inline void +delete_vta_debug_insn (rtx_insn *insn) +{ + if (DEBUG_MARKER_INSN_P (insn)) + { + reemit_marker_as_note (insn); + return; + } + + tree decl = INSN_VAR_LOCATION_DECL (insn); + if (TREE_CODE (decl) == LABEL_DECL + && DECL_NAME (decl) + && !DECL_RTL_SET_P (decl)) + { + PUT_CODE (insn, NOTE); + NOTE_KIND (insn) = NOTE_INSN_DELETED_DEBUG_LABEL; + NOTE_DELETED_LABEL_NAME (insn) + = IDENTIFIER_POINTER (DECL_NAME (decl)); + SET_DECL_RTL (decl, insn); + CODE_LABEL_NUMBER (insn) = debug_label_num++; + } + else + delete_insn (insn); +} + /* Remove from the insn stream all debug insns used for variable - tracking at assignments. */ + tracking at assignments. USE_CFG should be false if the cfg is no + longer usable. */ -static void -delete_vta_debug_insns (void) +void +delete_vta_debug_insns (bool use_cfg) { basic_block bb; rtx_insn *insn, *next; @@ -10283,33 +10312,20 @@ delete_vta_debug_insns (void) if (!MAY_HAVE_DEBUG_INSNS) return; - FOR_EACH_BB_FN (bb, cfun) - { - FOR_BB_INSNS_SAFE (bb, insn, next) + if (use_cfg) + FOR_EACH_BB_FN (bb, cfun) + { + FOR_BB_INSNS_SAFE (bb, insn, next) + if (DEBUG_INSN_P (insn)) + delete_vta_debug_insn (insn); + } + else + for (insn = get_insns (); insn; insn = next) + { + next = NEXT_INSN (insn); if (DEBUG_INSN_P (insn)) - { - if (DEBUG_MARKER_INSN_P (insn)) - { - reemit_marker_as_note (insn); - continue; - } - - tree decl = INSN_VAR_LOCATION_DECL (insn); - if (TREE_CODE (decl) == LABEL_DECL - && DECL_NAME (decl) - && !DECL_RTL_SET_P (decl)) - { - PUT_CODE (insn, NOTE); - NOTE_KIND (insn) = NOTE_INSN_DELETED_DEBUG_LABEL; - NOTE_DELETED_LABEL_NAME (insn) - = IDENTIFIER_POINTER (DECL_NAME (decl)); - SET_DECL_RTL (decl, insn); - CODE_LABEL_NUMBER (insn) = debug_label_num++; - } - else - delete_insn (insn); - } - } + delete_vta_debug_insn (insn); + } } /* Run a fast, BB-local only version of var tracking, to take care of @@ -10322,7 +10338,7 @@ static void vt_debug_insns_local (bool skipped ATTRIBUTE_UNUSED) { /* ??? Just skip it all for now. */ - delete_vta_debug_insns (); + delete_vta_debug_insns (true); } /* Free the data structures needed for variable tracking. */ @@ -10395,7 +10411,7 @@ variable_tracking_main_1 (void) any pseudos at this point. */ || targetm.no_register_allocation) { - delete_vta_debug_insns (); + delete_vta_debug_insns (true); return 0; } @@ -10423,7 +10439,7 @@ variable_tracking_main_1 (void) { vt_finalize (); - delete_vta_debug_insns (); + delete_vta_debug_insns (true); /* This is later restored by our caller. */ flag_var_tracking_assignments = 0;