GCC Middle and Back End API Reference
gimple-low.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "tree-pass.h"
#include "fold-const.h"
#include "tree-nested.h"
#include "calls.h"
#include "gimple-iterator.h"
#include "gimple-low.h"
#include "predict.h"
#include "gimple-predict.h"
#include "gimple-fold.h"
#include "cgraph.h"
#include "tree-ssa.h"
#include "value-range.h"
#include "stringpool.h"
#include "tree-ssanames.h"
#include "tree-inline.h"
#include "gimple-walk.h"
#include "attribs.h"
Include dependency graph for gimple-low.cc:

Data Structures

struct  return_statements_t
 
struct  lower_data
 
struct  lower_assumption_data
 

Typedefs

typedef struct return_statements_t return_statements_t
 

Functions

static void lower_stmt (gimple_stmt_iterator *, struct lower_data *)
 
static void lower_gimple_bind (gimple_stmt_iterator *, struct lower_data *)
 
static void lower_try_catch (gimple_stmt_iterator *, struct lower_data *)
 
static void lower_gimple_return (gimple_stmt_iterator *, struct lower_data *)
 
static void lower_builtin_setjmp (gimple_stmt_iterator *)
 
static void lower_builtin_posix_memalign (gimple_stmt_iterator *)
 
static void lower_builtin_assume_aligned (gimple_stmt_iterator *)
 
static unsigned int lower_function_body (void)
 
gimple_opt_passmake_pass_lower_cf (gcc::context *ctxt)
 
static void lower_sequence (gimple_seq *seq, struct lower_data *data)
 
static void lower_omp_directive (gimple_stmt_iterator *gsi, struct lower_data *data)
 
static tree create_assumption_fn (location_t loc)
 
static tree find_assumption_locals_r (gimple_stmt_iterator *gsi_p, bool *, struct walk_stmt_info *wi)
 
static tree assumption_copy_decl (tree decl, copy_body_data *id)
 
static tree adjust_assumption_stmt_r (gimple_stmt_iterator *gsi_p, bool *, struct walk_stmt_info *wi)
 
static tree adjust_assumption_stmt_op (tree *tp, int *, void *datap)
 
static void lower_assumption (gimple_stmt_iterator *gsi, struct lower_data *data)
 
static bool gimple_try_catch_may_fallthru (gtry *stmt)
 
bool gimple_stmt_may_fallthru (gimple *stmt)
 
bool gimple_seq_may_fallthru (gimple_seq seq)
 
void record_vars_into (tree vars, tree fn)
 
void record_vars (tree vars)
 

Typedef Documentation

◆ return_statements_t

typedef struct return_statements_t return_statements_t

Function Documentation

◆ adjust_assumption_stmt_op()

static tree adjust_assumption_stmt_op ( tree * tp,
int * ,
void * datap )
static
Adjust trees in the assumption body.  Called through walk_tree.   

References build_simple_mem_ref, gcc_assert, ggc_alloc(), NULL_TREE, remap_decl(), TREE_CODE, TREE_THIS_NOTRAP, and TREE_THIS_VOLATILE.

Referenced by lower_assumption().

◆ adjust_assumption_stmt_r()

◆ assumption_copy_decl()

static tree assumption_copy_decl ( tree decl,
copy_body_data * id )
static
Create a new PARM_DECL that is indentical in all respect to DECL except that
DECL can be either a VAR_DECL, a PARM_DECL or RESULT_DECL.  The original
DECL must come from ID->src_fn and the copy will be part of ID->dst_fn.   

References build_decl(), build_pointer_type(), copy_decl_for_dup_finish(), DECL_ARG_TYPE, DECL_BY_REFERENCE, DECL_NAME, DECL_NOT_GIMPLE_REG_P, DECL_PT_UID, DECL_PT_UID_SET_P, DECL_SOURCE_LOCATION, gcc_assert, ggc_alloc(), is_global_var(), SET_DECL_PT_UID, TREE_ADDRESSABLE, TREE_CODE, TREE_READONLY, TREE_THIS_VOLATILE, TREE_TYPE, type(), and VAR_P.

Referenced by lower_assumption().

◆ create_assumption_fn()

◆ find_assumption_locals_r()

static tree find_assumption_locals_r ( gimple_stmt_iterator * gsi_p,
bool * ,
struct walk_stmt_info * wi )
static
Helper function for lower_assumptions.  Find local vars and labels
in the assumption sequence and remove debug stmts.   

References boolean_false_node, DECL_CHAIN, DECL_CONTEXT, DECL_EXTERNAL, g, gcc_assert, ggc_alloc(), gimple_bind_vars(), gimple_build_assign(), gimple_get_lhs(), gimple_label_label(), gimple_return_set_retval(), gsi_insert_before(), gsi_remove(), GSI_SAME_STMT, gsi_stmt(), NULL_TREE, SSA_NAME_VAR, TREE_CODE, and VAR_P.

Referenced by lower_assumption().

◆ gimple_seq_may_fallthru()

◆ gimple_stmt_may_fallthru()

bool gimple_stmt_may_fallthru ( gimple * stmt)
Try to determine if we can continue executing the statement
immediately following STMT.  This guess need not be 100% accurate;
simply be conservative and return true if we don't know.  This is
used only to avoid stupidly generating extra code. If we're wrong,
we'll just delete the extra code later.   

References ggc_alloc(), gimple_bind_body(), gimple_call_noreturn_p(), gimple_eh_else_e_body(), gimple_eh_else_n_body(), gimple_seq_may_fallthru(), GIMPLE_TRY_CATCH, gimple_try_catch_may_fallthru(), gimple_try_cleanup(), gimple_try_eval(), gimple_try_kind(), and walk_stmt_info::stmt.

Referenced by convert_nl_goto_receiver(), gimple_seq_may_fallthru(), last_stmt_in_scope(), lower_eh_constructs_2(), and warn_implicit_fallthrough_r().

◆ gimple_try_catch_may_fallthru()

static bool gimple_try_catch_may_fallthru ( gtry * stmt)
static
Try to determine whether a TRY_CATCH expression can fall through.
This is a subroutine of gimple_stmt_may_fallthru.   

References gcc_assert, ggc_alloc(), gimple_catch_handler(), gimple_eh_filter_failure(), gimple_seq_may_fallthru(), GIMPLE_TRY_CATCH, gimple_try_cleanup_ptr(), gimple_try_eval(), gimple_try_kind(), gsi_end_p(), gsi_next(), gsi_start(), gsi_stmt(), i, and walk_stmt_info::stmt.

Referenced by gimple_stmt_may_fallthru().

◆ lower_assumption()

static void lower_assumption ( gimple_stmt_iterator * gsi,
struct lower_data * data )
static
Lower assumption.
The gimplifier transformed:
.ASSUME (cond);
into:
[[assume (guard)]]
{
  guard = cond;
}
which we should transform into:
.ASSUME (&artificial_fn, args...);
where artificial_fn will look like:
bool artificial_fn (args...)
{
  guard = cond;
  return guard;
}
with any debug stmts in the block removed and jumps out of
the block or return stmts replaced with return false;   

References cgraph_node::add_new_function(), adjust_assumption_stmt_op(), adjust_assumption_stmt_r(), assumption_copy_decl(), boolean_false_node, boolean_type_node, build_fold_addr_expr, build_function_type(), CB_CGE_DUPLICATE, cfun, create_assumption_fn(), create_tmp_var, current_function_decl, DECL_ARGUMENTS, DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, DECL_CHAIN, DECL_CONTEXT, DECL_STRUCT_FUNCTION, find_assumption_locals_r(), g, gcc_assert, hash_map< KeyId, Value, Traits >::get(), ggc_alloc(), gimple_assume_body(), gimple_assume_body_ptr(), gimple_assume_guard(), gimple_build_assign(), gimple_build_bind(), gimple_build_call_internal_vec(), gimple_build_label(), gimple_build_return(), gimple_location(), gimple_seq_add_stmt(), gimple_set_body(), gimple_set_location(), walk_stmt_info::gsi, gsi_insert_before(), gsi_replace(), GSI_SAME_STMT, gsi_start(), gsi_stmt(), i, is_gimple_reg_type(), is_gimple_val(), is_global_var(), make_ssa_name(), NULL, NULL_TREE, pop_cfun(), hash_map< KeyId, Value, Traits >::put(), release_ssa_name(), remap_type(), walk_stmt_info::stmt, TREE_ADDRESSABLE, TREE_CODE, tree_cons(), TREE_THIS_VOLATILE, TREE_TYPE, VAR_P, void_list_node, and walk_gimple_stmt().

Referenced by lower_stmt().

◆ lower_builtin_assume_aligned()

static void lower_builtin_assume_aligned ( gimple_stmt_iterator * gsi)
static

◆ lower_builtin_posix_memalign()

static void lower_builtin_posix_memalign ( gimple_stmt_iterator * gsi)
static
Lower calls to posix_memalign to
  res = posix_memalign (ptr, align, size);
  if (res == 0)
    *ptr = __builtin_assume_aligned (*ptr, align);
or to
  void *tem;
  res = posix_memalign (&tem, align, size);
  if (res == 0)
    ptr = __builtin_assume_aligned (tem, align);
in case the first argument was &ptr.  That way we can get at the
alignment of the heap pointer in CCP.   

References build_fold_addr_expr, build_int_cst(), builtin_decl_implicit(), create_artificial_label(), create_tmp_reg(), create_tmp_var, fold_build2, ggc_alloc(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_build_label(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_arg(), gimple_call_set_lhs(), walk_stmt_info::gsi, gsi_insert_after(), GSI_NEW_STMT, gsi_stmt(), integer_type_node, integer_zero_node, NULL_TREE, ptr_type_node, walk_stmt_info::stmt, TREE_ADDRESSABLE, TREE_CODE, and UNKNOWN_LOCATION.

Referenced by lower_stmt().

◆ lower_builtin_setjmp()

static void lower_builtin_setjmp ( gimple_stmt_iterator * gsi)
static
Lower a __builtin_setjmp GSI.

__builtin_setjmp is passed a pointer to an array of five words (not
all will be used on all machines).  It operates similarly to the C
library function of the same name, but is more efficient.

It is lowered into 2 other builtins, namely __builtin_setjmp_setup,
__builtin_setjmp_receiver.

After full lowering, the body of the function should look like:

 {
   int D.1844;
   int D.2844;

   [...]

   __builtin_setjmp_setup (&buf, &<D1847>);
   D.1844 = 0;
   goto <D1846>;
   <D1847>:;
   __builtin_setjmp_receiver (&<D1847>);
   D.1844 = 1;
   <D1846>:;
   if (D.1844 == 0) goto <D1848>; else goto <D1849>;

   [...]

   __builtin_setjmp_setup (&buf, &<D2847>);
   D.2844 = 0;
   goto <D2846>;
   <D2847>:;
   __builtin_setjmp_receiver (&<D2847>);
   D.2844 = 1;
   <D2846>:;
   if (D.2844 == 0) goto <D2848>; else goto <D2849>;

   [...]

   <D3850>:;
   return;
 }

During cfg creation an extra per-function (or per-OpenMP region)
block with ABNORMAL_DISPATCHER internal call will be added, unique
destination of all the abnormal call edges and the unique source of
all the abnormal edges to the receivers, thus keeping the complexity
explosion localized.   

References build_addr(), build_zero_cst(), builtin_decl_implicit(), cfun, create_artificial_label(), create_tmp_reg(), fold_convert_loc(), FORCED_LABEL, g, ggc_alloc(), gimple_build_assign(), gimple_build_call(), gimple_build_goto(), gimple_build_label(), gimple_call_arg(), gimple_call_lhs(), gimple_location(), gimple_set_location(), walk_stmt_info::gsi, gsi_insert_before(), gsi_remove(), GSI_SAME_STMT, gsi_stmt(), integer_one_node, walk_stmt_info::stmt, TREE_CODE, and TREE_TYPE.

Referenced by lower_stmt().

◆ lower_function_body()

◆ lower_gimple_bind()

◆ lower_gimple_return()

◆ lower_omp_directive()

static void lower_omp_directive ( gimple_stmt_iterator * gsi,
struct lower_data * data )
static
Lower the OpenMP directive statement pointed by GSI.  DATA is
passed through the recursion.   

References gimple_omp_body(), gimple_omp_body_ptr(), gimple_omp_set_body(), GSI_CONTINUE_LINKING, gsi_insert_seq_after(), gsi_next(), gsi_stmt(), lower_sequence(), and NULL.

Referenced by lower_stmt().

◆ lower_sequence()

static void lower_sequence ( gimple_seq * seq,
struct lower_data * data )
static
Lower sequence SEQ.  Unlike gimplification the statements are not relowered
when they are changed -- if this has to be done, the lowering routine must
do it explicitly.  DATA is passed through the recursion.   

References gsi_end_p(), gsi_start(), and lower_stmt().

Referenced by lower_gimple_bind(), lower_omp_directive(), lower_stmt(), and lower_try_catch().

◆ lower_stmt()

◆ lower_try_catch()

◆ make_pass_lower_cf()

gimple_opt_pass * make_pass_lower_cf ( gcc::context * ctxt)

References ggc_alloc().

◆ record_vars()

void record_vars ( tree vars)
Record the variables in VARS into current_function_decl.   

References current_function_decl, and record_vars_into().

Referenced by gimple_add_tmp_var(), lower_gimple_bind(), omp_copy_decl_2(), and pop_gimplify_context().

◆ record_vars_into()

void record_vars_into ( tree vars,
tree fn )
Record the variables in VARS into function FN.   

References add_local_decl(), DECL_CHAIN, DECL_EXTERNAL, DECL_STRUCT_FUNCTION, and VAR_P.

Referenced by gimple_add_tmp_var_fn(), lower_omp_target(), lower_omp_taskreg(), and record_vars().