GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
#include "intl.h"
#include "tm.h"
#include "basic-block.h"
#include "gimple.h"
#include "function.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
#include "tree-pass.h"
#include "tree-iterator.h"
#include "langhooks.h"
#include "output.h"
#include "options.h"
#include "target.h"
#include "diagnostic.h"
#include "tree-ssa-propagate.h"
#include "tsan.h"
#include "asan.h"
Data Structures | |
struct | tsan_map_atomic |
Macros | |
#define | TRANSFORM(fcode, tsan_fcode, action, code) { BUILT_IN_##fcode, BUILT_IN_##tsan_fcode, action, code } |
#define | CHECK_LAST(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, check_last, ERROR_MARK) |
#define | ADD_SEQ_CST(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, add_seq_cst, ERROR_MARK) |
#define | ADD_ACQUIRE(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, add_acquire, ERROR_MARK) |
#define | WEAK_CAS(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, weak_cas, ERROR_MARK) |
#define | STRONG_CAS(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, strong_cas, ERROR_MARK) |
#define | BOOL_CAS(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, bool_cas, ERROR_MARK) |
#define | VAL_CAS(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, val_cas, ERROR_MARK) |
#define | LOCK_RELEASE(fcode, tsan_fcode) TRANSFORM (fcode, tsan_fcode, lock_release, ERROR_MARK) |
#define | FETCH_OP(fcode, tsan_fcode, code) TRANSFORM (fcode, tsan_fcode, fetch_op, code) |
#define | FETCH_OPS(fcode, tsan_fcode, code) TRANSFORM (fcode, tsan_fcode, fetch_op_seq_cst, code) |
Enumerations | |
enum | tsan_atomic_action { check_last, add_seq_cst, add_acquire, weak_cas, strong_cas, bool_cas, val_cas, lock_release, fetch_op, fetch_op_seq_cst } |
Functions | |
static tree | get_memory_access_decl () |
static tree | is_vptr_store () |
static bool | instrument_expr () |
static void | instrument_builtin_call () |
static bool | instrument_gimple () |
static bool | instrument_memory_accesses () |
static void | instrument_func_entry () |
static void | instrument_func_exit () |
static unsigned | tsan_pass () |
static bool | tsan_gate () |
void | tsan_finish_file () |
gimple_opt_pass * | make_pass_tsan () |
static bool | tsan_gate_O0 () |
gimple_opt_pass * | make_pass_tsan_O0 () |
Variables | |
static struct tsan_map_atomic | tsan_atomic_table [] |
#define ADD_ACQUIRE | ( | fcode, | |
tsan_fcode | |||
) | TRANSFORM (fcode, tsan_fcode, add_acquire, ERROR_MARK) |
#define ADD_SEQ_CST | ( | fcode, | |
tsan_fcode | |||
) | TRANSFORM (fcode, tsan_fcode, add_seq_cst, ERROR_MARK) |
#define CHECK_LAST | ( | fcode, | |
tsan_fcode | |||
) | TRANSFORM (fcode, tsan_fcode, check_last, ERROR_MARK) |
#define FETCH_OPS | ( | fcode, | |
tsan_fcode, | |||
code | |||
) | TRANSFORM (fcode, tsan_fcode, fetch_op_seq_cst, code) |
#define LOCK_RELEASE | ( | fcode, | |
tsan_fcode | |||
) | TRANSFORM (fcode, tsan_fcode, lock_release, ERROR_MARK) |
#define STRONG_CAS | ( | fcode, | |
tsan_fcode | |||
) | TRANSFORM (fcode, tsan_fcode, strong_cas, ERROR_MARK) |
#define TRANSFORM | ( | fcode, | |
tsan_fcode, | |||
action, | |||
code | |||
) | { BUILT_IN_##fcode, BUILT_IN_##tsan_fcode, action, code } |
enum tsan_atomic_action |
|
static |
GCC instrumentation plugin for ThreadSanitizer. Copyright (C) 2011-2013 Free Software Foundation, Inc. Contributed by Dmitry Vyukov dvyuk ov@g oogle .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/. Number of instrumented memory accesses in the current function. Builds the following decl void __tsan_read/writeX (void *addr);
|
static |
Instrument an atomic builtin.
BIT_NOT_EXPR stands for NAND.
FALLTHRU
References add_acquire, add_seq_cst, bool_cas, boolean_type_node, build2, build_fold_addr_expr, build_int_cst(), builtin_decl_implicit(), check_last, create_tmp_var, fetch_op, fetch_op_seq_cst, gcc_assert, gimple_assign_lhs(), gimple_build_assign, gimple_build_assign_with_ops(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_fndecl(), gimple_call_set_lhs(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_stmt(), host_integerp(), HOST_WIDE_INT, integer_nonzerop(), lock_release, make_ssa_name(), mark_addressable(), MEMMODEL_ACQUIRE, MEMMODEL_RELEASE, MEMMODEL_SEQ_CST, NULL, NULL_TREE, strong_cas, TREE_CHAIN, tree_low_cst(), TREE_TYPE, TREE_VALUE, tsan_atomic_table, TYPE_ARG_TYPES, update_gimple_call(), update_stmt(), useless_type_conversion_p(), val_cas, and weak_cas.
|
static |
Instruments EXPR if needed. If any instrumentation is inserted, return true.
For now just avoid instrumenting bit field acceses. TODO: handle bit-fields as if touching the whole field.
No need to instrument accesses to decls that don't escape, they can't escape to other threads then.
Instrumentation for assignment of a function result must be inserted after the call. Instrumentation for reads of function arguments must be inserted before the call. That's because the call can contain synchronization.
If the call can throw, it must be the last stmt in a basic block, so the instrumented stmts need to be inserted in successor bbs.
Referenced by instrument_gimple().
|
static |
Instruments function entry.
|
static |
Instruments function exits.
Find all function exits.
|
static |
Instruments the gimple pointed to by GSI. Return true if func entry/exit should be instrumented.
References gimple_assign_lhs(), gimple_assign_load_p(), gimple_assign_rhs1(), gimple_store_p(), and instrument_expr().
|
static |
Instruments all interesting memory accesses in the current function. Return true if func entry/exit should be instrumented.
References builtin_decl_implicit(), cfun, ENTRY_BLOCK_PTR, g, gimple_build_call(), gimple_call_set_lhs(), gimple_set_location(), gsi_after_labels(), gsi_insert_before(), GSI_SAME_STMT, integer_zero_node, make_ssa_name(), NULL, ptr_type_node, and single_succ().
|
static |
Check as to whether EXPR refers to a store to vptr.
References DECL_VIRTUAL_P, gimple_assign_rhs1(), TREE_CODE, and TREE_OPERAND.
gimple_opt_pass* make_pass_tsan | ( | ) |
gimple_opt_pass* make_pass_tsan_O0 | ( | ) |
void tsan_finish_file | ( | void | ) |
Inserts __tsan_init () into the list of CTORs.
Referenced by emit_debug_global_declarations().
|
static |
The pass's gate.
References GIMPLE_PASS, and OPTGROUP_NONE.
|
static |
|
static |
ThreadSanitizer instrumentation pass.
References append_to_statement_list(), build_call_expr(), builtin_decl_implicit(), cgraph_build_static_cdtor(), initialize_sanitizer_builtins(), MAX_RESERVED_INIT_PRIORITY, and NULL_TREE.
|
static |
Referenced by instrument_builtin_call().