GCC Middle and Back End API Reference
shrink-wrap.h File Reference
#include "function.h"
Include dependency graph for shrink-wrap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SHRINK_WRAPPING_ENABLED    (flag_shrink_wrap && targetm.have_simple_return ())
 

Functions

bool requires_stack_frame_p (rtx_insn *, HARD_REG_SET, HARD_REG_SET)
 
void try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
 
void try_shrink_wrapping_separate (basic_block first_bb)
 
bool use_shrink_wrapping_separate (void)
 

Macro Definition Documentation

◆ SHRINK_WRAPPING_ENABLED

Function Documentation

◆ requires_stack_frame_p()

bool requires_stack_frame_p ( rtx_insn * insn,
HARD_REG_SET prologue_used,
HARD_REG_SET set_up_by_prologue )
extern
Shrink-wrapping related functions.
   Copyright (C) 1989-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
In shrink-wrap.cc.   
Shrink-wrapping related optimizations.
   Copyright (C) 1987-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
This file handles shrink-wrapping related optimizations.   
Return true if INSN requires the stack frame to be set up.
PROLOGUE_USED contains the hard registers used in the function
prologue.  SET_UP_BY_PROLOGUE is the set of registers we expect the
prologue to set up for the function.   

References add_to_hard_reg_set(), CALL_P, can_throw_internal(), cfun, CLEAR_HARD_REG_SET, DF_REF_REG, df_regs_ever_live_p(), FAKE_CALL_P, FOR_EACH_INSN_DEF, FOR_EACH_INSN_USE, GET_MODE, ggc_alloc(), hard_reg_set_intersect_p(), REG_P, REGNO, SIBLING_CALL_P, and TEST_HARD_REG_BIT.

Referenced by try_shrink_wrapping().

◆ try_shrink_wrapping()

void try_shrink_wrapping ( edge * entry_edge,
rtx_insn * prologue_seq )
extern
Try to perform a kind of shrink-wrapping, making sure the
prologue/epilogue is emitted only around those parts of the
function that require it.

There will be exactly one prologue, and it will be executed either
zero or one time, on any path.  Depending on where the prologue is
placed, some of the basic blocks can be reached via both paths with
and without a prologue.  Such blocks will be duplicated here, and the
edges changed to match.

Paths that go to the exit without going through the prologue will use
a simple_return instead of the epilogue.  We maximize the number of
those, making sure to only duplicate blocks that can be duplicated.
If the prologue can then still be placed in multiple locations, we
place it as early as possible.

An example, where we duplicate blocks with control flow (legend:
_B_egin, _R_eturn and _S_imple_return; edges without arrowhead should
be taken to point down or to the right, to simplify the diagram; here,
block 3 needs a prologue, the rest does not):


    B                 B
    |                 |
    2                 2
    |\                |\
    | 3    becomes    | 3
    |/                |  \
    4                 7   4
    |\                |\  |\
    | 5               | 8 | 5
    |/                |/  |/
    6                 9   6
    |                 |   |
    R                 S   R


(bb 4 is duplicated to 7, and so on; the prologue is inserted on the
edge 2->3).

Another example, where part of a loop is duplicated (again, bb 3 is
the only block that needs a prologue):


    B   3<--              B       ->3<--
    |   |   |             |      |  |   |
    |   v   |   becomes   |      |  v   |
    2---4---              2---5--   4---
        |                     |     |
        R                     S     R


(bb 4 is duplicated to 5; the prologue is inserted on the edge 5->3).

ENTRY_EDGE is the edge where the prologue will be placed, possibly
changed by this function.  PROLOGUE_SEQ is the prologue we will insert.   

References add_to_hard_reg_set(), any_condjump_p(), profile_count::apply_scale(), basic_block_def::aux, BB_COPY_PARTITION, BB_END, bitmap_bit_p, bitmap_copy(), bitmap_set_bit, calculate_dominance_info(), can_dup_for_shrink_wrapping(), can_get_prologue(), CDI_DOMINATORS, CDI_POST_DOMINATORS, cfun, CLEAR_HARD_REG_BIT, CLEAR_HARD_REG_SET, basic_block_def::count, create_empty_bb(), crtl, dominated_by_p(), dump_file, duplicate_block(), EDGE_COUNT, ei_next(), ei_safe_edge(), ei_start, emit_barrier_after_bb(), ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_BB_INSNS, FOR_EACH_BB_FN, FOR_EACH_BB_REVERSE_FN, FOR_EACH_EDGE, force_nonfallthru(), frame_pointer_needed, free_dominance_info(), gcc_assert, get_immediate_dominator(), GET_MODE, get_uncond_jump_length(), ggc_alloc(), handle_simple_exit(), HARD_FRAME_POINTER_REGNUM, basic_block_def::index, INSN_UID(), INVALID_REGNUM, JUMP_P, make_single_succ_edge(), n_basic_blocks_for_fn, nearest_common_dominator(), NEXT_INSN(), NONDEBUG_INSN_P, NOTE_KIND, NOTE_P, note_stores(), note_uses(), NULL, PATTERN(), PIC_OFFSET_TABLE_REGNUM, pic_offset_table_rtx, prepare_shrink_wrap(), print_rtl_single(), record_hard_reg_sets(), record_hard_reg_uses(), redirect_edge_and_branch_force(), REGNO, requires_stack_frame_p(), SHRINK_WRAPPING_ENABLED, single_succ_edge(), split_edge(), basic_block_def::succs, targetm, and profile_count::zero().

Referenced by thread_prologue_and_epilogue_insns().

◆ try_shrink_wrapping_separate()

◆ use_shrink_wrapping_separate()

bool use_shrink_wrapping_separate ( void )
extern