From 00b94487352ad836f175eb288fea31d91426b080 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 19 Feb 2018 22:58:04 +0100 Subject: [PATCH] re PR target/84146 (ICE with -mcet in dwarf2out_var_location, involving sigsetjmp) PR target/84146 * reg-notes.def (REG_CALL_ARG_LOCATION): New reg note. * insn-notes.def (NOTE_INSN_CALL_ARG_LOCATION): Remove. * var-tracking.c (emit_note_insn_var_location): Remove all references to NOTE_INSN_CALL_ARG_LOCATION. (emit_notes_in_bb): Emit arguments as REG_CALL_ARG_LOCATION note on the CALL_INSN rather than separate NOTE_INSN_CALL_ARG_LOCATION note. Use copy_rtx_if_shared. * dwarf2out.c (gen_subprogram_die): Use XEXP with 0 instead of NOTE_VAR_LOCATION on ca_loc->call_arg_loc_note. (dwarf2out_var_location): Remove handling of NOTE_INSN_CALL_ARG_LOCATION, instead handle REG_CALL_ARG_LOCATION note on call_insn. * final.c (final_scan_insn): Remove all references to NOTE_INSN_CALL_ARG_LOCATION. (rest_of_clean_state): Likewise. Remove REG_CALL_ARG_LOCATION notes before dumping final insns. * except.c (emit_note_eh_region_end): Remove all references to NOTE_INSN_CALL_ARG_LOCATION. * config/alpha/alpha.c (alpha_pad_function_end): Likewise. * config/c6x/c6x.c (c6x_gen_bundles): Likewise. * config/arc/arc.c (hwloop_optimize): Likewise. * config/arm/arm.c (create_fix_barrier): Likewise. * config/s390/s390.c (s390_chunkify_start): Likewise. * config/sh/sh.c (find_barrier): Likewise. * config/i386/i386.c (rest_of_insert_endbranch, ix86_seh_fixup_eh_fallthru): Likewise. * config/xtensa/xtensa.c (hwloop_optimize): Likewise. * config/iq2000/iq2000.c (final_prescan_insn): Likewise. * config/frv/frv.c (frv_function_prologue): Likewise. * emit-rtl.c (try_split): Likewise. Copy over REG_CALL_ARG_LOCATION reg note. (note_outside_basic_block_p): Remove all references to NOTE_INSN_CALL_ARG_LOCATION. * gengtype.c (adjust_field_rtx_def): Likewise. * print-rtl.c (rtx_writer::print_rtx_operand_code_0, print_insn): Likewise. * jump.c (cleanup_barriers, delete_related_insns): Likewise. * cfgrtl.c (force_nonfallthru_and_redirect): Likewise. * gcc.target/i386/pr84146.c: Add -fcompare-debug to dg-options. From-SVN: r257826 --- gcc/ChangeLog | 40 +++++++++++++++++++++++++ gcc/cfgrtl.c | 5 ---- gcc/config/alpha/alpha.c | 8 ----- gcc/config/arc/arc.c | 5 +--- gcc/config/arm/arm.c | 10 ------- gcc/config/c6x/c6x.c | 24 --------------- gcc/config/frv/frv.c | 28 ----------------- gcc/config/i386/i386.c | 14 ++------- gcc/config/iq2000/iq2000.c | 8 +---- gcc/config/s390/s390.c | 4 +-- gcc/config/sh/sh.c | 10 +------ gcc/config/xtensa/xtensa.c | 5 +--- gcc/dwarf2out.c | 22 ++++++++++---- gcc/emit-rtl.c | 22 ++------------ gcc/except.c | 8 ----- gcc/final.c | 23 ++++++++------ gcc/gengtype.c | 1 - gcc/insn-notes.def | 3 -- gcc/jump.c | 31 ------------------- gcc/print-rtl.c | 2 -- gcc/reg-notes.def | 3 ++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.target/i386/pr84146.c | 2 +- gcc/var-tracking.c | 20 ++++++------- 24 files changed, 98 insertions(+), 205 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6bef46372ac..900f9d5864c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,45 @@ 2018-02-19 Jakub Jelinek + PR target/84146 + * reg-notes.def (REG_CALL_ARG_LOCATION): New reg note. + * insn-notes.def (NOTE_INSN_CALL_ARG_LOCATION): Remove. + * var-tracking.c (emit_note_insn_var_location): Remove all references + to NOTE_INSN_CALL_ARG_LOCATION. + (emit_notes_in_bb): Emit arguments as REG_CALL_ARG_LOCATION note on + the CALL_INSN rather than separate NOTE_INSN_CALL_ARG_LOCATION note. + Use copy_rtx_if_shared. + * dwarf2out.c (gen_subprogram_die): Use XEXP with 0 instead of + NOTE_VAR_LOCATION on ca_loc->call_arg_loc_note. + (dwarf2out_var_location): Remove handling of + NOTE_INSN_CALL_ARG_LOCATION, instead handle REG_CALL_ARG_LOCATION note + on call_insn. + * final.c (final_scan_insn): Remove all references to + NOTE_INSN_CALL_ARG_LOCATION. + (rest_of_clean_state): Likewise. Remove REG_CALL_ARG_LOCATION notes + before dumping final insns. + * except.c (emit_note_eh_region_end): Remove all references to + NOTE_INSN_CALL_ARG_LOCATION. + * config/alpha/alpha.c (alpha_pad_function_end): Likewise. + * config/c6x/c6x.c (c6x_gen_bundles): Likewise. + * config/arc/arc.c (hwloop_optimize): Likewise. + * config/arm/arm.c (create_fix_barrier): Likewise. + * config/s390/s390.c (s390_chunkify_start): Likewise. + * config/sh/sh.c (find_barrier): Likewise. + * config/i386/i386.c (rest_of_insert_endbranch, + ix86_seh_fixup_eh_fallthru): Likewise. + * config/xtensa/xtensa.c (hwloop_optimize): Likewise. + * config/iq2000/iq2000.c (final_prescan_insn): Likewise. + * config/frv/frv.c (frv_function_prologue): Likewise. + * emit-rtl.c (try_split): Likewise. Copy over REG_CALL_ARG_LOCATION + reg note. + (note_outside_basic_block_p): Remove all references to + NOTE_INSN_CALL_ARG_LOCATION. + * gengtype.c (adjust_field_rtx_def): Likewise. + * print-rtl.c (rtx_writer::print_rtx_operand_code_0, print_insn): + Likewise. + * jump.c (cleanup_barriers, delete_related_insns): Likewise. + * cfgrtl.c (force_nonfallthru_and_redirect): Likewise. + PR c++/84444 * builtins.c (builtin_mathfn_code): Don't check if CALL_EXPR_FN (t) is ADDR_EXPR. diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 6ff80fd5c01..fd095ac59ed 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -1628,11 +1628,6 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label) else new_head = BB_END (e->src); new_head = NEXT_INSN (new_head); - /* Make sure we don't split a call and its corresponding - CALL_ARG_LOCATION note. */ - if (new_head && NOTE_P (new_head) - && NOTE_KIND (new_head) == NOTE_INSN_CALL_ARG_LOCATION) - new_head = NEXT_INSN (new_head); jump_block = create_basic_block (new_head, NULL, e->src); jump_block->count = count; diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 2f6d118606a..a039f045262 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -9406,14 +9406,6 @@ alpha_pad_function_end (void) || find_reg_note (insn, REG_NORETURN, NULL_RTX))) continue; - /* Make sure we do not split a call and its corresponding - CALL_ARG_LOCATION note. */ - next = NEXT_INSN (insn); - if (next == NULL) - continue; - if (NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - insn = next; - next = next_active_insn (insn); if (next) { diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 843defd4cda..196d0e4a727 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -7700,10 +7700,7 @@ hwloop_optimize (hwloop_info loop) #if 0 while (DEBUG_INSN_P (entry_after) || (NOTE_P (entry_after) - && NOTE_KIND (entry_after) != NOTE_INSN_BASIC_BLOCK - /* Make sure we don't split a call and its corresponding - CALL_ARG_LOCATION note. */ - && NOTE_KIND (entry_after) != NOTE_INSN_CALL_ARG_LOCATION)) + && NOTE_KIND (entry_after) != NOTE_INSN_BASIC_BLOCK)) entry_after = NEXT_INSN (entry_after); #endif entry_after = next_nonnote_nondebug_insn_bb (entry_after); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 17feba46619..90d62e699bc 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -16556,16 +16556,6 @@ create_fix_barrier (Mfix *fix, HOST_WIDE_INT max_address) /* Make sure that we found a place to insert the jump. */ gcc_assert (selected); - /* Make sure we do not split a call and its corresponding - CALL_ARG_LOCATION note. */ - if (CALL_P (selected)) - { - rtx_insn *next = NEXT_INSN (selected); - if (next && NOTE_P (next) - && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - selected = next; - } - /* Create a new JUMP_INSN that branches around a barrier. */ from = emit_jump_insn_after (gen_jump (label), selected); JUMP_LABEL (from) = label; diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index 762e29faa17..f12edfd0821 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -4637,7 +4637,6 @@ static void c6x_gen_bundles (void) { basic_block bb; - rtx_insn *insn, *next, *last_call; FOR_EACH_BB_FN (bb, cfun) { @@ -4704,29 +4703,6 @@ c6x_gen_bundles (void) break; } } - /* Bundling, and emitting nops, can separate - NOTE_INSN_CALL_ARG_LOCATION from the corresponding calls. Fix - that up here. */ - last_call = NULL; - for (insn = get_insns (); insn; insn = next) - { - next = NEXT_INSN (insn); - if (CALL_P (insn) - || (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE - && CALL_P (XVECEXP (PATTERN (insn), 0, 0)))) - last_call = insn; - if (!NOTE_P (insn) || NOTE_KIND (insn) != NOTE_INSN_CALL_ARG_LOCATION) - continue; - if (NEXT_INSN (last_call) == insn) - continue; - SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); - SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); - SET_PREV_INSN (insn) = last_call; - SET_NEXT_INSN (insn) = NEXT_INSN (last_call); - SET_PREV_INSN (NEXT_INSN (insn)) = insn; - SET_NEXT_INSN (PREV_INSN (insn)) = insn; - last_call = insn; - } } /* Emit a NOP instruction for CYCLES cycles after insn AFTER. Return it. */ diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 3bf770b3649..56027bd67d9 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -1415,8 +1415,6 @@ frv_function_contains_far_jump (void) static void frv_function_prologue (FILE *file) { - rtx_insn *insn, *next, *last_call; - /* If no frame was created, check whether the function uses a call instruction to implement a far jump. If so, save the link in gr3 and replace all returns to LR with returns to GR3. GR3 is used because it @@ -1457,32 +1455,6 @@ frv_function_prologue (FILE *file) /* Allow the garbage collector to free the nops created by frv_reorg. */ memset (frv_nops, 0, sizeof (frv_nops)); - - /* Locate CALL_ARG_LOCATION notes that have been misplaced - and move them back to where they should be located. */ - last_call = NULL; - for (insn = get_insns (); insn; insn = next) - { - next = NEXT_INSN (insn); - if (CALL_P (insn) - || (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE - && CALL_P (XVECEXP (PATTERN (insn), 0, 0)))) - last_call = insn; - - if (!NOTE_P (insn) || NOTE_KIND (insn) != NOTE_INSN_CALL_ARG_LOCATION) - continue; - - if (NEXT_INSN (last_call) == insn) - continue; - - SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); - SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); - SET_PREV_INSN (insn) = last_call; - SET_NEXT_INSN (insn) = NEXT_INSN (last_call); - SET_PREV_INSN (NEXT_INSN (insn)) = insn; - SET_NEXT_INSN (PREV_INSN (insn)) = insn; - last_call = insn; - } } diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4a968a75a9e..d54e7301e84 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2619,16 +2619,8 @@ rest_of_insert_endbranch (void) /* Generate ENDBRANCH after CALL, which can return more than twice, setjmp-like functions. */ - /* Skip notes that must immediately follow the call insn. */ - rtx_insn *next_insn = insn; - if (NEXT_INSN (insn) - && NOTE_P (NEXT_INSN (insn)) - && (NOTE_KIND (NEXT_INSN (insn)) - == NOTE_INSN_CALL_ARG_LOCATION)) - next_insn = NEXT_INSN (insn); - cet_eb = gen_nop_endbr (); - emit_insn_after_setloc (cet_eb, next_insn, INSN_LOCATION (insn)); + emit_insn_after_setloc (cet_eb, insn, INSN_LOCATION (insn)); continue; } @@ -42128,9 +42120,7 @@ ix86_seh_fixup_eh_fallthru (void) /* Do not separate calls from their debug information. */ for (next = NEXT_INSN (insn); next != NULL; next = NEXT_INSN (next)) - if (NOTE_P (next) - && (NOTE_KIND (next) == NOTE_INSN_VAR_LOCATION - || NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)) + if (NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_VAR_LOCATION) insn = next; else break; diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 18588084c10..ee89ced0e2f 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -1578,13 +1578,7 @@ final_prescan_insn (rtx_insn *insn, rtx opvec[] ATTRIBUTE_UNUSED, || (GET_CODE (PATTERN (insn)) == RETURN)) && NEXT_INSN (PREV_INSN (insn)) == insn) { - rtx_insn *tmp = insn; - while (NEXT_INSN (tmp) - && NOTE_P (NEXT_INSN (tmp)) - && NOTE_KIND (NEXT_INSN (tmp)) == NOTE_INSN_CALL_ARG_LOCATION) - tmp = NEXT_INSN (tmp); - - rtx_insn *nop_insn = emit_insn_after (gen_nop (), tmp); + rtx_insn *nop_insn = emit_insn_after (gen_nop (), insn); INSN_ADDRESSES_NEW (nop_insn, -1); } diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 298fdd16490..51adb0df480 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -9259,7 +9259,6 @@ s390_chunkify_start (void) section_switch_p = true; break; case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: continue; default: break; @@ -9330,8 +9329,7 @@ s390_chunkify_start (void) } while (next && NOTE_P (next) - && (NOTE_KIND (next) == NOTE_INSN_VAR_LOCATION - || NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)); + && NOTE_KIND (next) == NOTE_INSN_VAR_LOCATION); } else { diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 90d6c733d33..ced66408265 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -5225,21 +5225,13 @@ find_barrier (int num_mova, rtx_insn *mova, rtx_insn *from) around the constant pool table will be hit. Putting it before a jump makes it more likely that the bra delay slot will be filled. */ - while (NOTE_P (from) || JUMP_P (from) - || LABEL_P (from)) + while (NOTE_P (from) || JUMP_P (from) || LABEL_P (from)) from = PREV_INSN (from); - /* Make sure we do not split between a call and its corresponding - CALL_ARG_LOCATION note. */ if (CALL_P (from)) { bool sibcall_p = SIBLING_CALL_P (from); - rtx_insn *next = NEXT_INSN (from); - if (next && NOTE_P (next) - && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - from = next; - /* If FROM was a sibling call, then we know that control will not return. In fact, we were guaranteed to hit a barrier before another real insn. diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 23cdf4d26bf..7cfe64d4289 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -4255,10 +4255,7 @@ hwloop_optimize (hwloop_info loop) entry_after = BB_END (entry_bb); while (DEBUG_INSN_P (entry_after) || (NOTE_P (entry_after) - && NOTE_KIND (entry_after) != NOTE_INSN_BASIC_BLOCK - /* Make sure we don't split a call and its corresponding - CALL_ARG_LOCATION note. */ - && NOTE_KIND (entry_after) != NOTE_INSN_CALL_ARG_LOCATION)) + && NOTE_KIND (entry_after) != NOTE_INSN_BASIC_BLOCK)) entry_after = PREV_INSN (entry_after); emit_insn_after (seq, entry_after); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 4e2bf3b4c88..5e88c7bacf0 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -23110,7 +23110,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) rtx arg, next_arg; for (arg = (ca_loc->call_arg_loc_note != NULL_RTX - ? NOTE_VAR_LOCATION (ca_loc->call_arg_loc_note) + ? XEXP (ca_loc->call_arg_loc_note, 0) : NULL_RTX); arg; arg = next_arg) { @@ -26975,6 +26975,17 @@ dwarf2out_var_location (rtx_insn *loc_note) call_site_count++; if (SIBLING_CALL_P (loc_note)) tail_call_site_count++; + if (find_reg_note (loc_note, REG_CALL_ARG_LOCATION, NULL_RTX)) + { + call_insn = loc_note; + loc_note = NULL; + var_loc_p = false; + + next_real = dwarf2out_next_real_insn (call_insn); + next_note = NULL; + cached_next_real_insn = NULL; + goto create_label; + } if (optimize == 0 && !flag_var_tracking) { /* When the var-tracking pass is not running, there is no note @@ -27034,8 +27045,7 @@ dwarf2out_var_location (rtx_insn *loc_note) || ! NOTE_P (next_note) || (NOTE_KIND (next_note) != NOTE_INSN_VAR_LOCATION && NOTE_KIND (next_note) != NOTE_INSN_BEGIN_STMT - && NOTE_KIND (next_note) != NOTE_INSN_INLINE_ENTRY - && NOTE_KIND (next_note) != NOTE_INSN_CALL_ARG_LOCATION)) + && NOTE_KIND (next_note) != NOTE_INSN_INLINE_ENTRY)) next_note = NULL; if (! next_real) @@ -27145,10 +27155,10 @@ create_label: { struct call_arg_loc_node *ca_loc = ggc_cleared_alloc (); - rtx_insn *prev - = loc_note != NULL_RTX ? prev_real_insn (loc_note) : call_insn; + rtx_insn *prev = call_insn; - ca_loc->call_arg_loc_note = loc_note; + ca_loc->call_arg_loc_note + = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX); ca_loc->next = NULL; ca_loc->label = last_label; gcc_assert (prev diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index a722985b5d9..dd8fec3f349 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3866,15 +3866,12 @@ try_split (rtx pat, rtx_insn *trial, int last) for (insn = insn_last; insn ; insn = PREV_INSN (insn)) if (CALL_P (insn)) { - rtx_insn *next; - rtx *p; - gcc_assert (call_insn == NULL_RTX); call_insn = insn; /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the target may have explicitly specified. */ - p = &CALL_INSN_FUNCTION_USAGE (insn); + rtx *p = &CALL_INSN_FUNCTION_USAGE (insn); while (*p) p = &XEXP (*p, 1); *p = CALL_INSN_FUNCTION_USAGE (trial); @@ -3882,21 +3879,6 @@ try_split (rtx pat, rtx_insn *trial, int last) /* If the old call was a sibling call, the new one must be too. */ SIBLING_CALL_P (insn) = SIBLING_CALL_P (trial); - - /* If the new call is the last instruction in the sequence, - it will effectively replace the old call in-situ. Otherwise - we must move any following NOTE_INSN_CALL_ARG_LOCATION note - so that it comes immediately after the new call. */ - if (NEXT_INSN (insn)) - for (next = NEXT_INSN (trial); - next && NOTE_P (next); - next = NEXT_INSN (next)) - if (NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - { - remove_insn (next); - add_insn_after (next, insn, NULL); - break; - } } } @@ -3913,6 +3895,7 @@ try_split (rtx pat, rtx_insn *trial, int last) case REG_SETJMP: case REG_TM: case REG_CALL_NOCF_CHECK: + case REG_CALL_ARG_LOCATION: for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn)) { if (CALL_P (insn)) @@ -4777,7 +4760,6 @@ note_outside_basic_block_p (enum insn_note subtype, bool on_bb_boundary_p) inside basic blocks. If the caller is emitting on the basic block boundary, do not set BLOCK_FOR_INSN on the new note. */ case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: case NOTE_INSN_EH_REGION_BEG: case NOTE_INSN_EH_REGION_END: return on_bb_boundary_p; diff --git a/gcc/except.c b/gcc/except.c index bd587de1836..04d4764ee17 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -2465,14 +2465,6 @@ add_call_site (rtx landing_pad, int action, int section) static rtx_note * emit_note_eh_region_end (rtx_insn *insn) { - rtx_insn *next = NEXT_INSN (insn); - - /* Make sure we do not split a call and its corresponding - CALL_ARG_LOCATION note. */ - if (next && NOTE_P (next) - && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - insn = next; - return emit_note_after (NOTE_INSN_EH_REGION_END, insn); } diff --git a/gcc/final.c b/gcc/final.c index cbebbfdf5b0..78a750388e6 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2467,7 +2467,6 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, break; case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: if (!DECL_IGNORED_P (current_function_decl)) { debug_hooks->var_location (insn); @@ -4846,15 +4845,21 @@ rest_of_clean_state (void) SET_NEXT_INSN (insn) = NULL; SET_PREV_INSN (insn) = NULL; + if (CALL_P (insn)) + { + rtx note = find_reg_note (insn, REG_CALL_ARG_LOCATION, NULL_RTX); + if (note) + remove_note (insn, note); + } + if (final_output - && (!NOTE_P (insn) || - (NOTE_KIND (insn) != NOTE_INSN_VAR_LOCATION - && NOTE_KIND (insn) != NOTE_INSN_BEGIN_STMT - && NOTE_KIND (insn) != NOTE_INSN_INLINE_ENTRY - && NOTE_KIND (insn) != NOTE_INSN_CALL_ARG_LOCATION - && NOTE_KIND (insn) != NOTE_INSN_BLOCK_BEG - && NOTE_KIND (insn) != NOTE_INSN_BLOCK_END - && NOTE_KIND (insn) != NOTE_INSN_DELETED_DEBUG_LABEL))) + && (!NOTE_P (insn) + || (NOTE_KIND (insn) != NOTE_INSN_VAR_LOCATION + && NOTE_KIND (insn) != NOTE_INSN_BEGIN_STMT + && NOTE_KIND (insn) != NOTE_INSN_INLINE_ENTRY + && NOTE_KIND (insn) != NOTE_INSN_BLOCK_BEG + && NOTE_KIND (insn) != NOTE_INSN_BLOCK_END + && NOTE_KIND (insn) != NOTE_INSN_DELETED_DEBUG_LABEL))) print_rtl_single (final_output, insn); } diff --git a/gcc/gengtype.c b/gcc/gengtype.c index c94008ee0c4..0db5528e632 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -1187,7 +1187,6 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) break; case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: note_flds = create_field (note_flds, rtx_tp, "rt_rtx"); break; diff --git a/gcc/insn-notes.def b/gcc/insn-notes.def index 9cac5f1549a..0afd47504ec 100644 --- a/gcc/insn-notes.def +++ b/gcc/insn-notes.def @@ -65,9 +65,6 @@ INSN_NOTE (EH_REGION_END) /* The location of a variable. */ INSN_NOTE (VAR_LOCATION) -/* The values passed to callee. */ -INSN_NOTE (CALL_ARG_LOCATION) - /* The beginning of a statement. */ INSN_NOTE (BEGIN_STMT) diff --git a/gcc/jump.c b/gcc/jump.c index dcc85949aa2..f379048f636 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -127,17 +127,6 @@ cleanup_barriers (void) if (!prev) continue; - if (CALL_P (prev)) - { - /* Make sure we do not split a call and its corresponding - CALL_ARG_LOCATION note. */ - rtx_insn *next = NEXT_INSN (prev); - - if (NOTE_P (next) - && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) - prev = next; - } - if (BARRIER_P (prev)) delete_insn (insn); else if (prev != PREV_INSN (insn)) @@ -1279,26 +1268,6 @@ delete_related_insns (rtx uncast_insn) if (next != 0 && BARRIER_P (next)) delete_insn (next); - /* If this is a call, then we have to remove the var tracking note - for the call arguments. */ - - if (CALL_P (insn) - || (NONJUMP_INSN_P (insn) - && GET_CODE (PATTERN (insn)) == SEQUENCE - && CALL_P (XVECEXP (PATTERN (insn), 0, 0)))) - { - rtx_insn *p; - - for (p = next && next->deleted () ? NEXT_INSN (next) : next; - p && NOTE_P (p); - p = NEXT_INSN (p)) - if (NOTE_KIND (p) == NOTE_INSN_CALL_ARG_LOCATION) - { - remove_insn (p); - break; - } - } - /* If deleting a jump, decrement the count of the label, and delete the label if it is now unused. */ diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 3ad11dc4cf9..37c0d53fae2 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -264,7 +264,6 @@ rtx_writer::print_rtx_operand_code_0 (const_rtx in_rtx ATTRIBUTE_UNUSED, } case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: fputc (' ', m_outfile); print_rtx (NOTE_VAR_LOCATION (in_rtx)); break; @@ -1970,7 +1969,6 @@ print_insn (pretty_printer *pp, const rtx_insn *x, int verbose) break; case NOTE_INSN_VAR_LOCATION: - case NOTE_INSN_CALL_ARG_LOCATION: pp_left_brace (pp); print_pattern (pp, NOTE_VAR_LOCATION (x), verbose); pp_right_brace (pp); diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def index f9caa247f2c..76f3f452186 100644 --- a/gcc/reg-notes.def +++ b/gcc/reg-notes.def @@ -239,3 +239,6 @@ REG_NOTE (CALL_DECL) when a called function has a 'notrack' attribute. This note is used by the compiler when the option -fcf-protection=branch is specified. */ REG_NOTE (CALL_NOCF_CHECK) + +/* The values passed to callee, for debuginfo purposes. */ +REG_NOTE (CALL_ARG_LOCATION) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 15638f7b0ad..286a6af5a4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-19 Jakub Jelinek + + PR target/84146 + * gcc.target/i386/pr84146.c: Add -fcompare-debug to dg-options. + 2017-02-19 Uros Bizjak * gcc.target/i386/pr70023.c (dg-do): Compile only for target int128. diff --git a/gcc/testsuite/gcc.target/i386/pr84146.c b/gcc/testsuite/gcc.target/i386/pr84146.c index ba9b6336c0d..a14baa47532 100644 --- a/gcc/testsuite/gcc.target/i386/pr84146.c +++ b/gcc/testsuite/gcc.target/i386/pr84146.c @@ -1,6 +1,6 @@ /* PR target/84146 */ /* { dg-do compile } */ -/* { dg-options "-O2 -g -mcet -fcf-protection=full" } */ +/* { dg-options "-O2 -g -mcet -fcf-protection=full -fcompare-debug" } */ int __setjmp (void **); void *buf[64]; diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index fb30ec223ef..56a701c283e 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -8860,14 +8860,12 @@ emit_note_insn_var_location (variable **varp, emit_note_data *data) /* Make sure that the call related notes come first. */ while (NEXT_INSN (insn) && NOTE_P (insn) - && ((NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION - && NOTE_DURING_CALL_P (insn)) - || NOTE_KIND (insn) == NOTE_INSN_CALL_ARG_LOCATION)) + && NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION + && NOTE_DURING_CALL_P (insn)) insn = NEXT_INSN (insn); if (NOTE_P (insn) - && ((NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION - && NOTE_DURING_CALL_P (insn)) - || NOTE_KIND (insn) == NOTE_INSN_CALL_ARG_LOCATION)) + && NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION + && NOTE_DURING_CALL_P (insn)) note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn); else note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn); @@ -9210,7 +9208,6 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set) emit_notes_for_changes (insn, EMIT_NOTE_AFTER_CALL_INSN, set->vars); { rtx arguments = mo->u.loc, *p = &arguments; - rtx_note *note; while (*p) { XEXP (XEXP (*p, 0), 1) @@ -9218,7 +9215,11 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set) shared_hash_htab (set->vars)); /* If expansion is successful, keep it in the list. */ if (XEXP (XEXP (*p, 0), 1)) - p = &XEXP (*p, 1); + { + XEXP (XEXP (*p, 0), 1) + = copy_rtx_if_shared (XEXP (XEXP (*p, 0), 1)); + p = &XEXP (*p, 1); + } /* Otherwise, if the following item is data_value for it, drop it too too. */ else if (XEXP (*p, 1) @@ -9234,8 +9235,7 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set) else *p = XEXP (*p, 1); } - note = emit_note_after (NOTE_INSN_CALL_ARG_LOCATION, insn); - NOTE_VAR_LOCATION (note) = arguments; + add_reg_note (insn, REG_CALL_ARG_LOCATION, arguments); } break; -- 2.30.2