GCC Middle and Back End API Reference
gimple-harden-conditionals.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "fold-const.h"
#include "gimple.h"
#include "gimplify.h"
#include "tree-pass.h"
#include "ssa.h"
#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "basic-block.h"
#include "cfghooks.h"
#include "cfgloop.h"
#include "tree-eh.h"
#include "sbitmap.h"
#include "diagnostic.h"
#include "intl.h"
Include dependency graph for gimple-harden-conditionals.cc:

Functions

static tree detach_value (location_t loc, gimple_stmt_iterator *gsip, tree val)
 
static void insert_check_and_trap (location_t loc, gimple_stmt_iterator *gsip, int flags, enum tree_code cop, tree lhs, tree rhs)
 
static void insert_edge_check_and_trap (location_t loc, edge e, enum tree_code cop, tree lhs, tree rhs)
 
gimple_opt_passmake_pass_harden_conditional_branches (gcc::context *ctxt)
 
static edge non_eh_succ_edge (basic_block bb, edge *ehp=NULL)
 
gimple_opt_passmake_pass_harden_compares (gcc::context *ctxt)
 

Function Documentation

◆ detach_value()

static tree detach_value ( location_t loc,
gimple_stmt_iterator * gsip,
tree val )
inlinestatic
If VAL is an SSA name, return an SSA name holding the same value,
but without the compiler's knowing that it holds the same value, so
that uses thereof can't be optimized the way VAL might.  Insert
stmts that initialize it before *GSIP, with LOC.

Otherwise, VAL must be an invariant, returned unchanged.   

References build_clobber(), build_string(), build_tree_list(), create_tmp_var, gcc_checking_assert, gimple_build_asm_vec(), gimple_build_assign(), gimple_set_location(), gsi_insert_before(), GSI_SAME_STMT, i, is_gimple_min_invariant(), make_ssa_name(), mark_addressable(), NULL, NULL_TREE, reg_class_contents, SSA_NAME_DEF_STMT, targetm, TEST_HARD_REG_BIT, TREE_CODE, TREE_CONSTANT, TREE_TYPE, TYPE_MODE, and vec_safe_push().

◆ insert_check_and_trap()

static void insert_check_and_trap ( location_t loc,
gimple_stmt_iterator * gsip,
int flags,
enum tree_code cop,
tree lhs,
tree rhs )
inlinestatic
Build a cond stmt out of COP, LHS, RHS, insert it before *GSIP with
location LOC.  *GSIP must be at the end of a basic block.  The succ
edge out of the block becomes the true or false edge opposite to
that in FLAGS.  Create a new block with a single trap stmt, in the
cold partition if the function is partitioned,, and a new edge to
it as the other edge for the cond.   

References add_bb_to_loop(), profile_probability::always(), BB_PARTITION, BB_SET_PARTITION, builtin_decl_explicit(), CDI_DOMINATORS, basic_block_def::count, create_empty_bb(), current_loops, dom_info_available_p(), dump_file, gcc_assert, gimple_build_call(), gimple_build_cond(), gimple_call_set_ctrl_altering(), gimple_set_location(), gsi_after_labels(), gsi_bb(), gsi_insert_before(), GSI_SAME_STMT, basic_block_def::index, make_edge(), profile_probability::never(), NULL, set_immediate_dominator(), single_succ_edge(), and profile_count::zero().

Referenced by insert_edge_check_and_trap().

◆ insert_edge_check_and_trap()

static void insert_edge_check_and_trap ( location_t loc,
edge e,
enum tree_code cop,
tree lhs,
tree rhs )
inlinestatic
Split edge E, and insert_check_and_trap (see above) in the
newly-created block, using already-detached copies of LHS's and
RHS's values (see detach_value above) for the COP compare.   

References dump_file, gsi_after_labels(), basic_block_def::index, insert_check_and_trap(), NULL, single_pred_edge(), single_succ_edge(), and split_edge().

◆ make_pass_harden_compares()

gimple_opt_pass * make_pass_harden_compares ( gcc::context * ctxt)
Instantiate a hardcmp pass.   

◆ make_pass_harden_conditional_branches()

gimple_opt_pass * make_pass_harden_conditional_branches ( gcc::context * ctxt)
Instantiate a hardcbr pass.   

◆ non_eh_succ_edge()

static edge non_eh_succ_edge ( basic_block bb,
edge * ehp = NULL )
inlinestatic
Return the fallthru edge of a block whose other edge is an EH
edge.  If EHP is not NULL, store the EH edge in it.   

References EDGE_COUNT, EDGE_SUCC, find_fallthru_edge(), gcc_checking_assert, and basic_block_def::succs.