GCC Middle and Back End API Reference
lra-lives.c File Reference

Functions

static void free_live_range ()
static void free_live_range_list ()
static lra_live_range_t create_live_range ()
static lra_live_range_t copy_live_range ()
lra_live_range_t lra_copy_live_range_list ()
lra_live_range_t lra_merge_live_ranges ()
bool lra_intersected_live_ranges_p ()
static void make_hard_regno_born ()
static void make_hard_regno_dead ()
static void mark_pseudo_live ()
static void mark_pseudo_dead ()
static bool mark_regno_live ()
static bool mark_regno_dead ()
static bool bb_has_abnormal_call_pred ()
static void next_program_point ()
void lra_setup_reload_pseudo_preferenced_hard_reg (int regno, int hard_regno, int profit)
static void check_pseudos_live_through_calls ()
static void process_bb_lives ()
static void remove_some_program_points_and_update_live_ranges ()
void lra_print_live_range_list ()
DEBUG_FUNCTION void debug ()
void lra_debug_live_range_list ()
static void print_pseudo_live_ranges ()
void lra_debug_pseudo_live_ranges ()
static void print_live_ranges ()
void lra_debug_live_ranges ()
static void compress_live_ranges ()
void lra_create_live_ranges ()
void lra_clear_live_ranges ()
void lra_live_ranges_init ()
void lra_live_ranges_finish ()

Variables

int lra_live_max_point
int lra_hard_reg_usage [FIRST_PSEUDO_REGISTER]
static bool complete_info_p
static sparseset pseudos_live
static sparseset pseudos_live_through_calls
static sparseset pseudos_live_through_setjumps
static HARD_REG_SET hard_regs_live
static sparseset start_living
static sparseset start_dying
static sparseset unused_set
static sparseset dead_set
static alloc_pool live_range_pool
static rtx curr_insn
static lra_insn_recog_data_t curr_id
static struct
lra_static_insn_data
curr_static_id
static vec< int > point_freq_vec
int * lra_point_freq
int lra_live_range_iter

Function Documentation

static bool bb_has_abnormal_call_pred ( )
static
   Return true when one of the predecessor edges of BB is marked with
   EDGE_ABNORMAL_CALL or EDGE_EH.  

References lra_constraint_new_regno_start, lra_reg_info, lra_reg::preferred_hard_regno1, lra_reg::preferred_hard_regno_profit1, and lra_reg::preferred_hard_regno_profit2.

static void check_pseudos_live_through_calls ( )
inlinestatic
   Check that REGNO living through calls and setjumps, set up conflict
   regs, and clear corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and
   PSEUDOS_LIVE_THROUGH_SETJUMPS.  
     Don't allocate pseudos that cross setjmps or any call, if this
     function receives a nonlocal goto.  
static void compress_live_ranges ( )
static
   Compress pseudo live ranges.  
static lra_live_range_t copy_live_range ( )
static
   Copy live range R and return the result.  

References lra_live_range::next.

static lra_live_range_t create_live_range ( )
static
   Create and return pseudo live range with given attributes.  

References pool_alloc().

DEBUG_FUNCTION void debug ( )
static void free_live_range ( )
static
   Free live range LR.  

References lra_live_range::next.

Referenced by remove_some_program_points_and_update_live_ranges().

static void free_live_range_list ( )
static
void lra_clear_live_ranges ( void  )
   Finish all live ranges.  
lra_live_range_t lra_copy_live_range_list ( )
   Copy live range list given by its head R and return the result.  

References lra_live_range::finish, first, last, and lra_live_range::start.

void lra_create_live_ranges ( )
   The main entry function creates live ranges only for memory pseudos
   (or for all ones if ALL_P), set up CONFLICT_HARD_REGS for
   the pseudos.  
         The biggest mode is already set but its value might be to
         conservative because of recent transformation.  Here in this
         file we recalculate it again as it costs practically
         nothing.  
     Under some circumstances, we can have functions without pseudo
     registers.  For such functions, lra_live_max_point will be 0,
     see e.g. PR55604, and there's nothing more to do for us here.  
     Clean up.  
void lra_debug_live_range_list ( )
   Print live ranges R to stderr.  

References curr_point, and max_reg_num().

void lra_debug_live_ranges ( void  )
   Print live ranges of all pseudos to stderr.  

References lra_reg::freq, lra_hard_reg_usage, lra_reg_info, and reg_renumber.

void lra_debug_pseudo_live_ranges ( )
   Print live ranges of pseudo REGNO to stderr.  
bool lra_intersected_live_ranges_p ( )
   Return TRUE if live ranges R1 and R2 intersect.  
     Remember the live ranges are always kept ordered.  

References hard_regs_live, lra_no_alloc_regs, lra_reg_info, and sparseset_set_bit().

void lra_live_ranges_finish ( void  )
   Finish live ranges data once per function.  
void lra_live_ranges_init ( void  )
   Initialize live ranges data once per function.  
lra_live_range_t lra_merge_live_ranges ( )
   Merge *non-intersected* ranges R1 and R2 and returns the result.
   The function maintains the order of ranges and tries to minimize
   size of the result range list.  Ranges R1 and R2 may not be used
   after the call.  
             Joint ranges: merge r1 and r2 into r1.  
             Add r1 to the result.  

References lra_live_range::next, pool_free(), and lra_live_range::start.

void lra_print_live_range_list ( )
   Print live ranges R to file F.  

References print_live_ranges().

void lra_setup_reload_pseudo_preferenced_hard_reg ( int  regno,
int  hard_regno,
int  profit 
)
   Update the preference of HARD_REGNO for pseudo REGNO by PROFIT.  
     Keep the 1st hard regno as more profitable.  
static void make_hard_regno_born ( )
static
   The function processing birth of hard register REGNO.  It updates
   living hard regs, conflict hard regs for living pseudos, and
   START_LIVING.  

Referenced by mark_pseudo_dead().

static void make_hard_regno_dead ( )
static
   Process the death of hard register REGNO.  This updates
   hard_regs_live and START_DYING.  

Referenced by mark_regno_live().

static void mark_pseudo_dead ( )
static
   Mark pseudo REGNO as not living at program point POINT and update
   START_DYING.
   This finishes the current live range for the pseudo corresponding
   to REGNO.  

References last, and make_hard_regno_born().

Referenced by mark_regno_live().

static void mark_pseudo_live ( )
static
   Mark pseudo REGNO as living at program point POINT, update conflicting
   hard registers of the pseudo and START_LIVING, and start a new live
   range for the pseudo corresponding to REGNO if it is necessary.  
static bool mark_regno_dead ( )
static
   Mark register REGNO in MODE as dead at program point POINT.
   Return TRUE if the liveness tracking sets were modified,
   or FALSE if nothing changed.  

References edge_def::flags, and basic_block_def::preds.

static bool mark_regno_live ( )
static
   Mark register REGNO (pseudo or hard register) in MODE as live
   at program point POINT.
   Return TRUE if the liveness tracking sets were modified,
   or FALSE if nothing changed.  

References changed, last, make_hard_regno_dead(), mark_pseudo_dead(), and sparseset_bit_p().

static void next_program_point ( )
static
   Increment the current program point POINT to the next point which has
   execution frequency FREQ.  

References lra_reg_info, lra_reg::preferred_hard_regno1, lra_reg::preferred_hard_regno2, and lra_reg::preferred_hard_regno_profit1.

static void print_live_ranges ( )
static
   Print live ranges of all pseudos to file F.  

Referenced by debug(), and lra_print_live_range_list().

static void print_pseudo_live_ranges ( )
static
   Print live ranges of pseudo REGNO to file F.  
static void process_bb_lives ( )
static
   Process insns of the basic block BB to update pseudo live ranges,
   pseudo hard register conflicts, and insn notes.  We do it on
   backward scan of BB insns.  CURR_POINT is the program point where
   BB ends.  The function updates this counter and returns in
   CURR_POINT the program point where BB starts.  
     Scan the code of this basic block, noting which pseudos and hard
     regs are born or die.

     Note that this loop treats uninitialized values as live until the
     beginning of the block.  For example, if an instruction uses
     (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever set,
     FOO will remain live until the beginning of the block.  Likewise
     if FOO is not set at all.  This is unnecessarily pessimistic, but
     it probably doesn't matter much in practice.  
         Update max ref width and hard reg usage.  
             Check that source regno does not conflict with
             destination regno to exclude most impossible
             preferences.  
                 It might be 'inheritance pseudo <- reload pseudo'.  
         Try to avoid unnecessary program point increments, this saves
         a lot of time in remove_some_program_points_and_update_live_ranges.
         We only need an increment if something becomes live or dies at this
         program point.  
         Mark each defined value as live.  We need to do this for
         unused values because they still conflict with quantities
         that are live at the time of the definition.  
         See which defined values die here.  
         Increment the current program point if we must.  
         Mark each used value as live.  
           Make argument hard registers live.  
         Mark early clobber outputs dead.  
         Update notes.  
     Pseudos can't go in stack regs at the start of a basic block that
     is reached by an abnormal edge. Likewise for call clobbered regs,
     because caller-save, fixup_abnormal_edges and possibly the table
     driven EH machinery are not quite ready to handle such pseudos
     live across such edges.  
         No need to record conflicts for call clobbered regs if we
         have nonlocal labels around, as we don't ever try to
         allocate such regs in this case.  
     See if we'll need an increment at the end of this basic block.
     An increment is needed if the PSEUDOS_LIVE set is not empty,
     to make sure the finish points are set up correctly.  
static void remove_some_program_points_and_update_live_ranges ( )
static
   Compress pseudo live ranges by removing program points where
   nothing happens.  Complexity of many algorithms in LRA is linear
   function of program points number.  To speed up the code we try to
   minimize the number of the program points here.  

References lra_live_range::finish, free_live_range(), lra_live_max_point, lra_reg_info, lra_live_range::next, and lra_live_range::start.

Referenced by debug().


Variable Documentation

bool complete_info_p
static
   A global flag whose true value says to build live ranges for all
   pseudos, otherwise the live ranges only for pseudos got memory is
   build.  True value means also building copies and setting up hard
   register preferences.  The complete info is necessary only for the
   assignment pass.  The complete info is not needed for the
   coalescing and spill passes.  
lra_insn_recog_data_t curr_id
static
   The insn data.  
rtx curr_insn
static
   Insn currently scanned.  
struct lra_static_insn_data* curr_static_id
static
   The insn static data.  
sparseset dead_set
static
HARD_REG_SET hard_regs_live
static
   Set of hard regs (except eliminable ones) currently live.  

Referenced by lra_intersected_live_ranges_p().

alloc_pool live_range_pool
static
   Pool for pseudo live ranges.  
int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER]
   Accumulated execution frequency of all references for each hard
   register.  

Referenced by lra_debug_live_ranges(), and update_hard_regno_preference().

int lra_live_max_point
@verbatim 

Build live ranges for pseudos. Copyright (C) 2010-2013 Free Software Foundation, Inc. Contributed by Vladimir Makarov vmaka.nosp@m.rov@.nosp@m.redha.nosp@m.t.co.nosp@m.m.

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 contains code to build pseudo live-ranges (analogous
   structures used in IRA, so read comments about the live-ranges
   there) and other info necessary for other passes to assign
   hard-registers to pseudos, coalesce the spilled pseudos, and assign
   stack memory slots to spilled pseudos.  
   Program points are enumerated by numbers from range
   0..LRA_LIVE_MAX_POINT-1.  There are approximately two times more
   program points than insns.  Program points are places in the
   program where liveness info can be changed.  In most general case
   (there are more complicated cases too) some program points
   correspond to places where input operand dies and other ones
   correspond to places where output operands are born.  

Referenced by finish_live_range_start_chains(), remove_some_program_points_and_update_live_ranges(), and update_lives().

int lra_live_range_iter
   The number of the current live range pass.  
int* lra_point_freq
   The start of the above vector elements.  
vec<int> point_freq_vec
static
   Vec containing execution frequencies of program points.  
sparseset pseudos_live
static
   Pseudos live at current point in the RTL scan.  
sparseset pseudos_live_through_calls
static
   Pseudos probably living through calls and setjumps.  As setjump is
   a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up
   then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up
   too.  These data are necessary for cases when only one subreg of a
   multi-reg pseudo is set up after a call.  So we decide it is
   probably live when traversing bb backward.  We are sure about
   living when we see its usage or definition of the pseudo.  
sparseset pseudos_live_through_setjumps
static
sparseset start_dying
static
sparseset start_living
static
   Set of pseudos and hard registers start living/dying in the current
   insn.  These sets are used to update REG_DEAD and REG_UNUSED notes
   in the insn.  
sparseset unused_set
static
   Set of pseudos and hard regs dead and unused in the current
   insn.