GCC Middle and Back End API 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"
Data Structures | |
struct | return_statements_t |
struct | lower_data |
struct | lower_assumption_data |
Typedefs | |
typedef struct return_statements_t | return_statements_t |
typedef struct return_statements_t return_statements_t |
Adjust trees in the assumption body. Called through walk_tree.
References build_simple_mem_ref, gcc_assert, NULL_TREE, remap_decl(), TREE_CODE, TREE_THIS_NOTRAP, and TREE_THIS_VOLATILE.
Referenced by lower_assumption().
|
static |
Transform gotos out of the assumption into return false.
References as_a(), create_artificial_label(), current_function_decl, DECL_CONTEXT, gimple_cond_false_label(), gimple_cond_set_false_label(), gimple_cond_set_true_label(), gimple_cond_true_label(), gimple_goto_dest(), gimple_goto_set_dest(), gimple_label_label(), gsi_stmt(), NULL_TREE, and UNKNOWN_LOCATION.
Referenced by lower_assumption().
|
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, 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().
|
static |
Create an artificial FUNCTION_DECL for assumption at LOC.
References BLOCK_SUPERCONTEXT, boolean_type_node, build_decl(), build_varargs_function_type_list(), cfun, clone_function_name_numbered(), current_function_decl, DECL_ARTIFICIAL, DECL_ATTRIBUTES, DECL_CONTEXT, DECL_EXTERNAL, DECL_FUNCTION_SPECIFIC_OPTIMIZATION, DECL_FUNCTION_SPECIFIC_TARGET, DECL_IGNORED_P, DECL_INITIAL, DECL_NAMELESS, DECL_RESULT, DECL_SOURCE_LOCATION, DECL_UNINLINABLE, get_identifier(), init_tree_ssa(), lookup_attribute(), make_node(), NULL, NULL_TREE, push_struct_function(), tree_cons(), TREE_PUBLIC, TREE_STATIC, and TREE_USED.
Referenced by lower_assumption().
|
static |
Helper function for lower_assumptions. Find local vars and labels in the assumption sequence and remove debug stmts.
References as_a(), boolean_false_node, DECL_CHAIN, DECL_CONTEXT, DECL_EXTERNAL, g, gcc_assert, 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().
bool gimple_seq_may_fallthru | ( | gimple_seq | seq | ) |
Same as gimple_stmt_may_fallthru, but for the gimple sequence SEQ.
References gimple_seq_last_nondebug_stmt(), and gimple_stmt_may_fallthru().
Referenced by frob_into_branch_around(), gimple_stmt_may_fallthru(), gimple_try_catch_may_fallthru(), gimplify_cond_expr(), honor_protect_cleanup_actions(), lower_catch(), lower_cleanup(), lower_function_body(), and lower_try_finally().
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 as_a(), 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().
Try to determine whether a TRY_CATCH expression can fall through. This is a subroutine of gimple_stmt_may_fallthru.
References as_a(), gcc_assert, 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().
|
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, copy_body_data::copy_decl, create_assumption_fn(), create_tmp_var, function::curr_properties, current_function_decl, DECL_ARGUMENTS, DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, DECL_CHAIN, DECL_CONTEXT, copy_body_data::decl_map, DECL_STRUCT_FUNCTION, lower_assumption_data::decls, copy_body_data::do_not_fold, copy_body_data::do_not_unshare, copy_body_data::dst_fn, find_assumption_locals_r(), g, gcc_assert, hash_map< KeyId, Value, Traits >::get(), 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(), lower_assumption_data::guard_copy, i, lower_assumption_data::id, 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(), lower_assumption_data::return_false_label, copy_body_data::src_cfun, copy_body_data::src_fn, walk_stmt_info::stmt, copy_body_data::transform_call_graph_edges, copy_body_data::transform_parameter, TREE_ADDRESSABLE, TREE_CODE, tree_cons(), TREE_THIS_VOLATILE, TREE_TYPE, VAR_P, void_list_node, and walk_gimple_stmt().
Referenced by lower_stmt().
|
static |
Lower calls to __builtin_assume_aligned when not optimizing.
References as_a(), get_ptr_info(), gimple_call_arg(), gimple_call_lhs(), gimple_call_num_args(), walk_stmt_info::gsi, gsi_stmt(), NULL_TREE, POINTER_TYPE_P, set_ptr_info_alignment(), TREE_CODE, tree_fits_uhwi_p(), TREE_INT_CST_LOW, and TREE_TYPE.
Referenced by lower_stmt().
|
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, 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().
|
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, 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().
|
static |
Lower the body of current_function_decl from High GIMPLE into Low GIMPLE.
References BLOCK_CHAIN, BLOCK_SUBBLOCKS, blocks_nreverse(), cfun, clear_block_marks(), current_function_decl, DECL_INITIAL, gcc_assert, gimple_body(), gimple_build_label(), gimple_build_return(), gimple_return_retval(), gimple_seq_add_stmt(), gimple_seq_first(), gimple_seq_first_stmt(), gimple_seq_last(), gimple_seq_may_fallthru(), gimple_set_block(), gimple_set_body(), gimple_set_location(), GSI_CONTINUE_LINKING, gsi_insert_after(), gsi_last(), gsi_start(), i, return_statements_t::label, lower_gimple_bind(), MAY_HAVE_DEBUG_MARKER_STMTS, NULL, NULL_TREE, return_statements_t::stmt, TREE_ASM_WRITTEN, and UNKNOWN_LOCATION.
|
static |
Lower a bind_expr TSI. DATA is passed through the recursion.
References as_a(), BLOCK_CHAIN, BLOCK_SUBBLOCKS, BLOCK_SUPERCONTEXT, BLOCK_VARS, blocks_nreverse(), current_function_decl, DECL_CHAIN, DECL_INITIAL, gcc_assert, gimple_bind_block(), gimple_bind_body(), gimple_bind_body_ptr(), gimple_bind_vars(), walk_stmt_info::gsi, gsi_insert_seq_before(), gsi_remove(), GSI_SAME_STMT, gsi_stmt(), lower_sequence(), NULL, NULL_TREE, record_vars(), walk_stmt_info::stmt, TREE_ASM_WRITTEN, and TREE_VISITED.
Referenced by lower_function_body(), and lower_stmt().
|
static |
Lower a GIMPLE_RETURN GSI. DATA is passed through the recursion.
References as_a(), cfun, create_artificial_label(), DECL_ARTIFICIAL, gimple_build_goto(), gimple_has_location(), gimple_location(), gimple_return_retval(), gimple_set_location(), walk_stmt_info::gsi, gsi_insert_before(), gsi_remove(), GSI_SAME_STMT, gsi_stmt(), i, return_statements_t::label, return_statements_t::stmt, walk_stmt_info::stmt, and UNKNOWN_LOCATION.
Referenced by lower_stmt().
|
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().
|
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().
|
static |
Lower statement GSI. DATA is passed through the recursion. We try to track the fallthruness of statements and get rid of unreachable return statements in order to prevent the EH lowering pass from adding useless edges that can cause bogus warnings to be issued later; this guess need not be 100% accurate, simply be conservative and reset cannot_fallthru to false if we don't know.
References as_a(), BUILT_IN_NORMAL, cfun, DECL_FUNCTION_CODE(), ECF_NORETURN, EXPR_P, flags_from_decl_or_type(), fndecl_built_in_p(), fold_stmt(), gcc_checking_assert, gcc_unreachable, gimple_builtin_call_types_compatible_p(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_fndecl(), gimple_call_internal_p(), gimple_call_num_args(), gimple_debug_nonbind_marker_p(), gimple_eh_else_e_body_ptr(), gimple_eh_else_n_body_ptr(), gimple_set_block(), gimple_transaction_body_ptr(), GIMPLE_TRY_CATCH, gimple_try_cleanup_ptr(), gimple_try_eval_ptr(), gimple_try_kind(), walk_stmt_info::gsi, gsi_next(), gsi_remove(), gsi_stmt(), i, lower_assumption(), lower_builtin_assume_aligned(), lower_builtin_posix_memalign(), lower_builtin_setjmp(), lower_gimple_bind(), lower_gimple_return(), lower_omp_directive(), lower_sequence(), lower_try_catch(), MAY_HAVE_DEBUG_MARKER_STMTS, walk_stmt_info::stmt, TREE_CODE, TREE_OPERAND, TREE_SET_BLOCK, TREE_STATIC, and VAR_P.
Referenced by lower_sequence().
|
static |
Same as above, but for a GIMPLE_TRY_CATCH.
References as_a(), gcc_assert, gcc_checking_assert, gimple_catch_handler_ptr(), gimple_debug_begin_stmt_p(), gimple_eh_filter_failure_ptr(), GIMPLE_TRY_CATCH, gimple_try_cleanup_ptr(), gimple_try_eval_ptr(), gimple_try_kind(), walk_stmt_info::gsi, gsi_end_p(), gsi_next(), gsi_start(), gsi_stmt(), i, lower_sequence(), and walk_stmt_info::stmt.
Referenced by lower_stmt().
gimple_opt_pass * make_pass_lower_cf | ( | gcc::context * | ctxt | ) |
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 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().