GCC Middle and Back End API Reference
split_bb_info Class Reference
Collaboration diagram for split_bb_info:

Data Fields

unsigned int size
 
sreal time
 

Detailed Description

Function splitting pass
   Copyright (C) 2010-2024 Free Software Foundation, Inc.
   Contributed by Jan Hubicka  <jh@suse.cz>

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/>.   
The purpose of this pass is to split function bodies to improve
inlining.  I.e. for function of the form:

func (...)
  {
    if (cheap_test)
      something_small
    else
      something_big
  }

Produce:

func.part (...)
  {
     something_big
  }

func (...)
  {
    if (cheap_test)
      something_small
    else
      func.part (...);
  }

When func becomes inlinable and when cheap_test is often true, inlining func,
but not fund.part leads to performance improvement similar as inlining
original func while the code size growth is smaller.

The pass is organized in three stages:
1) Collect local info about basic block into BB_INFO structure and
   compute function body estimated size and time.
2) Via DFS walk find all possible basic blocks where we can split
   and chose best one.
3) If split point is found, split at the specified BB by creating a clone
   and updating function to call it.  

The decisions what functions to split are in execute_split_functions
and consider_split.  

There are several possible future improvements for this pass including:

1) Splitting to break up large functions
2) Splitting to reduce stack frame usage
3) Allow split part of function to use values computed in the header part.
   The values needs to be passed to split function, perhaps via same
   interface as for nested functions or as argument.
4) Support for simple rematerialization.  I.e. when split part use
   value computed in header from function parameter in very cheap way, we
   can just recompute it.
5) Support splitting of nested functions.
6) Support non-SSA arguments.  
7) There is nothing preventing us from producing multiple parts of single function
   when needed or splitting also the parts.   
Per basic block info.   

Field Documentation

◆ size

unsigned int split_bb_info::size

◆ time

sreal split_bb_info::time

The documentation for this class was generated from the following file: