GCC Middle and Back End API Reference
|
Data Structures | |
struct | object_size_info |
Variables | |
static const unsigned HOST_WIDE_INT | unknown [4] = { -1, -1, 0, 0 } |
static unsigned HOST_WIDE_INT * | object_sizes [4] |
static bitmap | computed [4] |
static unsigned HOST_WIDE_INT | offset_limit |
|
static |
Compute __builtin_object_size for PTR, which is a ADDR_EXPR. OBJECT_SIZE_TYPE is the second argument from __builtin_object_size. If unknown, return unknown[object_size_type].
References bitmap_bit_p(), collect_object_sizes_for(), compute_builtin_object_size(), compute_object_offset(), double_int::fits_uhwi(), double_int::from_uhwi(), handled_component_p(), host_integerp(), HOST_WIDE_INT, double_int::is_negative(), mem_ref_offset(), object_sizes, offset_limit, object_size_info::pass, double_int::to_uhwi(), tree_int_cst_lt(), tree_low_cst(), and unknown.
Referenced by compute_builtin_object_size(), expr_object_size(), and plus_stmt_object_size().
|
static |
Referenced by call_object_size().
|
static |
Compute __builtin_object_size for CALL, which is a GIMPLE_CALL. Handles various allocation calls. OBJECT_SIZE_TYPE is the second argument from __builtin_object_size. If unknown, return unknown[object_size_type].
References BUILT_IN_NORMAL, gimple_call_arg(), gimple_call_fndecl(), gimple_call_num_args(), host_integerp(), is_gimple_call(), lookup_attribute(), tree_low_cst(), and unknown.
|
static |
Compute object_sizes for PTR, defined to the result of a call.
References alloc_object_size(), HOST_WIDE_INT, is_gimple_call(), object_size_info::object_size_type, object_sizes, object_size_info::pass, and unknown.
Referenced by collect_object_sizes_for().
|
static |
Referenced by compute_builtin_object_size().
|
static |
Check if some pointer we are computing object size of is being increased within a loop. If yes, assume all the SSA variables participating in that loop have minimum object sizes 0.
References check_for_plus_in_loops_1(), object_size_info::depths, gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), integer_zerop(), is_gimple_assign(), and object_size_info::tos.
|
static |
Helper function for check_for_plus_in_loops. Called recursively to detect loops.
References bitmap_bit_p(), bitmap_clear_bit(), bitmap_set_bit(), phi_arg_d::def, object_size_info::depths, gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_single_p(), gimple_assign_unary_nop_p(), gimple_phi_arg(), gimple_phi_num_args(), integer_zerop(), object_size_info::object_size_type, object_sizes, pass_through_call(), object_size_info::reexamine, object_size_info::stack, and object_size_info::tos.
Referenced by check_for_plus_in_loops().
|
static |
Referenced by addr_object_size(), compute_builtin_object_size(), and merge_object_sizes().
|
static |
Compute object sizes for VAR. For ADDR_EXPR an object size is the number of remaining bytes to the end of the object (where what is considered an object depends on OSI->object_size_type). For allocation GIMPLE_CALL like malloc or calloc object size is the size of the allocation. For POINTER_PLUS_EXPR where second operand is a constant integer, object size is object size of the first operand minus the constant. If the constant is bigger than the number of remaining bytes until the end of the object, object size is 0, but if it is instead a pointer subtraction, object size is unknown[object_size_type]. To differentiate addition from subtraction, ADDR_EXPR returns unknown[object_size_type] for all objects bigger than half of the address space, and constants less than half of the address space are considered addition, while bigger constants subtraction. For a memcpy like GIMPLE_CALL that always returns one of its arguments, the object size is object size of that argument. Otherwise, object size is the maximum of object sizes of variables that it might be set to.
References bitmap_bit_p(), bitmap_clear_bit(), bitmap_set_bit(), call_object_size(), cond_expr_object_size(), phi_arg_d::def, dump_file, dump_flags, expr_object_size(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_assign_single_p(), gimple_assign_unary_nop_p(), gimple_phi_arg(), gimple_phi_num_args(), merge_object_sizes(), object_size_info::object_size_type, object_sizes, object_size_info::pass, pass_through_call(), plus_stmt_object_size(), print_generic_expr(), object_size_info::reexamine, unknown, unknown_object_size(), and object_size_info::visited.
unsigned HOST_WIDE_INT compute_builtin_object_size | ( | ) |
Compute __builtin_object_size value for PTR. OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
References addr_object_size(), bitmap_bit_p(), bitmap_copy(), bitmap_empty_p(), bitmap_set_bit(), object_size_info::changed, check_for_plus_in_loops(), collect_object_sizes_for(), object_size_info::depths, dump_file, dump_flags, free(), HOST_WIDE_INT_PRINT_UNSIGNED, init_offset_limit(), object_size_info::object_size_type, object_sizes, offset_limit, object_size_info::pass, print_generic_expr(), object_size_info::reexamine, object_size_info::stack, object_size_info::tos, unknown, and object_size_info::visited.
Referenced by addr_object_size(), and fold_builtin_object_size().
|
static |
Referenced by addr_object_size(), and compute_object_offset().
|
static |
Compute offset of EXPR within VAR. Return error_mark_node if unknown.
References compute_object_offset(), double_int_to_tree(), mem_ref_offset(), tree_int_cst_sgn(), and tree_low_cst().
|
static |
Simple pass to optimize all __builtin_object_size () builtins.
References build_zero_cst(), BUILT_IN_NORMAL, dump_file, dump_flags, fini_object_sizes(), fold_call_stmt(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_num_args(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), host_integerp(), HOST_WIDE_INT, init_object_sizes(), object_size_info::object_size_type, print_gimple_stmt(), tree_low_cst(), and update_call_from_tree().
|
static |
Referenced by collect_object_sizes_for().
|
static |
Compute object_sizes for VAR, defined at STMT, which is a COND_EXPR. Return true if the object size might need reexamination later.
References expr_object_size(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), merge_object_sizes(), object_size_info::object_size_type, object_sizes, object_size_info::reexamine, and unknown.
|
static |
Referenced by collect_object_sizes_for(), and cond_expr_object_size().
|
static |
Compute object_sizes for PTR, defined to VALUE, which is not an SSA_NAME.
References addr_object_size(), HOST_WIDE_INT, object_size_info::object_size_type, object_sizes, object_size_info::pass, and unknown.
void fini_object_sizes | ( | void | ) |
Destroy data structures after the object size computation.
References free(), object_size_info::object_size_type, and object_sizes.
Referenced by compute_object_sizes().
void init_object_sizes | ( | void | ) |
Initialize data structures for the object size computation.
References HOST_WIDE_INT, init_offset_limit(), object_size_info::object_size_type, and object_sizes.
Referenced by compute_object_sizes().
|
static |
Initialize OFFSET_LIMIT variable.
References host_integerp(), offset_limit, and tree_low_cst().
Referenced by compute_builtin_object_size(), and init_object_sizes().
gimple_opt_pass* make_pass_object_sizes | ( | ) |
|
static |
Merge object sizes of ORIG + OFFSET into DEST. Return true if the object size might need reexamination later.
References bitmap_bit_p(), object_size_info::changed, collect_object_sizes_for(), HOST_WIDE_INT, object_size_info::object_size_type, object_sizes, offset, offset_limit, object_size_info::pass, object_size_info::reexamine, and unknown.
Referenced by collect_object_sizes_for(), cond_expr_object_size(), and plus_stmt_object_size().
|
static |
Referenced by check_for_plus_in_loops_1(), and collect_object_sizes_for().
|
static |
If object size is propagated from one of function's arguments directly to its return value, return that argument for GIMPLE_CALL statement CALL. Otherwise return NULL.
References BUILT_IN_NORMAL, gimple_call_arg(), gimple_call_fndecl(), and gimple_call_num_args().
|
static |
Referenced by collect_object_sizes_for().
|
static |
Compute object_sizes for VAR, defined to the result of an assignment with operator POINTER_PLUS_EXPR. Return true if the object size might need reexamination later.
References addr_object_size(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), host_integerp(), HOST_WIDE_INT, merge_object_sizes(), object_size_info::object_size_type, object_sizes, offset_limit, tree_low_cst(), and unknown.
|
static |
Compute object_sizes for PTR, defined to an unknown value.
References HOST_WIDE_INT, object_size_info::object_size_type, object_sizes, object_size_info::pass, and unknown.
Referenced by collect_object_sizes_for().
|
static |
Bitmaps what object sizes have been computed already.
|
static |
object_sizes[0] is upper bound for number of bytes till the end of the object. object_sizes[1] is upper bound for number of bytes till the end of the subobject (innermost array or field with address taken). object_sizes[2] is lower bound for number of bytes till the end of the object and object_sizes[3] lower bound for subobject.
Referenced by addr_object_size(), call_object_size(), check_for_plus_in_loops_1(), collect_object_sizes_for(), compute_builtin_object_size(), cond_expr_object_size(), expr_object_size(), fini_object_sizes(), init_object_sizes(), merge_object_sizes(), plus_stmt_object_size(), and unknown_object_size().
|
static |
Maximum value of offset we consider to be addition.
Referenced by addr_object_size(), compute_builtin_object_size(), init_offset_limit(), merge_object_sizes(), and plus_stmt_object_size().
|
static |
Referenced by addr_object_size(), alloc_object_size(), call_object_size(), collect_object_sizes_for(), compute_builtin_object_size(), cond_expr_object_size(), expr_object_size(), go_define(), max_fn(), merge_object_sizes(), min_fn(), plus_stmt_object_size(), unknown_object_size(), and write_length_unit_log().