static rtx next_active_insn_bb (basic_block bb, rtx insn) { for (insn = NEXT_INSN (insn); insn != NEXT_INSN (BB_END (bb)); insn = NEXT_INSN (insn)) if (active_insn_p (insn)) return insn; return NULL_RTX; }
static rtx prev_active_insn_bb (basic_block bb, rtx insn) { for (insn = PREV_INSN (insn); insn != PREV_INSN (BB_HEAD (bb)); insn = PREV_INSN (insn)) if (active_insn_p (insn)) return insn; return NULL_RTX; }
static int count_insns (basic_block bb) { rtx insn; int n = 0; for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = NEXT_INSN (insn)) if (active_insn_p (insn)) n++; return n; }
void reemit_insn_block_notes (void) { tree cur_block = DECL_INITIAL (cfun->decl); rtx insn, note; insn = get_insns (); if (!active_insn_p (insn)) insn = next_active_insn (insn); for (; insn; insn = next_active_insn (insn)) { tree this_block; /* Avoid putting scope notes between jump table and its label. */ if (JUMP_P (insn) && (GET_CODE (PATTERN (insn)) == ADDR_VEC || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)) continue; this_block = insn_scope (insn); /* For sequences compute scope resulting from merging all scopes of instructions nested inside. */ if (GET_CODE (PATTERN (insn)) == SEQUENCE) { int i; rtx body = PATTERN (insn); this_block = NULL; for (i = 0; i < XVECLEN (body, 0); i++) this_block = choose_inner_scope (this_block, insn_scope (XVECEXP (body, 0, i))); } if (! this_block) continue; if (this_block != cur_block) { change_scope (insn, cur_block, this_block); cur_block = this_block; } } /* change_scope emits before the insn, not after. */ note = emit_note (NOTE_INSN_DELETED); change_scope (note, cur_block, DECL_INITIAL (cfun->decl)); delete_insn (note); reorder_blocks (); }
void insn_locators_initialize (void) { tree block = NULL; tree last_block = NULL; rtx insn, next; int loc = 0; int line_number = 0, last_line_number = 0; char *file_name = NULL, *last_file_name = NULL; prologue_locator = epilogue_locator = 0; VARRAY_INT_INIT (block_locators_locs, 32, "block_locators_locs"); VARRAY_TREE_INIT (block_locators_blocks, 32, "block_locators_blocks"); VARRAY_INT_INIT (line_locators_locs, 32, "line_locators_locs"); VARRAY_INT_INIT (line_locators_lines, 32, "line_locators_lines"); VARRAY_INT_INIT (file_locators_locs, 32, "file_locators_locs"); VARRAY_CHAR_PTR_INIT (file_locators_files, 32, "file_locators_files"); for (insn = get_insns (); insn; insn = next) { next = NEXT_INSN (insn); if ((active_insn_p (insn) && GET_CODE (PATTERN (insn)) != ADDR_VEC && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC) || !NEXT_INSN (insn) || (!prologue_locator && file_name)) { if (last_block != block) { loc++; VARRAY_PUSH_INT (block_locators_locs, loc); VARRAY_PUSH_TREE (block_locators_blocks, block); last_block = block; } if (last_line_number != line_number) { loc++; VARRAY_PUSH_INT (line_locators_locs, loc); VARRAY_PUSH_INT (line_locators_lines, line_number); last_line_number = line_number; } if (last_file_name != file_name) { loc++; VARRAY_PUSH_INT (file_locators_locs, loc); VARRAY_PUSH_CHAR_PTR (file_locators_files, file_name); last_file_name = file_name; } } if (!prologue_locator && file_name) prologue_locator = loc; if (!NEXT_INSN (insn)) epilogue_locator = loc; if (active_insn_p (insn)) INSN_LOCATOR (insn) = loc; else if (GET_CODE (insn) == NOTE) { switch (NOTE_LINE_NUMBER (insn)) { case NOTE_INSN_BLOCK_BEG: block = NOTE_BLOCK (insn); delete_insn (insn); break; case NOTE_INSN_BLOCK_END: block = BLOCK_SUPERCONTEXT (block); if (block && TREE_CODE (block) == FUNCTION_DECL) block = 0; delete_insn (insn); break; default: if (NOTE_LINE_NUMBER (insn) > 0) { line_number = NOTE_LINE_NUMBER (insn); file_name = (char *)NOTE_SOURCE_FILE (insn); } break; } } } /* Tag the blocks with a depth number so that change_scope can find the common parent easily. */ set_block_levels (DECL_INITIAL (cfun->decl), 0); }
unsigned int insn_locators_initialize (void) { tree block = NULL; tree last_block = NULL; rtx insn, next; int loc = 0; int line_number = 0, last_line_number = 0; const char *file_name = NULL, *last_file_name = NULL; prologue_locator = epilogue_locator = 0; block_locators_locs = VEC_alloc (int, heap, 32); block_locators_blocks = VEC_alloc (tree, gc, 32); line_locators_locs = VEC_alloc (int, heap, 32); line_locators_lines = VEC_alloc (int, heap, 32); file_locators_locs = VEC_alloc (int, heap, 32); VARRAY_CHAR_PTR_INIT (file_locators_files, 32, "file_locators_files"); for (insn = get_insns (); insn; insn = next) { int active = 0; next = NEXT_INSN (insn); if (NOTE_P (insn)) { gcc_assert (NOTE_LINE_NUMBER (insn) != NOTE_INSN_BLOCK_BEG && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BLOCK_END); if (NOTE_LINE_NUMBER (insn) > 0) { expanded_location xloc; NOTE_EXPANDED_LOCATION (xloc, insn); line_number = xloc.line; file_name = xloc.file; } } else active = (active_insn_p (insn) && GET_CODE (PATTERN (insn)) != ADDR_VEC && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC); check_block_change (insn, &block); if (active || !next || (!prologue_locator && file_name)) { if (last_block != block) { loc++; VEC_safe_push (int, heap, block_locators_locs, loc); VEC_safe_push (tree, gc, block_locators_blocks, block); last_block = block; } if (last_line_number != line_number) { loc++; VEC_safe_push (int, heap, line_locators_locs, loc); VEC_safe_push (int, heap, line_locators_lines, line_number); last_line_number = line_number; } if (last_file_name != file_name) { loc++; VEC_safe_push (int, heap, file_locators_locs, loc); VARRAY_PUSH_CHAR_PTR (file_locators_files, (char *) file_name); last_file_name = file_name; } if (!prologue_locator && file_name) prologue_locator = loc; if (!next) epilogue_locator = loc; if (active) INSN_LOCATOR (insn) = loc; } } /* Tag the blocks with a depth number so that change_scope can find the common parent easily. */ set_block_levels (DECL_INITIAL (cfun->decl), 0); free_block_changes (); return 0; }