GCC Middle and Back End API Reference
|
Data Structures | |
struct | mf_xform_decls_data |
Variables | |
static tree | mf_uintptr_type |
static tree | mf_cache_struct_type |
static tree | mf_cache_structptr_type |
static tree | mf_cache_array_decl |
static tree | mf_cache_shift_decl |
static tree | mf_cache_mask_decl |
static tree | mf_cache_shift_decl_l |
static tree | mf_cache_mask_decl_l |
static tree | mf_check_fndecl |
static tree | mf_register_fndecl |
static tree | mf_unregister_fndecl |
static tree | mf_init_fndecl |
static tree | mf_set_options_fndecl |
static htab_t | marked_trees = NULL |
static vec< tree, va_gc > * | deferred_static_decls |
static tree | enqueued_call_stmt_chain |
void add_bb_to_loop | ( | basic_block | , |
struct loop * | |||
) |
@verbatim Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002-2013 Free Software Foundation, Inc. Contributed by Frank Ch. Eigler fche@ and Graydon Hoare redh at.co mgrayd on@r edhat .com
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/.
|
static |
------------------------------------------------------------------------
ADDR_EXPR transforms. Perform the declaration-related mudflap tree transforms on the current function. This is the first part of the mudflap instrumentation. It works on high-level GIMPLE because after lowering, all variables are moved out of their BIND_EXPR binding context, and we lose liveness information for the declarations we wish to instrument.
References current_function_decl, gimple_body(), mf_artificial(), mf_marked_p(), mf_xform_decls(), pop_gimplify_context(), and push_gimplify_context().
|
static |
------------------------------------------------------------------------
This is the second part of the mudflap instrumentation. It works on low-level GIMPLE using the CFG, because we want to run this pass after tree optimizations have been performed, but we have to preserve the CFG for expansion from trees to RTL. Below is the list of transformations performed on statements in the current function. 1) Memory reference transforms: Perform the mudflap indirection-related tree transforms on memory references. 2) Mark BUILTIN_ALLOCA calls not inlineable.
References current_function_decl, mf_artificial(), mf_decl_cache_locals(), mf_decl_clear_locals(), mf_marked_p(), mf_xform_statements(), pop_gimplify_context(), and push_gimplify_context().
|
static |
|
static |
Insert a gimple_seq SEQ on all the outgoing edges out of BB. Note that if BB has more than one edge, STMT will be replicated for each edge. Also, abnormal edges will be ignored.
References edge_def::flags, gimple_seq_copy(), gsi_insert_seq_on_edge(), and basic_block_def::succs.
Referenced by mf_decl_cache_locals().
gimple_opt_pass* make_pass_mudflap_1 | ( | ) |
gimple_opt_pass* make_pass_mudflap_2 | ( | ) |
|
inlinestatic |
Return true if DECL is artificial stub that shouldn't be instrumented by mf. We should instrument clones of non-artificial functions.
Referenced by execute_mudflap_function_decls(), execute_mudflap_function_ops(), mudflap_enqueue_decl(), and mx_register_decls().
|
static |
References add_bb_to_loop(), build_int_cst(), CDI_DOMINATORS, edge_def::count, basic_block_def::count, create_empty_bb(), create_tmp_reg(), edge_def::dest, dom_info_available_p(), find_edge(), edge_def::flags, fold_convert_loc(), force_gimple_operand(), g, gimple_bb(), gimple_build_call(), gimple_build_cond(), gimple_seq_add_seq(), gimple_seq_add_stmt(), gimple_set_location(), GSI_CONTINUE_LINKING, gsi_end_p(), gsi_insert_seq_after(), gsi_last_bb(), gsi_prev(), gsi_start_bb(), gsi_stmt(), basic_block_def::loop_father, make_edge(), make_single_succ_edge(), mf_cache_array_decl, mf_cache_mask_decl, mf_cache_mask_decl_l, mf_cache_shift_decl, mf_cache_shift_decl_l, mf_cache_struct_type, mf_cache_structptr_type, mf_check_fndecl, mf_file_function_line_tree(), mf_uintptr_type, edge_def::probability, set_immediate_dominator(), split_block(), split_block_after_labels(), edge_def::src, stmt_ends_bb_p(), and unshare_expr().
Referenced by mf_xform_derefs_1().
|
static |
Helpers.
Referenced by mf_file_function_line_tree(), mf_varname_tree(), mudflap_enqueue_constant(), and mudflap_finish_file().
|
static |
------------------------------------------------------------------------
Some generally helpful functions for mudflap instrumentation.
Build a reference to a literal string.
References build_array_type(), build_index_type(), build_pointer_type(), build_string(), len, mf_mark(), and strlen().
|
static |
Indirection-related instrumentation.
Create and initialize local shadow variables for the lookup cache globals. Put their decls in the *_l globals for use by mf_build_check_statement_for.
References create_tmp_reg(), current_function_decl, g, gimple_seq_add_stmt(), gimple_set_location(), gsi_commit_edge_inserts(), insert_edge_copies_seq(), mf_cache_mask_decl, mf_cache_mask_decl_l, mf_cache_shift_decl, mf_cache_shift_decl_l, and mf_mark().
Referenced by execute_mudflap_function_ops().
|
static |
References mf_cache_mask_decl_l, and mf_cache_shift_decl_l.
Referenced by execute_mudflap_function_ops().
|
static |
Check whether the given decl, generally a VAR_DECL or PARM_DECL, is eligible for instrumentation. For the mudflap1 pass, this implies that it should be registered with the libmudflap runtime. For the mudflap2 pass this means instrumenting an indirection operation with respect to the object.
Referenced by mf_xform_derefs_1(), and mx_register_decls().
|
static |
Referenced by mf_build_check_statement_for().
|
static |
And another friend, for producing a simpler message.
References current_function_decl, lang_hooks::decl_printable_name, expand_location(), free(), and mf_build_string().
|
inlinestatic |
Helper for mudflap_init: construct a decl with the given category, name, and type, mark it an external reference, and pushdecl it.
References lang_hooks::decls, get_identifier(), mf_mark(), and lang_hooks_for_decls::pushdecl.
Referenced by mudflap_init().
|
inlinestatic |
Helper for mudflap_init: construct a tree corresponding to the type struct __mf_cache { uintptr_t low; uintptr_t high; }; where uintptr_t is the FIELD_TYPE argument.
References get_identifier(), and layout_type().
Referenced by mudflap_init().
tree mf_mark | ( | ) |
References marked_trees.
Referenced by build_constant_desc(), build_va_arg_indirect_ref(), copy_tree_r(), mf_build_string(), mf_decl_cache_locals(), mf_make_builtin(), mudflap_init(), and mx_register_decls().
int mf_marked_p | ( | ) |
Referenced by mudflap_finish_file(), and mx_register_decls().
|
static |
Create a properly typed STRING_CST node that describes the given declaration. It will be used as an argument for __mf_register(). Try to construct a helpful string, including file/function/variable name.
References current_function_decl, lang_hooks::decl_printable_name, expand_location(), mf_build_string(), lang_hooks::name, pp_clear_output_area(), pp_formatted_text(), and pp_string().
|
static |
Addressable variables instrumentation.
Referenced by execute_mudflap_function_decls().
|
static |
Perform the object lifetime tracking mudflap transform on the given function tree. The tree is mutated in place, with possibly copied subtree nodes. For every auto variable declared, if its address is ever taken within the function, then supply its lifetime to the mudflap runtime with the __mf_register and __mf_unregister calls.
References walk_stmt_info::info, memset(), mx_xfn_xform_decls(), mf_xform_decls_data::param_decls, pointer_set_create(), pointer_set_destroy(), walk_stmt_info::pset, and walk_gimple_seq().
|
static |
References addr_expr_of_non_mem_decl_p(), build_pointer_type(), byte_position(), fold_build_pointer_plus_hwi_loc(), fold_build_pointer_plus_loc(), fold_convert_loc(), limit, mf_build_check_statement_for(), mf_decl_eligible_p(), mf_marked_p(), mf_uintptr_type, size_binop_loc(), tree_mem_ref_addr(), type(), and warning().
Referenced by mf_xform_statements().
|
static |
Transform 1) Memory references.
References get_gimple_rhs_class(), gimple_assign_lhs_ptr(), gimple_assign_rhs1_ptr(), gimple_assign_rhs2_ptr(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, gimple_location(), gimple_return_retval(), gimple_return_retval_ptr(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), basic_block_def::index, mf_xform_derefs_1(), and basic_block_def::next_bb.
Referenced by execute_mudflap_function_ops().
void mudflap_enqueue_constant | ( | ) |
References mf_build_string(), mf_marked_p(), mudflap_register_call(), and size_in_bytes().
Referenced by output_constant_def_contents().
void mudflap_enqueue_decl | ( | ) |
References deferred_static_decls, mf_artificial(), mf_marked_p(), and vec_safe_push().
Referenced by make_decl_rtl().
void mudflap_finish_file | ( | void | ) |
Emit any file-wide instrumentation.
Referenced by compile_file().
void mudflap_init | ( | void | ) |
Initialize the global tree nodes that correspond to mf-runtime.h declarations.
References build_array_type(), build_function_type_list(), build_pointer_type(), build_qualified_type(), mf_cache_array_decl, mf_cache_mask_decl, mf_cache_shift_decl, mf_cache_struct_type, mf_cache_structptr_type, mf_check_fndecl, mf_init_fndecl, mf_make_builtin(), mf_make_mf_cache_struct_type(), mf_mark(), mf_register_fndecl, mf_set_options_fndecl, mf_uintptr_type, mf_unregister_fndecl, ptr_mode, lang_hooks_for_types::type_for_mode, TYPE_QUAL_CONST, and lang_hooks::types.
|
static |
References append_to_statement_list(), build_call_expr(), build_int_cst(), build_pointer_type(), and mf_register_fndecl.
Referenced by mudflap_enqueue_constant(), and mudflap_finish_file().
|
static |
Referenced by mx_xfn_xform_decls().
gimple_seq mx_register_decls | ( | ) |
Synthesize a CALL_EXPR and a TRY_FINALLY_EXPR, for this chain of _DECLs if appropriate. Arrange to call the __mf_register function now, and the __mf_unregister function later for each. Return the gimple sequence after synthesis.
References build_pointer_type(), gimple_build_call(), gimple_build_try(), gimple_seq_add_stmt(), gimple_set_location(), GIMPLE_TRY_FINALLY, gsi_end_p(), gsi_insert_before(), GSI_SAME_STMT, is_gimple_val(), mf_artificial(), mf_decl_eligible_p(), mf_mark(), mf_marked_p(), mf_register_fndecl, mf_unregister_fndecl, mf_varname_tree(), and warning().
|
static |
Process every variable mentioned in BIND_EXPRs.
References gimple_bind_body(), gimple_bind_set_body(), gimple_bind_vars(), gimple_location(), gsi_stmt(), walk_stmt_info::info, mx_register_decls(), and mf_xform_decls_data::param_decls.
Referenced by mf_xform_decls().
Remember given node as a static of some kind: global data, function-scope static, or an anonymous constant. Its assembler label is given.
A list of globals whose incomplete declarations we encountered. Instead of emitting the __mf_register call for them here, it's delayed until program finish time. If they're still incomplete by then, warnings are emitted.
Referenced by mudflap_enqueue_decl(), and mudflap_finish_file().
|
static |
A list of statements for calling __mf_register() at startup time.
Referenced by mudflap_finish_file().
|
static |
------------------------------------------------------------------------
Externally visible mudflap functions.
Mark and return the given tree node to prevent further mudflap transforms.
Referenced by mf_mark(), and mf_marked_p().
|
static |
extern struct __mf_cache __mf_lookup_cache [];
Referenced by mf_build_check_statement_for(), and mudflap_init().
|
static |
extern uintptr_t __mf_lc_mask;
Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mudflap_init().
|
static |
auto const uintptr_t __mf_lc_mask_l;
Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mf_decl_clear_locals().
|
static |
extern unsigned char __mf_lc_shift;
Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mudflap_init().
|
static |
Their function-scope local shadows, used in single-threaded mode only.
auto const unsigned char __mf_lc_shift_l;
Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mf_decl_clear_locals().
|
static |
struct __mf_cache { uintptr_t low; uintptr_t high; };
Referenced by mf_build_check_statement_for(), and mudflap_init().
|
static |
struct __mf_cache * const
Referenced by mf_build_check_statement_for(), and mudflap_init().
|
static |
extern void __mf_check (void *ptr, size_t sz, int type, const char *);
Referenced by mf_build_check_statement_for(), and mudflap_init().
|
static |
extern void __mf_init ();
Referenced by mudflap_finish_file(), and mudflap_init().
|
static |
extern void __mf_register (void *ptr, size_t sz, int type, const char *);
Referenced by mudflap_init(), mudflap_register_call(), and mx_register_decls().
|
static |
extern int __mf_set_options (const char*);
Referenced by mudflap_finish_file(), and mudflap_init().
|
static |
global tree nodes
Global tree objects for global variables and functions exported by mudflap runtime library. mf_init_extern_trees must be called before using these.
uintptr_t (usually "unsigned long")
Referenced by mf_build_check_statement_for(), mf_xform_derefs_1(), and mudflap_init().
|
static |
extern void __mf_unregister (void *ptr, size_t sz, int type);
Referenced by mudflap_init(), and mx_register_decls().