GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "memmodel.h"
#include "gimple.h"
#include "tree-pass.h"
#include "ssa.h"
#include "cgraph.h"
#include "fold-const.h"
#include "gimplify.h"
#include "gimple-iterator.h"
#include "gimplify-me.h"
#include "tree-cfg.h"
#include "tree-iterator.h"
#include "gimple-fold.h"
#include "tree-ssa-loop-ivopts.h"
#include "tree-eh.h"
#include "tsan.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "builtins.h"
#include "target.h"
#include "diagnostic-core.h"
Data Structures | |
struct | tsan_map_atomic |
Macros | |
#define | TRANSFORM(fcode, tsan_fcode, action, code) |
#define | CHECK_LAST(fcode, tsan_fcode) |
#define | ADD_SEQ_CST(fcode, tsan_fcode) |
#define | ADD_ACQUIRE(fcode, tsan_fcode) |
#define | WEAK_CAS(fcode, tsan_fcode) |
#define | STRONG_CAS(fcode, tsan_fcode) |
#define | BOOL_CAS(fcode, tsan_fcode) |
#define | VAL_CAS(fcode, tsan_fcode) |
#define | LOCK_RELEASE(fcode, tsan_fcode) |
#define | FETCH_OP(fcode, tsan_fcode, code) |
#define | FETCH_OPS(fcode, tsan_fcode, code) |
#define | BOOL_CLEAR(fcode, tsan_fcode) |
#define | BOOL_TEST_AND_SET(fcode, tsan_fcode) |
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 , bool_clear , bool_test_and_set } |
Functions | |
static tree | get_memory_access_decl (bool is_write, unsigned size, bool volatilep) |
static tree | is_vptr_store (gimple *stmt, tree expr, bool is_write) |
static bool | instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) |
static void | instrument_builtin_call (gimple_stmt_iterator *gsi) |
static bool | instrument_gimple (gimple_stmt_iterator *gsi) |
static void | replace_func_exit (gimple *stmt) |
static void | instrument_func_exit (void) |
static bool | instrument_memory_accesses (bool *cfg_changed) |
static void | instrument_func_entry (void) |
static unsigned | tsan_pass (void) |
void | tsan_finish_file (void) |
gimple_opt_pass * | make_pass_tsan (gcc::context *ctxt) |
gimple_opt_pass * | make_pass_tsan_O0 (gcc::context *ctxt) |
Variables | |
static const struct tsan_map_atomic | tsan_atomic_table [] |
#define ADD_ACQUIRE | ( | fcode, | |
tsan_fcode ) |
#define ADD_SEQ_CST | ( | fcode, | |
tsan_fcode ) |
#define BOOL_CAS | ( | fcode, | |
tsan_fcode ) |
#define BOOL_CLEAR | ( | fcode, | |
tsan_fcode ) |
#define BOOL_TEST_AND_SET | ( | fcode, | |
tsan_fcode ) |
#define CHECK_LAST | ( | fcode, | |
tsan_fcode ) |
#define FETCH_OP | ( | fcode, | |
tsan_fcode, | |||
code ) |
#define FETCH_OPS | ( | fcode, | |
tsan_fcode, | |||
code ) |
#define LOCK_RELEASE | ( | fcode, | |
tsan_fcode ) |
#define STRONG_CAS | ( | fcode, | |
tsan_fcode ) |
#define TRANSFORM | ( | fcode, | |
tsan_fcode, | |||
action, | |||
code ) |
#define VAL_CAS | ( | fcode, | |
tsan_fcode ) |
#define WEAK_CAS | ( | fcode, | |
tsan_fcode ) |
enum tsan_atomic_action |
GCC instrumentation plugin for ThreadSanitizer. Copyright (C) 2011-2024 Free Software Foundation, Inc. Contributed by Dmitry Vyukov <dvyukov@google.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);
References builtin_decl_implicit().
Referenced by instrument_expr().
|
static |
Instrument an atomic builtin.
References add_acquire, add_seq_cst, bool_cas, bool_clear, bool_test_and_set, BOOL_TYPE_SIZE, boolean_type_node, build_fold_addr_expr, build_int_cst(), build_zero_cst(), builtin_decl_implicit(), check_last, create_tmp_var, DECL_FUNCTION_CODE(), fetch_op, fetch_op_seq_cst, g, gcc_assert, gimple_assign_lhs(), gimple_build_assign(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_num_args(), gimple_call_set_fndecl(), gimple_call_set_lhs(), gimple_location(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_stmt(), i, integer_nonzerop(), lock_release, make_ssa_name(), mark_addressable(), maybe_clean_eh_stmt(), maybe_clean_or_replace_eh_stmt(), MEMMODEL_ACQUIRE, memmodel_base(), MEMMODEL_LAST, MEMMODEL_RELEASE, MEMMODEL_SEQ_CST, NULL_TREE, strong_cas, targetm, TREE_CHAIN, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, TREE_VALUE, tsan_atomic_table, TYPE_ARG_TYPES, update_gimple_call(), update_stmt(), useless_type_conversion_p(), val_cas, warning_at(), and weak_cas.
Referenced by instrument_gimple().
|
static |
Instruments EXPR if needed. If any instrumentation is inserted, return true.
References ADDR_SPACE_GENERIC_P, build2(), build_fold_addr_expr, build_int_cst(), builtin_decl_implicit(), char_type_node, DECL_BIT_FIELD_REPRESENTATIVE, DECL_BIT_FIELD_TYPE, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_HARD_REGISTER, DECL_P, DECL_SIZE, pt_solution::escaped, find_fallthru_edge(), force_gimple_operand(), g, get_inner_reference(), get_memory_access_decl(), get_object_alignment(), gimple_build_call(), gimple_location(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gsi_bb(), gsi_insert_seq_after(), gsi_insert_seq_before(), gsi_insert_seq_on_edge_immediate(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_stmt(), int_size_in_bytes(), pt_solution::ipa_escaped, is_ctrl_altering_stmt(), is_gimple_call(), is_global_var(), is_vptr_store(), least_bit_hwi(), may_be_aliased(), may_be_nonaddressable_p(), MIN, NULL, NULL_TREE, offset, pt_solution_includes(), size_int, basic_block_def::succs, TREE_CODE, tree_fits_uhwi_p(), TREE_OPERAND, TREE_READONLY, TREE_THIS_VOLATILE, tree_to_uhwi(), TREE_TYPE, TYPE_ADDR_SPACE, unshare_expr(), and VAR_P.
Referenced by instrument_gimple().
|
static |
Instruments function entry.
References builtin_decl_implicit(), cfun, ENTRY_BLOCK_PTR_FOR_FN, g, gimple_build_call(), gimple_call_set_lhs(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gsi_insert_seq_on_edge_immediate(), integer_zero_node, make_ssa_name(), NULL, ptr_type_node, and single_succ_edge().
Referenced by tsan_pass().
|
static |
Instrument function exit. Used when TSAN_FUNC_EXIT does not exist.
References builtin_decl_implicit(), cfun, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, g, gcc_assert, gimple_build_call(), gimple_call_builtin_p(), gimple_location(), gimple_set_location(), gsi_insert_before(), gsi_last_bb(), GSI_SAME_STMT, gsi_stmt(), and basic_block_def::preds.
Referenced by instrument_memory_accesses().
|
static |
Instruments the gimple pointed to by GSI. Return true if func entry/exit should be instrumented.
References as_a(), BUILT_IN_NORMAL, builtin_decl_implicit(), gimple_assign_lhs(), gimple_assign_load_p(), gimple_assign_rhs1(), gimple_call_builtin_p(), gimple_call_fndecl(), gimple_call_set_tail(), gimple_clobber_p(), gimple_store_p(), gsi_stmt(), instrument_builtin_call(), instrument_expr(), is_gimple_assign(), and is_gimple_call().
Referenced by instrument_memory_accesses().
Instruments all interesting memory accesses in the current function. Return true if func entry/exit should be instrumented.
References cfg_changed, cfun, FOR_EACH_BB_FN, FOR_EACH_VEC_ELT, gimple_call_internal_p(), gimple_purge_dead_eh_edges(), gsi_end_p(), gsi_for_stmt(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_stmt(), i, instrument_func_exit(), instrument_gimple(), and replace_func_exit().
Referenced by tsan_pass().
Check as to whether EXPR refers to a store to vptr.
References DECL_VIRTUAL_P, gimple_assign_rhs1(), gimple_assign_single_p(), NULL, TREE_CODE, and TREE_OPERAND.
Referenced by instrument_expr().
gimple_opt_pass * make_pass_tsan | ( | gcc::context * | ctxt | ) |
gimple_opt_pass * make_pass_tsan_O0 | ( | gcc::context * | ctxt | ) |
|
static |
Replace TSAN_FUNC_EXIT internal call with function exit tsan builtin.
References builtin_decl_implicit(), cfun, g, gimple_build_call(), gimple_set_location(), gsi_for_stmt(), and gsi_replace().
Referenced by instrument_memory_accesses().
void tsan_finish_file | ( | void | ) |
Inserts __tsan_init () into the list of CTORs.
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.
Referenced by compile_file().
|
static |
ThreadSanitizer instrumentation pass.
References cfg_changed, initialize_sanitizer_builtins(), instrument_func_entry(), instrument_memory_accesses(), and TODO_cleanup_cfg.
|
static |
Referenced by instrument_builtin_call().