GCC Middle and Back End API Reference
tree-mudflap.c File Reference

Data Structures

struct  mf_xform_decls_data

Functions

void add_bb_to_loop (basic_block, struct loop *)
static tree mf_build_string (const char *string)
static tree mf_varname_tree (tree)
static tree mf_file_function_line_tree (location_t)
static void mf_decl_cache_locals (void)
static void mf_decl_clear_locals (void)
static void mf_xform_statements (void)
static unsigned int execute_mudflap_function_ops (void)
static void mf_xform_decls (gimple_seq, tree)
static tree mx_xfn_xform_decls (gimple_stmt_iterator *, bool *, struct walk_stmt_info *)
static gimple_seq mx_register_decls (tree, gimple_seq, location_t)
static unsigned int execute_mudflap_function_decls (void)
static bool mf_artificial ()
static tree mf_build_string ()
static tree mf_varname_tree ()
static tree mf_file_function_line_tree ()
static tree mf_make_builtin ()
static tree mf_make_mf_cache_struct_type ()
void mudflap_init ()
static void insert_edge_copies_seq ()
static void mf_build_check_statement_for (tree base, tree limit, gimple_stmt_iterator *instr_gsi, location_t location, tree dirflag)
static int mf_decl_eligible_p ()
static void mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, location_t location, tree dirflag)
gimple_seq mx_register_decls ()
static void mf_xform_decls ()
tree mf_mark ()
int mf_marked_p ()
static void mudflap_register_call ()
void mudflap_enqueue_decl ()
void mudflap_enqueue_constant ()
void mudflap_finish_file ()
static bool gate_mudflap ()
gimple_opt_passmake_pass_mudflap_1 ()
gimple_opt_passmake_pass_mudflap_2 ()

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

Function Documentation

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@.nosp@m.redh.nosp@m.at.co.nosp@m.m and Graydon Hoare grayd.nosp@m.on@r.nosp@m.edhat.nosp@m..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 unsigned int execute_mudflap_function_decls ( )
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 unsigned int execute_mudflap_function_ops ( )
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 bool gate_mudflap ( )
static
static void insert_edge_copies_seq ( )
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 ( )
static bool mf_artificial ( )
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 tree mf_build_string ( const char *  string)
static
static tree mf_build_string ( )
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 void mf_decl_cache_locals ( void  )
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 void mf_decl_clear_locals ( void  )
static
static int mf_decl_eligible_p ( )
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 tree mf_file_function_line_tree ( location_t  )
static
static tree mf_file_function_line_tree ( )
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().

static tree mf_make_builtin ( )
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().

static tree mf_make_mf_cache_struct_type ( )
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().

static tree mf_varname_tree ( tree  )
static
static tree mf_varname_tree ( )
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 void mf_xform_decls ( gimple_seq  ,
tree   
)
static
Addressable variables instrumentation.   

Referenced by execute_mudflap_function_decls().

static void mf_xform_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().

void mudflap_enqueue_constant ( )
void mudflap_enqueue_decl ( )
void mudflap_finish_file ( void  )
Emit any file-wide instrumentation.   

Referenced by compile_file().

static gimple_seq mx_register_decls ( tree  ,
gimple_seq  ,
location_t   
)
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 tree mx_xfn_xform_decls ( gimple_stmt_iterator gsi,
bool *  handled_operands_p,
struct walk_stmt_info wi 
)
static

Variable Documentation

vec<tree, va_gc>* deferred_static_decls
static
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().

tree enqueued_call_stmt_chain
static
A list of statements for calling __mf_register() at startup time.   

Referenced by mudflap_finish_file().

htab_t marked_trees = NULL
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().

tree mf_cache_array_decl
static
extern struct __mf_cache __mf_lookup_cache [];  

Referenced by mf_build_check_statement_for(), and mudflap_init().

tree mf_cache_mask_decl
static
extern uintptr_t __mf_lc_mask;  

Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mudflap_init().

tree mf_cache_mask_decl_l
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().

tree mf_cache_shift_decl
static
extern unsigned char __mf_lc_shift;  

Referenced by mf_build_check_statement_for(), mf_decl_cache_locals(), and mudflap_init().

tree mf_cache_shift_decl_l
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().

tree mf_cache_struct_type
static
struct __mf_cache { uintptr_t low; uintptr_t high; };  

Referenced by mf_build_check_statement_for(), and mudflap_init().

tree mf_cache_structptr_type
static
struct __mf_cache * const  

Referenced by mf_build_check_statement_for(), and mudflap_init().

tree mf_check_fndecl
static
extern void __mf_check (void *ptr, size_t sz, int type, const char *);  

Referenced by mf_build_check_statement_for(), and mudflap_init().

tree mf_init_fndecl
static
extern void __mf_init ();  

Referenced by mudflap_finish_file(), and mudflap_init().

tree mf_register_fndecl
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().

tree mf_set_options_fndecl
static
extern int __mf_set_options (const char*);  

Referenced by mudflap_finish_file(), and mudflap_init().

tree mf_uintptr_type
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().

tree mf_unregister_fndecl
static
extern void __mf_unregister (void *ptr, size_t sz, int type);  

Referenced by mudflap_init(), and mx_register_decls().