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 "ssa.h"
#include "tree-pass.h"
#include "tree-ssa-operands.h"
#include "gimple-pretty-print.h"
#include "fold-const.h"
#include "gimple-iterator.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "ubsan.h"
#include "tree-hash-traits.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
#include "gimplify.h"
#include "gimple-walk.h"
#include "cfghooks.h"
#include "tree-dfa.h"
#include "tree-ssa.h"
#include "varasm.h"
Data Structures | |
struct | sanopt_info |
struct | sanopt_tree_triplet |
struct | sanopt_tree_triplet_hash |
struct | sanopt_tree_couple |
struct | sanopt_tree_couple_hash |
class | sanopt_ctx |
|
static |
Returns TRUE if ASan check of length LEN in block BB can be removed if preceded by checks in V.
References basic_block_def::aux, CDI_DOMINATORS, FOR_EACH_VEC_ELT_REVERSE, g, gcc_assert, get_immediate_dominator(), gimple_bb(), gimple_call_arg(), gimple_uid(), i, imm_dom_path_with_freeing_call(), NULL, same_value_p(), si, TREE_CODE, and tree_int_cst_lt().
Referenced by maybe_optimize_asan_check_ifn().
|
static |
Return true when pointer PTR for a given CUR_OFFSET is already sanitized in a given sanitization context CTX.
References g, gcc_assert, hash_map< KeyId, Value, Traits >::get_or_insert(), gimple_call_arg(), wi::les_p(), maybe_get_dominating_check(), wi::neg_p(), offset, POINTER_SIZE, sanopt_tree_couple::pos_p, sanopt_tree_couple::ptr, sanopt_ctx::ptr_check_map, wi::sext(), wi::to_offset(), and TREE_CODE.
Referenced by maybe_optimize_ubsan_ptr_ifn().
|
static |
Return true if there might be any call to free/munmap operation on any path in between DOM (which should be imm(BB)) and BB.
References basic_block_def::aux, sanopt_info::being_visited_p, CDI_DOMINATORS, dyn_cast(), FOR_EACH_EDGE, get_immediate_dominator(), gimple_asm_clobbers_memory_p(), gimple_asm_volatile_p(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), imm_dom_path_with_freeing_call(), sanopt_info::imm_dom_path_with_freeing_call_computed_p, sanopt_info::imm_dom_path_with_freeing_call_p, is_gimple_call(), nonfreeing_call_p(), and basic_block_def::preds.
Referenced by can_remove_asan_check(), and imm_dom_path_with_freeing_call().
gimple_opt_pass * make_pass_sanopt | ( | gcc::context * | ctxt | ) |
Get the first dominating check from the list of stored checks. Non-dominating checks are silently dropped.
References basic_block_def::aux, g, gimple_bb(), NULL, and si.
Referenced by has_dominating_ubsan_ptr_check(), maybe_optimize_asan_check_ifn(), maybe_optimize_ubsan_null_ifn(), and maybe_optimize_ubsan_vptr_ifn().
If T has a single definition of form T = T2, return T2.
References g, gimple_assign_single_p(), NULL, SSA_NAME_DEF_STMT, and TREE_CODE.
Referenced by maybe_optimize_asan_check_ifn().
|
static |
Optimize away redundant ASAN_CHECK calls.
References sanopt_ctx::asan_check_map, basic_block_def::aux, can_remove_asan_check(), sanopt_info::freeing_call_events, g, gcc_assert, hash_map< KeyId, Value, Traits >::get(), hash_map< KeyId, Value, Traits >::get_or_insert(), gimple_assign_rhs1(), gimple_bb(), gimple_call_arg(), gimple_call_num_args(), gimple_set_uid(), integer_zerop(), maybe_get_dominating_check(), maybe_get_single_definition(), NULL, NULL_TREE, and TREE_CODE.
Referenced by sanopt_optimize_walker().
|
static |
Optimize away redundant UBSAN_NULL calls.
References g, gcc_assert, hash_map< KeyId, Value, Traits >::get_or_insert(), gimple_bb(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), integer_zerop(), maybe_get_dominating_check(), sanopt_ctx::null_check_map, SANITIZE_ALIGNMENT, SANITIZE_NULL, TREE_CODE, tree_int_cst_compare(), tree_int_cst_le(), tree_to_shwi(), UBSAN_LOAD_OF, UBSAN_MEMBER_ACCESS, and UBSAN_STORE_OF.
Referenced by sanopt_optimize_walker().
|
static |
Optimize away redundant UBSAN_PTR calls.
References build1(), build_pointer_type(), decl_binds_to_current_def_p(), DECL_P, DECL_REGISTER, DECL_SIZE_UNIT, gcc_assert, get_inner_reference(), gimple_call_arg(), gimple_call_num_args(), has_dominating_ubsan_ptr_check(), integer_zerop(), poly_int< N, C >::is_constant(), is_global_var(), wi::les_p(), wi::neg_p(), NULL_TREE, offset, operand_equal_p(), POINTER_SIZE, record_ubsan_ptr_check_stmt(), wi::sext(), wi::to_offset(), TREE_CODE, TREE_OPERAND, TREE_TYPE, and VAR_P.
Referenced by sanopt_optimize_walker().
|
static |
Optimize away redundant UBSAN_VPTR calls. The second argument is the value loaded from the virtual table, so rely on FRE to find out when we can actually optimize.
References g, gcc_assert, hash_map< KeyId, Value, Traits >::get_or_insert(), gimple_call_arg(), gimple_call_num_args(), maybe_get_dominating_check(), sanopt_tree_triplet::t1, sanopt_tree_triplet::t2, sanopt_tree_triplet::t3, and sanopt_ctx::vptr_check_map.
Referenced by sanopt_optimize_walker().
|
static |
Record UBSAN_PTR check of given context CTX. Register pointer PTR on a given OFFSET that it's handled by GIMPLE STMT.
References hash_map< KeyId, Value, Traits >::get_or_insert(), wi::neg_p(), offset, sanopt_tree_couple::pos_p, sanopt_tree_couple::ptr, and sanopt_ctx::ptr_check_map.
Referenced by maybe_optimize_ubsan_ptr_ifn().
Checks whether value of T in CHECK and USE is the same.
References gimple_vuse(), is_gimple_min_invariant(), and TREE_CODE.
Referenced by can_remove_asan_check().
Try to remove redundant sanitizer checks in function FUN.
References alloc_aux_for_blocks(), sanopt_ctx::asan_num_accesses, calculate_dominance_info(), CDI_DOMINATORS, sanopt_ctx::contains_asan_mark, ENTRY_BLOCK_PTR_FOR_FN, free_aux_for_blocks(), and sanopt_optimize_walker().
|
static |
Try to optimize away redundant UBSAN_NULL and ASAN_CHECK calls. We walk blocks in the CFG via a depth first search of the dominator tree; we push unique UBSAN_NULL or ASAN_CHECK statements into a vector in the NULL_CHECK_MAP or ASAN_CHECK_MAP hash maps as we enter the blocks. When leaving a block, we mark the block as visited; then when checking the statements in the vector, we ignore statements that are coming from already visited blocks, because these cannot dominate anything anymore. CTX is a sanopt context.
References sanopt_ctx::asan_num_accesses, basic_block_def::aux, CDI_DOMINATORS, sanopt_ctx::contains_asan_mark, dump_file, dump_flags, dyn_cast(), first_dom_son(), sanopt_info::freeing_call_events, gcc_assert, gimple_asm_clobbers_memory_p(), gimple_asm_volatile_p(), gimple_call_builtin_p(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_vdef(), gsi_end_p(), gsi_for_stmt(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_stmt(), sanopt_info::has_freeing_call_computed_p, sanopt_info::has_freeing_call_p, hwasan_sanitize_p(), is_gimple_call(), maybe_optimize_asan_check_ifn(), maybe_optimize_ubsan_null_ifn(), maybe_optimize_ubsan_ptr_ifn(), maybe_optimize_ubsan_vptr_ifn(), next_dom_son(), nonfreeing_call_p(), print_gimple_stmt(), SANITIZE_ADDRESS, SANITIZE_HWADDRESS, sanopt_optimize_walker(), single_imm_use(), TDF_DETAILS, unlink_stmt_vdef(), and sanopt_info::visited_p.
Referenced by sanopt_optimize(), and sanopt_optimize_walker().