diff options
Diffstat (limited to 'gcc')
483 files changed, 886 insertions, 21580 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e85b7423576..7e7efe5f3f3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,295 @@ +2018-06-08 Martin Liska <mliska@suse.cz> + + * Makefile.in: Remove support for MPX (macros, related functions, + fields in cgraph_node, ...). + * builtin-types.def (BT_BND): Likewise. + (BT_FN_BND_CONST_PTR): Likewise. + (BT_FN_CONST_PTR_BND): Likewise. + (BT_FN_VOID_PTR_BND): Likewise. + (BT_FN_BND_CONST_PTR_SIZE): Likewise. + (BT_FN_VOID_CONST_PTR_BND_CONST_PTR): Likewise. + * builtins.c (expand_builtin_memcpy_with_bounds): Likewise. + (expand_builtin_mempcpy_with_bounds): Likewise. + (expand_builtin_memset_with_bounds): Likewise. + (expand_builtin_memset_args): Likewise. + (std_expand_builtin_va_start): Likewise. + (expand_builtin): Likewise. + (expand_builtin_with_bounds): Likewise. + * builtins.def (DEF_BUILTIN_CHKP): Likewise. + (DEF_LIB_BUILTIN_CHKP): Likewise. + (DEF_EXT_LIB_BUILTIN_CHKP): Likewise. + (DEF_CHKP_BUILTIN): Likewise. + (BUILT_IN_MEMCPY): Likewise. + (BUILT_IN_MEMMOVE): Likewise. + (BUILT_IN_MEMPCPY): Likewise. + (BUILT_IN_MEMSET): Likewise. + (BUILT_IN_STPCPY): Likewise. + (BUILT_IN_STRCAT): Likewise. + (BUILT_IN_STRCHR): Likewise. + (BUILT_IN_STRCPY): Likewise. + (BUILT_IN_STRLEN): Likewise. + (BUILT_IN_MEMCPY_CHK): Likewise. + (BUILT_IN_MEMMOVE_CHK): Likewise. + (BUILT_IN_MEMPCPY_CHK): Likewise. + (BUILT_IN_MEMSET_CHK): Likewise. + (BUILT_IN_STPCPY_CHK): Likewise. + (BUILT_IN_STRCAT_CHK): Likewise. + (BUILT_IN_STRCPY_CHK): Likewise. + * calls.c (store_bounds): Likewise. + (emit_call_1): Likewise. + (special_function_p): Likewise. + (maybe_warn_nonstring_arg): Likewise. + (initialize_argument_information): Likewise. + (finalize_must_preallocate): Likewise. + (compute_argument_addresses): Likewise. + (expand_call): Likewise. + * cfgexpand.c (expand_call_stmt): Likewise. + (expand_return): Likewise. + (expand_gimple_stmt_1): Likewise. + (pass_expand::execute): Likewise. + * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Likewise. + (cgraph_node::remove): Likewise. + (cgraph_node::dump): Likewise. + (cgraph_node::verify_node): Likewise. + * cgraph.h (chkp_function_instrumented_p): Likewise. + (symtab_node::get_alias_target): Likewise. + (cgraph_node::can_remove_if_no_direct_calls_and_refs_p): Likewise. + (cgraph_local_p): Likewise. + * cgraphbuild.c (cgraph_edge::rebuild_edges): Likewise. + (cgraph_edge::rebuild_references): Likewise. + * cgraphunit.c (varpool_node::finalize_decl): Likewise. + (walk_polymorphic_call_targets): Likewise. + (cgraph_node::expand_thunk): Likewise. + (symbol_table::output_weakrefs): Likewise. + * common/config/i386/i386-common.c (OPTION_MASK_ISA2_GENERAL_REGS_ONLY_UNSET): Likewise. + (ix86_handle_option): Likewise. + * config/i386/constraints.md: Likewise. + * config/i386/i386-builtin-types.def (BND): Likewise. + (VOID): Likewise. + (PVOID): Likewise. + (ULONG): Likewise. + * config/i386/i386-builtin.def (BDESC_END): Likewise. + (BDESC_FIRST): Likewise. + (BDESC): Likewise. + * config/i386/i386-c.c (ix86_target_macros_internal): Likewise. + * config/i386/i386-protos.h (ix86_bnd_prefixed_insn_p): Likewise. + * config/i386/i386.c (enum reg_class): Likewise. + (ix86_target_string): Likewise. + (ix86_option_override_internal): Likewise. + (ix86_conditional_register_usage): Likewise. + (ix86_valid_target_attribute_inner_p): Likewise. + (ix86_set_indirect_branch_type): Likewise. + (ix86_set_current_function): Likewise. + (ix86_function_arg_regno_p): Likewise. + (init_cumulative_args): Likewise. + (ix86_function_arg_advance): Likewise. + (ix86_function_arg): Likewise. + (ix86_pass_by_reference): Likewise. + (ix86_function_value_regno_p): Likewise. + (ix86_function_value_1): Likewise. + (ix86_function_value_bounds): Likewise. + (ix86_return_in_memory): Likewise. + (ix86_setup_incoming_vararg_bounds): Likewise. + (ix86_va_start): Likewise. + (indirect_thunk_need_prefix): Likewise. + (print_reg): Likewise. + (ix86_print_operand): Likewise. + (ix86_expand_call): Likewise. + (ix86_output_function_return): Likewise. + (reg_encoded_number): Likewise. + (BDESC_VERIFYS): Likewise. + (ix86_init_mpx_builtins): Likewise. + (ix86_init_builtins): Likewise. + (ix86_emit_cmove): Likewise. + (ix86_emit_move_max): Likewise. + (ix86_expand_builtin): Likewise. + (ix86_builtin_mpx_function): Likewise. + (ix86_get_arg_address_for_bt): Likewise. + (ix86_load_bounds): Likewise. + (ix86_store_bounds): Likewise. + (ix86_load_returned_bounds): Likewise. + (ix86_store_returned_bounds): Likewise. + (ix86_class_likely_spilled_p): Likewise. + (ix86_hard_regno_mode_ok): Likewise. + (x86_order_regs_for_local_alloc): Likewise. + (ix86_mitigate_rop): Likewise. + (ix86_bnd_prefixed_insn_p): Likewise. + (ix86_mpx_bound_mode): Likewise. + (ix86_make_bounds_constant): Likewise. + (ix86_initialize_bounds): Likewise. + (TARGET_LOAD_BOUNDS_FOR_ARG): Likewise. + (TARGET_STORE_BOUNDS_FOR_ARG): Likewise. + (TARGET_LOAD_RETURNED_BOUNDS): Likewise. + (TARGET_STORE_RETURNED_BOUNDS): Likewise. + (TARGET_CHKP_BOUND_MODE): Likewise. + (TARGET_BUILTIN_CHKP_FUNCTION): Likewise. + (TARGET_CHKP_FUNCTION_VALUE_BOUNDS): Likewise. + (TARGET_CHKP_MAKE_BOUNDS_CONSTANT): Likewise. + (TARGET_CHKP_INITIALIZE_BOUNDS): Likewise. + * config/i386/i386.h (TARGET_MPX): Likewise. + (TARGET_MPX_P): Likewise. + (VALID_BND_REG_MODE): Likewise. + (FIRST_BND_REG): Likewise. + (LAST_BND_REG): Likewise. + (enum reg_class): Likewise. + (BND_REG_P): Likewise. + (BND_REGNO_P): Likewise. + (BNDmode): Likewise. + (ADJUST_INSN_LENGTH): Likewise. + * config/i386/i386.md: Likewise. + * config/i386/i386.opt: Likewise. + * config/i386/linux-common.h (LIBMPX_LIBS): Likewise. + (defined): Likewise. + (LINK_MPX): Likewise. + (MPX_SPEC): Likewise. + (LIBMPX_SPEC): Likewise. + (LIBMPXWRAPPERS_SPEC): Likewise. + (CHKP_SPEC): Likewise. + * config/i386/predicates.md: Likewise. + * dbxout.c (dbxout_type): Likewise. + * doc/extend.texi: Likewise. + * doc/invoke.texi: Likewise. + * doc/md.texi: Likewise. + * doc/tm.texi: Likewise. + * doc/tm.texi.in: Likewise. + * dwarf2out.c (is_base_type): Likewise. + (gen_formal_types_die): Likewise. + (gen_subprogram_die): Likewise. + (gen_type_die_with_usage): Likewise. + (gen_decl_die): Likewise. + (dwarf2out_late_global_decl): Likewise. + * expr.c (expand_assignment): Likewise. + (emit_storent_insn): Likewise. + (store_expr_with_bounds): Likewise. + (store_expr): Likewise. + (expand_expr_real_1): Likewise. + * expr.h (store_expr_with_bounds): Likewise. + * function.c (use_register_for_decl): Likewise. + (struct bounds_parm_data): Likewise. + (assign_parms_augmented_arg_list): Likewise. + (assign_parm_find_entry_rtl): Likewise. + (assign_parm_is_stack_parm): Likewise. + (assign_parm_load_bounds): Likewise. + (assign_bounds): Likewise. + (assign_parms): Likewise. + (expand_function_start): Likewise. + * gcc.c (CHKP_SPEC): Likewise. + * gimple-fold.c (gimple_fold_builtin_memory_op): Likewise. + * gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Likewise. + (wrestrict_dom_walker::check_call): Likewise. + * gimple.c (gimple_build_call_from_tree): Likewise. + * gimple.h (enum gf_mask): Likewise. + (gimple_call_with_bounds_p): Likewise. + (gimple_call_set_with_bounds): Likewise. + * gimplify.c (gimplify_init_constructor): Likewise. + * ipa-cp.c (initialize_node_lattices): Likewise. + (propagate_constants_across_call): Likewise. + (find_more_scalar_values_for_callers_subset): Likewise. + * ipa-hsa.c (process_hsa_functions): Likewise. + * ipa-icf-gimple.c (func_checker::compare_gimple_call): Likewise. + * ipa-icf.c (sem_function::merge): Likewise. + * ipa-inline.c (early_inliner): Likewise. + * ipa-pure-const.c (warn_function_noreturn): Likewise. + (warn_function_cold): Likewise. + (propagate_pure_const): Likewise. + * ipa-ref.h (enum GTY): Likewise. + * ipa-split.c (find_retbnd): Likewise. + (consider_split): Likewise. + (split_function): Likewise. + * ipa-visibility.c (cgraph_externally_visible_p): Likewise. + * ipa.c (walk_polymorphic_call_targets): Likewise. + (symbol_table::remove_unreachable_nodes): Likewise. + (process_references): Likewise. + (cgraph_build_static_cdtor_1): Likewise. + * lto-cgraph.c (lto_output_node): Likewise. + (output_refs): Likewise. + (compute_ltrans_boundary): Likewise. + (input_overwrite_node): Likewise. + (input_node): Likewise. + (input_cgraph_1): Likewise. + * params.def (PARAM_CHKP_MAX_CTOR_SIZE): Likewise. + * passes.c (pass_manager::execute_early_local_passes): Likewise. + (class pass_chkp_instrumentation_passes): Likewise. + (make_pass_chkp_instrumentation_passes): Likewise. + * passes.def: Likewise. + * rtl.h (struct GTY): Likewise. + (CALL_EXPR_WITH_BOUNDS_P): Likewise. + * stor-layout.c (layout_type): Likewise. + * symtab.c: Likewise. + * target.def: Likewise. + * targhooks.c (default_chkp_bound_type): Likewise. + (default_chkp_bound_mode): Likewise. + (default_builtin_chkp_function): Likewise. + (default_chkp_function_value_bounds): Likewise. + (default_chkp_make_bounds_constant): Likewise. + (default_chkp_initialize_bounds): Likewise. + * targhooks.h (default_chkp_bound_type): Likewise. + (default_chkp_bound_mode): Likewise. + (default_builtin_chkp_function): Likewise. + (default_chkp_function_value_bounds): Likewise. + (default_chkp_make_bounds_constant): Likewise. + (default_chkp_initialize_bounds): Likewise. + * toplev.c (compile_file): Likewise. + (process_options): Likewise. + * tree-core.h (DEF_BUILTIN): Likewise. + (DEF_BUILTIN_CHKP): Likewise. + * tree-inline.c (declare_return_variable): Likewise. + (remap_gimple_stmt): Likewise. + (copy_bb): Likewise. + (initialize_inlined_parameters): Likewise. + (expand_call_inline): Likewise. + * tree-pass.h (make_pass_ipa_chkp_versioning): Likewise. + (make_pass_ipa_chkp_early_produce_thunks): Likewise. + (make_pass_ipa_chkp_produce_thunks): Likewise. + (make_pass_chkp): Likewise. + (make_pass_chkp_opt): Likewise. + (make_pass_chkp_instrumentation_passes): Likewise. + * tree-pretty-print.c (dump_generic_node): Likewise. + * tree-ssa-ccp.c (insert_clobber_before_stack_restore): Likewise. + * tree-ssa-dce.c (propagate_necessity): Likewise. + (eliminate_unnecessary_stmts): Likewise. + * tree-ssa-pre.c (create_expression_by_pieces): Likewise. + * tree-ssa-sccvn.c (copy_reference_ops_from_call): Likewise. + * tree-ssa-sccvn.h: Likewise. + * tree-ssa-strlen.c (get_string_length): Likewise. + (valid_builtin_call): Likewise. + (adjust_last_stmt): Likewise. + (handle_builtin_strchr): Likewise. + (handle_builtin_strcpy): Likewise. + (handle_builtin_stxncpy): Likewise. + (handle_builtin_memcpy): Likewise. + (handle_builtin_strcat): Likewise. + (strlen_check_and_optimize_stmt): Likewise. + * tree-stdarg.c (expand_ifn_va_arg_1): Likewise. + * tree-streamer-in.c: Likewise. + * tree-streamer.c (record_common_node): Likewise. + * tree.c (tree_code_size): Likewise. + (wide_int_to_tree_1): Likewise. + (type_contains_placeholder_1): Likewise. + (build_common_tree_nodes): Likewise. + * tree.def (POINTER_BOUNDS_TYPE): Likewise. + * tree.h (POINTER_BOUNDS_TYPE_P): Likewise. + (POINTER_BOUNDS_P): Likewise. + (BOUNDED_TYPE_P): Likewise. + (BOUNDED_P): Likewise. + (CALL_WITH_BOUNDS_P): Likewise. + (pointer_bounds_type_node): Likewise. + * value-prof.c (gimple_ic): Likewise. + * var-tracking.c (vt_add_function_parameters): Likewise. + * varasm.c (make_decl_rtl): Likewise. + (assemble_start_function): Likewise. + (output_constant): Likewise. + (maybe_assemble_visibility): Likewise. + * varpool.c (ctor_for_folding): Likewise. + * chkp-builtins.def: Remove. + * ipa-chkp.c: Remove. + * ipa-chkp.h: Remove. + * rtl-chkp.c: Remove. + * rtl-chkp.h: Remove. + * tree-chkp-opt.c: Remove. + * tree-chkp.c: Remove. + * tree-chkp.h: Remove. + 2018-06-07 Carl Love <cel@us.ibm.com> * gcc/config/rs6000/vsx.md (vextract_fp_from_shorth, diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 256a21546ee..d8f3e886118 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1355,7 +1355,6 @@ OBJS = \ incpath.o \ init-regs.o \ internal-fn.o \ - ipa-chkp.o \ ipa-cp.o \ ipa-devirt.o \ ipa-fnsummary.o \ @@ -1452,7 +1451,6 @@ OBJS = \ reload1.o \ reorg.o \ resource.o \ - rtl-chkp.o \ rtl-error.o \ rtl-tests.o \ rtl.o \ @@ -1518,8 +1516,6 @@ OBJS = \ tree-outof-ssa.o \ tree-parloops.o \ tree-phinodes.o \ - tree-chkp.o \ - tree-chkp-opt.o \ tree-predcom.o \ tree-pretty-print.o \ tree-profile.o \ @@ -2552,7 +2548,6 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \ $(srcdir)/gimple.h \ $(srcdir)/gimple-ssa.h \ - $(srcdir)/tree-chkp.c \ $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \ $(srcdir)/tree-cfg.c $(srcdir)/tree-ssa-loop-ivopts.c \ $(srcdir)/tree-dfa.c \ @@ -3512,7 +3507,7 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ tree-ssa-loop-niter.h tree-ssa-ter.h tree-ssa-threadedge.h \ tree-ssa-threadupdate.h inchash.h wide-int.h signop.h hash-map.h \ hash-set.h dominance.h cfg.h cfgrtl.h cfganal.h cfgbuild.h cfgcleanup.h \ - lcm.h cfgloopmanip.h file-prefix-map.h builtins.def chkp-builtins.def \ + lcm.h cfgloopmanip.h file-prefix-map.h builtins.def \ pass-instances.def params.list # generate the 'build fragment' b-header-vars diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index 5365befd351..845810c3736 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -152,8 +152,6 @@ DEF_PRIMITIVE_TYPE (BT_I4, builtin_type_for_size (BITS_PER_UNIT*4, 1)) DEF_PRIMITIVE_TYPE (BT_I8, builtin_type_for_size (BITS_PER_UNIT*8, 1)) DEF_PRIMITIVE_TYPE (BT_I16, builtin_type_for_size (BITS_PER_UNIT*16, 1)) -DEF_PRIMITIVE_TYPE (BT_BND, pointer_bounds_type_node) - /* The C type `char * const *'. */ DEF_PRIMITIVE_TYPE (BT_PTR_CONST_STRING, build_pointer_type @@ -300,8 +298,6 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_FLOAT, BT_UINT64, BT_FLOAT) DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_INT, BT_BOOL, BT_INT) DEF_FUNCTION_TYPE_1 (BT_FN_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR) -DEF_FUNCTION_TYPE_1 (BT_FN_BND_CONST_PTR, BT_BND, BT_CONST_PTR) -DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_BND, BT_CONST_PTR, BT_BND) DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT32, BT_UINT16, BT_UINT32) DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT16, BT_UINT32, BT_UINT16) DEF_FUNCTION_TYPE_1 (BT_FN_INT_FENV_T_PTR, BT_INT, BT_FENV_T_PTR) @@ -487,9 +483,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_SIZE, BT_PTR, BT_CONST_PTR, BT_SIZE) DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR, BT_CONST_PTR) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTRPTR_CONST_PTR, BT_VOID, BT_PTR_PTR, BT_CONST_PTR) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, BT_SIZE) -DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_BND, BT_VOID, BT_PTR, BT_BND) DEF_FUNCTION_TYPE_2 (BT_FN_CONST_PTR_CONST_PTR_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR) -DEF_FUNCTION_TYPE_2 (BT_FN_BND_CONST_PTR_SIZE, BT_BND, BT_CONST_PTR, BT_SIZE) DEF_FUNCTION_TYPE_2 (BT_FN_UINT32_UINT64_PTR, BT_UINT32, BT_UINT64, BT_PTR) DEF_FUNCTION_TYPE_2 (BT_FN_INT_FEXCEPT_T_PTR_INT, BT_INT, BT_FEXCEPT_T_PTR, @@ -607,7 +601,6 @@ DEF_FUNCTION_TYPE_3 (BT_FN_VOID_VPTR_I8_INT, BT_VOID, BT_VOLATILE_PTR, BT_I8, BT DEF_FUNCTION_TYPE_3 (BT_FN_VOID_VPTR_I16_INT, BT_VOID, BT_VOLATILE_PTR, BT_I16, BT_INT) DEF_FUNCTION_TYPE_3 (BT_FN_INT_PTRPTR_SIZE_SIZE, BT_INT, BT_PTR_PTR, BT_SIZE, BT_SIZE) DEF_FUNCTION_TYPE_3 (BT_FN_PTR_CONST_PTR_CONST_PTR_SIZE, BT_PTR, BT_CONST_PTR, BT_CONST_PTR, BT_SIZE) -DEF_FUNCTION_TYPE_3 (BT_FN_VOID_CONST_PTR_BND_CONST_PTR, BT_VOID, BT_CONST_PTR, BT_BND, BT_CONST_PTR) DEF_FUNCTION_TYPE_3 (BT_FN_BOOL_INT_INT_INTPTR, BT_BOOL, BT_INT, BT_INT, BT_INT_PTR) DEF_FUNCTION_TYPE_3 (BT_FN_BOOL_LONG_LONG_LONGPTR, BT_BOOL, BT_LONG, BT_LONG, diff --git a/gcc/builtins.c b/gcc/builtins.c index d4150d877dd..8707e0cfbc3 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -64,8 +64,6 @@ along with GCC; see the file COPYING3. If not see #include "stringpool.h" #include "attribs.h" #include "asan.h" -#include "tree-chkp.h" -#include "rtl-chkp.h" #include "internal-fn.h" #include "case-cfn-macros.h" #include "gimple-fold.h" @@ -125,12 +123,10 @@ static rtx expand_builtin_strncmp (tree, rtx, machine_mode); static rtx builtin_memcpy_read_str (void *, HOST_WIDE_INT, scalar_int_mode); static rtx expand_builtin_memchr (tree, rtx); static rtx expand_builtin_memcpy (tree, rtx); -static rtx expand_builtin_memcpy_with_bounds (tree, rtx); static rtx expand_builtin_memory_copy_args (tree dest, tree src, tree len, rtx target, tree exp, int endp); static rtx expand_builtin_memmove (tree, rtx); static rtx expand_builtin_mempcpy (tree, rtx); -static rtx expand_builtin_mempcpy_with_bounds (tree, rtx); static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx, tree, int); static rtx expand_builtin_strcat (tree, rtx); static rtx expand_builtin_strcpy (tree, rtx); @@ -141,7 +137,6 @@ static rtx expand_builtin_strncat (tree, rtx); static rtx expand_builtin_strncpy (tree, rtx); static rtx builtin_memset_gen_str (void *, HOST_WIDE_INT, scalar_int_mode); static rtx expand_builtin_memset (tree, rtx, machine_mode); -static rtx expand_builtin_memset_with_bounds (tree, rtx, machine_mode); static rtx expand_builtin_memset_args (tree, tree, tree, rtx, machine_mode, tree); static rtx expand_builtin_bzero (tree); static rtx expand_builtin_strlen (tree, rtx, machine_mode); @@ -3479,38 +3474,6 @@ expand_builtin_memmove (tree exp, rtx) return NULL_RTX; } -/* Expand an instrumented call EXP to the memcpy builtin. - Return NULL_RTX if we failed, the caller should emit a normal call, - otherwise try to get the result in TARGET, if convenient (and in - mode MODE if that's convenient). */ - -static rtx -expand_builtin_memcpy_with_bounds (tree exp, rtx target) -{ - if (!validate_arglist (exp, - POINTER_TYPE, POINTER_BOUNDS_TYPE, - POINTER_TYPE, POINTER_BOUNDS_TYPE, - INTEGER_TYPE, VOID_TYPE)) - return NULL_RTX; - else - { - tree dest = CALL_EXPR_ARG (exp, 0); - tree src = CALL_EXPR_ARG (exp, 2); - tree len = CALL_EXPR_ARG (exp, 4); - rtx res = expand_builtin_memory_copy_args (dest, src, len, target, exp, - /*end_p=*/ 0); - - /* Return src bounds with the result. */ - if (res) - { - rtx bnd = force_reg (targetm.chkp_bound_mode (), - expand_normal (CALL_EXPR_ARG (exp, 1))); - res = chkp_join_splitted_slot (res, bnd); - } - return res; - } -} - /* Expand a call EXP to the mempcpy builtin. Return NULL_RTX if we failed; the caller should emit a normal call, otherwise try to get the result in TARGET, if convenient (and in @@ -3553,38 +3516,6 @@ expand_builtin_mempcpy (tree exp, rtx target) target, exp, /*endp=*/ 1); } -/* Expand an instrumented call EXP to the mempcpy builtin. - Return NULL_RTX if we failed, the caller should emit a normal call, - otherwise try to get the result in TARGET, if convenient (and in - mode MODE if that's convenient). */ - -static rtx -expand_builtin_mempcpy_with_bounds (tree exp, rtx target) -{ - if (!validate_arglist (exp, - POINTER_TYPE, POINTER_BOUNDS_TYPE, - POINTER_TYPE, POINTER_BOUNDS_TYPE, - INTEGER_TYPE, VOID_TYPE)) - return NULL_RTX; - else - { - tree dest = CALL_EXPR_ARG (exp, 0); - tree src = CALL_EXPR_ARG (exp, 2); - tree len = CALL_EXPR_ARG (exp, 4); - rtx res = expand_builtin_mempcpy_args (dest, src, len, target, - exp, 1); - - /* Return src bounds with the result. */ - if (res) - { - rtx bnd = force_reg (targetm.chkp_bound_mode (), - expand_normal (CALL_EXPR_ARG (exp, 1))); - res = chkp_join_splitted_slot (res, bnd); - } - return res; - } -} - /* Helper function to do the actual work for expand of memory copy family functions (memcpy, mempcpy, stpcpy). Expansing should assign LEN bytes of memory from SRC to DEST and assign to TARGET if convenient. @@ -4205,36 +4136,6 @@ expand_builtin_memset (tree exp, rtx target, machine_mode mode) return expand_builtin_memset_args (dest, val, len, target, mode, exp); } -/* Expand expression EXP, which is an instrumented call to the memset builtin. - Return NULL_RTX if we failed the caller should emit a normal call, otherwise - try to get the result in TARGET, if convenient (and in mode MODE if that's - convenient). */ - -static rtx -expand_builtin_memset_with_bounds (tree exp, rtx target, machine_mode mode) -{ - if (!validate_arglist (exp, - POINTER_TYPE, POINTER_BOUNDS_TYPE, - INTEGER_TYPE, INTEGER_TYPE, VOID_TYPE)) - return NULL_RTX; - else - { - tree dest = CALL_EXPR_ARG (exp, 0); - tree val = CALL_EXPR_ARG (exp, 2); - tree len = CALL_EXPR_ARG (exp, 3); - rtx res = expand_builtin_memset_args (dest, val, len, target, mode, exp); - - /* Return src bounds with the result. */ - if (res) - { - rtx bnd = force_reg (targetm.chkp_bound_mode (), - expand_normal (CALL_EXPR_ARG (exp, 1))); - res = chkp_join_splitted_slot (res, bnd); - } - return res; - } -} - /* Helper function to do the actual work for expand_builtin_memset. The arguments to the builtin_memset call DEST, VAL, and LEN are broken out so that this can also be called without constructing an actual CALL_EXPR. @@ -4363,8 +4264,7 @@ expand_builtin_memset_args (tree dest, tree val, tree len, do_libcall: fndecl = get_callee_fndecl (orig_exp); fcode = DECL_FUNCTION_CODE (fndecl); - if (fcode == BUILT_IN_MEMSET - || fcode == BUILT_IN_CHKP_MEMSET_NOBND_NOCHK_CHKP) + if (fcode == BUILT_IN_MEMSET) fn = build_call_nofold_loc (EXPR_LOCATION (orig_exp), fndecl, 3, dest, val, len); else if (fcode == BUILT_IN_BZERO) @@ -4889,13 +4789,6 @@ std_expand_builtin_va_start (tree valist, rtx nextarg) { rtx va_r = expand_expr (valist, NULL_RTX, VOIDmode, EXPAND_WRITE); convert_move (va_r, nextarg, 0); - - /* We do not have any valid bounds for the pointer, so - just store zero bounds for it. */ - if (chkp_function_instrumented_p (current_function_decl)) - chkp_expand_bounds_reset_for_mem (valist, - make_tree (TREE_TYPE (valist), - nextarg)); } /* Expand EXP, a call to __builtin_va_start. */ @@ -6766,19 +6659,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, && fcode != BUILT_IN_EXECVP && fcode != BUILT_IN_EXECVE && !ALLOCA_FUNCTION_CODE_P (fcode) - && fcode != BUILT_IN_FREE - && fcode != BUILT_IN_CHKP_SET_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_INIT_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_NULL_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_COPY_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_NARROW_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_STORE_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_CHECK_PTR_LBOUNDS - && fcode != BUILT_IN_CHKP_CHECK_PTR_UBOUNDS - && fcode != BUILT_IN_CHKP_CHECK_PTR_BOUNDS - && fcode != BUILT_IN_CHKP_GET_PTR_LBOUND - && fcode != BUILT_IN_CHKP_GET_PTR_UBOUND - && fcode != BUILT_IN_CHKP_BNDRET) + && fcode != BUILT_IN_FREE) return expand_call (exp, target, ignore); /* The built-in function expanders test for target == const0_rtx @@ -6812,10 +6693,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, } } - /* expand_builtin_with_bounds is supposed to be used for - instrumented builtin calls. */ - gcc_assert (!CALL_WITH_BOUNDS_P (exp)); - switch (fcode) { CASE_FLT_FN (BUILT_IN_FABS): @@ -7840,51 +7717,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, expand_builtin_set_thread_pointer (exp); return const0_rtx; - case BUILT_IN_CHKP_INIT_PTR_BOUNDS: - case BUILT_IN_CHKP_NULL_PTR_BOUNDS: - case BUILT_IN_CHKP_COPY_PTR_BOUNDS: - case BUILT_IN_CHKP_CHECK_PTR_LBOUNDS: - case BUILT_IN_CHKP_CHECK_PTR_UBOUNDS: - case BUILT_IN_CHKP_CHECK_PTR_BOUNDS: - case BUILT_IN_CHKP_SET_PTR_BOUNDS: - case BUILT_IN_CHKP_NARROW_PTR_BOUNDS: - case BUILT_IN_CHKP_STORE_PTR_BOUNDS: - case BUILT_IN_CHKP_GET_PTR_LBOUND: - case BUILT_IN_CHKP_GET_PTR_UBOUND: - /* We allow user CHKP builtins if Pointer Bounds - Checker is off. */ - if (!chkp_function_instrumented_p (current_function_decl)) - { - if (fcode == BUILT_IN_CHKP_SET_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_NARROW_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_INIT_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_NULL_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_COPY_PTR_BOUNDS) - return expand_normal (CALL_EXPR_ARG (exp, 0)); - else if (fcode == BUILT_IN_CHKP_GET_PTR_LBOUND) - return expand_normal (size_zero_node); - else if (fcode == BUILT_IN_CHKP_GET_PTR_UBOUND) - return expand_normal (size_int (-1)); - else - return const0_rtx; - } - /* FALLTHROUGH */ - - case BUILT_IN_CHKP_BNDMK: - case BUILT_IN_CHKP_BNDSTX: - case BUILT_IN_CHKP_BNDCL: - case BUILT_IN_CHKP_BNDCU: - case BUILT_IN_CHKP_BNDLDX: - case BUILT_IN_CHKP_BNDRET: - case BUILT_IN_CHKP_INTERSECT: - case BUILT_IN_CHKP_NARROW: - case BUILT_IN_CHKP_EXTRACT_LOWER: - case BUILT_IN_CHKP_EXTRACT_UPPER: - /* Software implementation of Pointer Bounds Checker is NYI. - Target support is required. */ - error ("Your target platform does not support -fcheck-pointer-bounds"); - break; - case BUILT_IN_ACC_ON_DEVICE: /* Do library call, if we failed to expand the builtin when folding. */ @@ -7903,70 +7735,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, return expand_call (exp, target, ignore); } -/* Similar to expand_builtin but is used for instrumented calls. */ - -rtx -expand_builtin_with_bounds (tree exp, rtx target, - rtx subtarget ATTRIBUTE_UNUSED, - machine_mode mode, int ignore) -{ - tree fndecl = get_callee_fndecl (exp); - enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); - - gcc_assert (CALL_WITH_BOUNDS_P (exp)); - - if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) - return targetm.expand_builtin (exp, target, subtarget, mode, ignore); - - gcc_assert (fcode > BEGIN_CHKP_BUILTINS - && fcode < END_CHKP_BUILTINS); - - switch (fcode) - { - case BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK_CHKP: - target = expand_builtin_memcpy_with_bounds (exp, target); - if (target) - return target; - break; - - case BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK_CHKP: - target = expand_builtin_mempcpy_with_bounds (exp, target); - if (target) - return target; - break; - - case BUILT_IN_CHKP_MEMSET_NOBND_NOCHK_CHKP: - target = expand_builtin_memset_with_bounds (exp, target, mode); - if (target) - return target; - break; - - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMMOVE_CHKP: - case BUILT_IN_MEMPCPY_CHKP: - if (call_expr_nargs (exp) > 3) - { - /* memcpy_chkp (void *dst, size_t dstbnd, - const void *src, size_t srcbnd, size_t n) - and others take a pointer bound argument just after each - pointer argument. */ - tree dest = CALL_EXPR_ARG (exp, 0); - tree src = CALL_EXPR_ARG (exp, 2); - tree len = CALL_EXPR_ARG (exp, 4); - - check_memop_access (exp, dest, src, len); - break; - } - - default: - break; - } - - /* The switch statement above can drop through to cause the function - to be called normally. */ - return expand_call (exp, target, ignore); - } - /* Determine whether a tree node represents a call to a built-in function. If the tree T is a call to a built-in function with the right number of arguments of the appropriate types, return diff --git a/gcc/builtins.def b/gcc/builtins.def index 58b469844a7..9776dfabddf 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -63,16 +63,6 @@ along with GCC; see the file COPYING3. If not see The builtins is registered only if COND is true. */ -/* A macro for builtins where the - BUILT_IN_*_CHKP = BUILT_IN_* + BEGIN_CHKP_BUILTINS + 1 - enums should be defined too. */ -#ifndef DEF_BUILTIN_CHKP -#define DEF_BUILTIN_CHKP(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, \ - FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT, COND) \ - DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \ - NONANSI_P, ATTRS, IMPLICIT, COND) -#endif - /* A GCC builtin (like __builtin_saveregs) is provided by the compiler, but does not correspond to a function in the standard library. */ @@ -110,10 +100,6 @@ along with GCC; see the file COPYING3. If not see #define DEF_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ true, true, false, ATTRS, true, true) -#undef DEF_LIB_BUILTIN_CHKP -#define DEF_LIB_BUILTIN_CHKP(ENUM, NAME, TYPE, ATTRS) \ - DEF_BUILTIN_CHKP (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, \ - TYPE, true, true, false, ATTRS, true, true) /* Like DEF_LIB_BUILTIN, except that the function is not one that is specified by ANSI/ISO C. So, when we're being fully conformant we @@ -123,10 +109,6 @@ along with GCC; see the file COPYING3. If not see #define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ true, true, true, ATTRS, false, true) -#undef DEF_EXT_LIB_BUILTIN_CHKP -#define DEF_EXT_LIB_BUILTIN_CHKP(ENUM, NAME, TYPE, ATTRS) \ - DEF_BUILTIN_CHKP (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, \ - TYPE, true, true, true, ATTRS, false, true) /* A set of GCC builtins for _FloatN and _FloatNx types. TYPE_MACRO is called with an argument such as FLOAT32 to produce the enum value for the type. If @@ -259,12 +241,6 @@ along with GCC; see the file COPYING3. If not see | SANITIZE_UNDEFINED_NONDEFAULT) \ || flag_sanitize_coverage)) -/* Builtin used by the implementation of Pointer Bounds Checker. */ -#undef DEF_CHKP_BUILTIN -#define DEF_CHKP_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ - DEF_BUILTIN_CHKP (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, \ - TYPE, true, true, false, ATTRS, true, true) - /* Define an attribute list for math functions that are normally "impure" because some of them may write into global memory for `errno'. If !flag_errno_math they are instead "const". */ @@ -713,22 +689,22 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_BZERO, "bzero", BT_FN_VOID_PTR_SIZE, ATTR_NOTHR DEF_EXT_LIB_BUILTIN (BUILT_IN_INDEX, "index", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_MEMCHR, "memchr", BT_FN_PTR_CONST_PTR_INT_SIZE, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_MEMCMP, "memcmp", BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, ATTR_PURE_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_MEMCPY, "memcpy", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_MEMMOVE, "memmove", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_MEMPCPY, "mempcpy", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_MEMSET, "memset", BT_FN_PTR_PTR_INT_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_MEMCPY, "memcpy", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_MEMMOVE, "memmove", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMPCPY, "mempcpy", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_MEMSET, "memset", BT_FN_PTR_PTR_INT_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_RINDEX, "rindex", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_STPCPY, "stpcpy", BT_FN_STRING_STRING_CONST_STRING, ATTR_RETNONNULL_NOTHROW_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_STPCPY, "stpcpy", BT_FN_STRING_STRING_CONST_STRING, ATTR_RETNONNULL_NOTHROW_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STPNCPY, "stpncpy", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRCASECMP, "strcasecmp", BT_FN_INT_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_STRCAT, "strcat", BT_FN_STRING_STRING_CONST_STRING, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_STRCHR, "strchr", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_STRCAT, "strcat", BT_FN_STRING_STRING_CONST_STRING, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_STRCHR, "strchr", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_STRCMP, "strcmp", BT_FN_INT_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_STRCPY, "strcpy", BT_FN_STRING_STRING_CONST_STRING, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_STRCPY, "strcpy", BT_FN_STRING_STRING_CONST_STRING, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_STRCSPN, "strcspn", BT_FN_SIZE_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRDUP, "strdup", BT_FN_STRING_CONST_STRING, ATTR_MALLOC_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNDUP, "strndup", BT_FN_STRING_CONST_STRING_SIZE, ATTR_MALLOC_NOTHROW_NONNULL_LEAF) -DEF_LIB_BUILTIN_CHKP (BUILT_IN_STRLEN, "strlen", BT_FN_SIZE_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL_LEAF) +DEF_LIB_BUILTIN (BUILT_IN_STRLEN, "strlen", BT_FN_SIZE_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNCASECMP, "strncasecmp", BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, ATTR_PURE_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_STRNCAT, "strncat", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_LIB_BUILTIN (BUILT_IN_STRNCMP, "strncmp", BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, ATTR_PURE_NOTHROW_NONNULL_LEAF) @@ -978,14 +954,14 @@ DEF_BUILTIN_STUB (BUILT_IN_STRNCMP_EQ, "__builtin_strncmp_eq") /* Object size checking builtins. */ DEF_GCC_BUILTIN (BUILT_IN_OBJECT_SIZE, "object_size", BT_FN_SIZE_CONST_PTR_INT, ATTR_PURE_NOTHROW_LEAF_LIST) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_MEMCPY_CHK, "__memcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_MEMMOVE_CHK, "__memmove_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_MEMPCPY_CHK, "__mempcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_MEMSET_CHK, "__memset_chk", BT_FN_PTR_PTR_INT_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_STPCPY_CHK, "__stpcpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMCPY_CHK, "__memcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMMOVE_CHK, "__memmove_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMPCPY_CHK, "__mempcpy_chk", BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMSET_CHK, "__memset_chk", BT_FN_PTR_PTR_INT_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_STPCPY_CHK, "__stpcpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STPNCPY_CHK, "__stpncpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE_SIZE, ATTR_RETNONNULL_NOTHROW_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_STRCAT_CHK, "__strcat_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_EXT_LIB_BUILTIN_CHKP (BUILT_IN_STRCPY_CHK, "__strcpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_STRCAT_CHK, "__strcat_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) +DEF_EXT_LIB_BUILTIN (BUILT_IN_STRCPY_CHK, "__strcpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNCAT_CHK, "__strncat_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNCPY_CHK, "__strncpy_chk", BT_FN_STRING_STRING_CONST_STRING_SIZE_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) DEF_EXT_LIB_BUILTIN (BUILT_IN_SNPRINTF_CHK, "__snprintf_chk", BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_NOTHROW_5_6) @@ -1053,9 +1029,6 @@ DEF_GCC_BUILTIN (BUILT_IN_LINE, "LINE", BT_FN_INT, ATTR_NOTHROW_LEAF_LIST) /* Sanitizer builtins. */ #include "sanitizer.def" -/* Pointer Bounds Checker builtins. */ -#include "chkp-builtins.def" - /* Do not expose the BRIG builtins by default gcc-wide, but only privately in the BRIG FE as long as there are no references for them in the middle end or any of the upstream backends. */ @@ -1099,5 +1072,4 @@ DEF_GCC_BUILTIN (BUILT_IN_LINE, "LINE", BT_FN_INT, ATTR_NOTHROW_LEAF_LIST) /* HSAIL/BRIG frontend builtins. */ #include "brig-builtins.def" -#undef DEF_BUILTIN_CHKP #undef DEF_BUILTIN diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 74bf0a49ab0..28ff01ae241 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2018-06-08 Martin Liska <mliska@suse.cz> + + * c-attribs.c (handle_bnd_variable_size_attribute): Remove support + for MPX (macros, related functions, fields in cgraph_node, ...). + (handle_bnd_legacy): Likewise. + (handle_bnd_instrument): Likewise. + * c.opt: Likewise. + 2018-06-06 Jakub Jelinek <jakub@redhat.com> PR c++/86068 diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index d302b4f22c7..73901bdf47c 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -143,9 +143,6 @@ static tree handle_simd_attribute (tree *, tree, tree, int, bool *); static tree handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *); static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *); -static tree handle_bnd_variable_size_attribute (tree *, tree, tree, int, bool *); -static tree handle_bnd_legacy (tree *, tree, tree, int, bool *); -static tree handle_bnd_instrument (tree *, tree, tree, int, bool *); static tree handle_fallthrough_attribute (tree *, tree, tree, int, bool *); static tree handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *); @@ -239,9 +236,6 @@ static const struct attribute_spec::exclusions attr_const_pure_exclusions[] = /* Table of machine-independent attributes common to all C-like languages. - All attributes referencing arguments should be additionally processed - in chkp_copy_function_type_adding_bounds for correct instrumentation - by Pointer Bounds Checker. Current list of processed common attributes: nonnull. */ const struct attribute_spec c_common_attribute_table[] = { @@ -452,12 +446,6 @@ const struct attribute_spec c_common_attribute_table[] = handle_assume_aligned_attribute, NULL }, { "designated_init", 0, 0, false, true, false, false, handle_designated_init_attribute, NULL }, - { "bnd_variable_size", 0, 0, true, false, false, false, - handle_bnd_variable_size_attribute, NULL }, - { "bnd_legacy", 0, 0, true, false, false, false, - handle_bnd_legacy, NULL }, - { "bnd_instrument", 0, 0, true, false, false, false, - handle_bnd_instrument, NULL }, { "fallthrough", 0, 0, false, false, false, false, handle_fallthrough_attribute, NULL }, { "patchable_function_entry", 1, 2, true, false, false, false, @@ -471,9 +459,6 @@ const struct attribute_spec c_common_attribute_table[] = /* Give the specifications for the format attributes, used by C and all descendants. - All attributes referencing arguments should be additionally processed - in chkp_copy_function_type_adding_bounds for correct instrumentation - by Pointer Bounds Checker. Current list of processed format attributes: format, format_arg. */ const struct attribute_spec c_common_format_attribute_table[] = { @@ -2489,54 +2474,6 @@ handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name), return NULL_TREE; } -/* Handle a "bnd_variable_size" attribute; arguments as in - struct attribute_spec.handler. */ - -static tree -handle_bnd_variable_size_attribute (tree *node, tree name, tree ARG_UNUSED (args), - int ARG_UNUSED (flags), bool *no_add_attrs) -{ - if (TREE_CODE (*node) != FIELD_DECL) - { - warning (OPT_Wattributes, "%qE attribute ignored", name); - *no_add_attrs = true; - } - - return NULL_TREE; -} - -/* Handle a "bnd_legacy" attribute; arguments as in - struct attribute_spec.handler. */ - -static tree -handle_bnd_legacy (tree *node, tree name, tree ARG_UNUSED (args), - int ARG_UNUSED (flags), bool *no_add_attrs) -{ - if (TREE_CODE (*node) != FUNCTION_DECL) - { - warning (OPT_Wattributes, "%qE attribute ignored", name); - *no_add_attrs = true; - } - - return NULL_TREE; -} - -/* Handle a "bnd_instrument" attribute; arguments as in - struct attribute_spec.handler. */ - -static tree -handle_bnd_instrument (tree *node, tree name, tree ARG_UNUSED (args), - int ARG_UNUSED (flags), bool *no_add_attrs) -{ - if (TREE_CODE (*node) != FUNCTION_DECL) - { - warning (OPT_Wattributes, "%qE attribute ignored", name); - *no_add_attrs = true; - } - - return NULL_TREE; -} - /* Handle a "warn_unused" attribute; arguments as in struct attribute_spec.handler. */ diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 5e0397f3614..1d7eafff1f7 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -410,7 +410,7 @@ Warn about subscripts whose type is \"char\". Wchkp C ObjC C++ ObjC++ Var(warn_chkp) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) -Warn about memory access errors found by Pointer Bounds Checker. +Deprecated in GCC 9. This switch has no effect. Wclobbered C ObjC C++ ObjC++ Var(warn_clobbered) Warning EnabledBy(Wextra) @@ -1260,97 +1260,86 @@ Where shorter, use canonicalized paths to systems headers. fcheck-pointer-bounds C ObjC C++ ObjC++ LTO Report Var(flag_check_pointer_bounds) -Add Pointer Bounds Checker instrumentation. fchkp-* flags are used to -control instrumentation. Currently available for C, C++ and ObjC. +Deprecated in GCC 9. This switch has no effect. fchkp-check-incomplete-type C ObjC C++ ObjC++ LTO Report Var(flag_chkp_incomplete_type) Init(1) -Generate pointer bounds checks for variables with incomplete type. +Deprecated in GCC 9. This switch has no effect. fchkp-zero-input-bounds-for-main C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_input_bounds_for_main) Init(0) -Use zero bounds for all incoming arguments in 'main' function. It helps when -instrumented binaries are used with legacy libs. +Deprecated in GCC 9. This switch has no effect. fchkp-first-field-has-own-bounds C ObjC C++ ObjC++ LTO RejectNegative Report Var(flag_chkp_first_field_has_own_bounds) -Forces Pointer Bounds Checker to use narrowed bounds for address of the first -field in the structure. By default pointer to the first field has the same -bounds as pointer to the whole structure. +Deprecated in GCC 9. This switch has no effect. fchkp-narrow-bounds C ObjC C++ ObjC++ LTO Report Var(flag_chkp_narrow_bounds) Init(1) -Control how Pointer Bounds Checker handle pointers to object fields. When -narrowing is on, field bounds are used. Otherwise full object bounds are used. +Deprecated in GCC 9. This switch has no effect. fchkp-narrow-to-innermost-array C ObjC C++ ObjC++ LTO RejectNegative Report Var(flag_chkp_narrow_to_innermost_arrray) -Forces Pointer Bounds Checker to use bounds of the innermost arrays in case of -nested static arrays access. By default outermost array is used. +Deprecated in GCC 9. This switch has no effect. fchkp-flexible-struct-trailing-arrays C ObjC C++ ObjC++ LTO Report Var(flag_chkp_flexible_struct_trailing_arrays) -Forces Pointer Bounds Checker to treat all trailing arrays in structures as -possibly flexible. By default only arrays fields with zero length or that are -marked with attribute bnd_variable_size are treated as flexible. +Deprecated in GCC 9. This switch has no effect. fchkp-optimize C ObjC C++ ObjC++ LTO Report Var(flag_chkp_optimize) Init(-1) -Allow Pointer Bounds Checker optimizations. By default allowed -on optimization levels >0. fchkp-use-fast-string-functions C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_fast_string_functions) Init(0) -Allow to use *_nobnd versions of string functions by Pointer Bounds Checker. +Deprecated in GCC 9. This switch has no effect. fchkp-use-nochk-string-functions C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_nochk_string_functions) Init(0) -Allow to use *_nochk versions of string functions by Pointer Bounds Checker. +Deprecated in GCC 9. This switch has no effect. fchkp-use-static-bounds C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_bounds) Init(1) -Use statically initialized variable for vars bounds instead of -generating them each time it is required. +Deprecated in GCC 9. This switch has no effect. fchkp-use-static-const-bounds C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_const_bounds) Init(-1) -Use statically initialized variable for constant bounds instead of -generating them each time it is required. +Deprecated in GCC 9. This switch has no effect. fchkp-treat-zero-dynamic-size-as-infinite C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_dynamic_size_as_infinite) Init(0) -With this option zero size obtained dynamically for objects with -incomplete type will be treated as infinite. +Deprecated in GCC 9. This switch has no effect. fchkp-check-read C ObjC C++ ObjC++ LTO Report Var(flag_chkp_check_read) Init(1) -Generate checks for all read accesses to memory. +Deprecated in GCC 9. This switch has no effect. fchkp-check-write C ObjC C++ ObjC++ LTO Report Var(flag_chkp_check_write) Init(1) -Generate checks for all write accesses to memory. +Deprecated in GCC 9. This switch has no effect. fchkp-store-bounds C ObjC C++ ObjC++ LTO Report Var(flag_chkp_store_bounds) Init(1) -Generate bounds stores for pointer writes. +Deprecated in GCC 9. This switch has no effect. fchkp-instrument-calls C ObjC C++ ObjC++ LTO Report Var(flag_chkp_instrument_calls) Init(1) -Generate bounds passing for calls. +Deprecated in GCC 9. This switch has no effect. fchkp-instrument-marked-only C ObjC C++ ObjC++ LTO Report Var(flag_chkp_instrument_marked_only) Init(0) -Instrument only functions marked with bnd_instrument attribute. +Deprecated in GCC 9. This switch has no effect. fchkp-use-wrappers C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_wrappers) Init(1) -Transform instrumented builtin calls into calls to wrappers. +Deprecated in GCC 9. This switch has no effect. static-libmpx Driver +Deprecated in GCC 9. This switch has no effect. static-libmpxwrappers Driver +Deprecated in GCC 9. This switch has no effect. fcilkplus Undocumented C ObjC C++ ObjC++ LTO Report Var(flag_cilkplus) Init(0) diff --git a/gcc/calls.c b/gcc/calls.c index 6e1ea925157..a5bba8195af 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -47,10 +47,8 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "dbgcnt.h" #include "rtl-iter.h" -#include "tree-chkp.h" #include "tree-vrp.h" #include "tree-ssanames.h" -#include "rtl-chkp.h" #include "intl.h" #include "stringpool.h" #include "attribs.h" @@ -154,7 +152,6 @@ static unsigned HOST_WIDE_INT stored_args_watermark; static int stack_arg_under_construction; static void precompute_register_parameters (int, struct arg_data *, int *); -static void store_bounds (struct arg_data *, struct arg_data *); static int store_one_arg (struct arg_data *, rtx, int, int, int); static void store_unaligned_arguments_into_pseudos (struct arg_data *, int); static int finalize_must_preallocate (int, int, struct arg_data *, @@ -488,10 +485,6 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU && MEM_EXPR (funmem) != NULL_TREE) set_mem_expr (XEXP (call, 0), MEM_EXPR (funmem)); - /* Mark instrumented calls. */ - if (call && fntree) - CALL_EXPR_WITH_BOUNDS_P (call) = CALL_WITH_BOUNDS_P (fntree); - /* Put the register usage information there. */ add_function_usage_to (call_insn, call_fusage); @@ -598,12 +591,6 @@ special_function_p (const_tree fndecl, int flags) { tree name_decl = DECL_NAME (fndecl); - /* For instrumentation clones we want to derive flags - from the original name. */ - if (cgraph_node::get (fndecl) - && cgraph_node::get (fndecl)->instrumentation_clone) - name_decl = DECL_NAME (cgraph_node::get (fndecl)->orig_decl); - if (fndecl && name_decl && IDENTIFIER_LENGTH (name_decl) <= 11 /* Exclude functions not at the file scope, or not `extern', @@ -1626,8 +1613,6 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL) return; - bool with_bounds = CALL_WITH_BOUNDS_P (exp); - unsigned nargs = call_expr_nargs (exp); /* The bound argument to a bounded string function like strncpy. */ @@ -1651,8 +1636,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) the range of their known or possible lengths and use it conservatively as the bound for the unbounded function, and to adjust the range of the bound of the bounded ones. */ - unsigned stride = with_bounds ? 2 : 1; - for (unsigned argno = 0; argno < nargs && !*lenrng; argno += stride) + for (unsigned argno = 0; argno < nargs && !*lenrng; argno ++) { tree arg = CALL_EXPR_ARG (exp, argno); if (!get_attr_nonstring_decl (arg)) @@ -1662,11 +1646,9 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) /* Fall through. */ case BUILT_IN_STPNCPY: - case BUILT_IN_STPNCPY_CHK: case BUILT_IN_STRNCPY: - case BUILT_IN_STRNCPY_CHK: { - unsigned argno = with_bounds ? 4 : 2; + unsigned argno = 2; if (argno < nargs) bound = CALL_EXPR_ARG (exp, argno); break; @@ -1674,7 +1656,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) case BUILT_IN_STRNDUP: { - unsigned argno = with_bounds ? 2 : 1; + unsigned argno = 1; if (argno < nargs) bound = CALL_EXPR_ARG (exp, argno); break; @@ -1879,7 +1861,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, i = num_actuals - 1; { - int j = i, ptr_arg = -1; + int j = i; call_expr_arg_iterator iter; tree arg; bitmap slots = NULL; @@ -1888,79 +1870,12 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, { args[j].tree_value = struct_value_addr_value; j--; - - /* If we pass structure address then we need to - create bounds for it. Since created bounds is - a call statement, we expand it right here to avoid - fixing all other places where it may be expanded. */ - if (CALL_WITH_BOUNDS_P (exp)) - { - args[j].value = gen_reg_rtx (targetm.chkp_bound_mode ()); - args[j].tree_value - = chkp_make_bounds_for_struct_addr (struct_value_addr_value); - expand_expr_real (args[j].tree_value, args[j].value, VOIDmode, - EXPAND_NORMAL, 0, false); - args[j].pointer_arg = j + 1; - j--; - } } argpos = 0; FOR_EACH_CALL_EXPR_ARG (arg, iter, exp) { tree argtype = TREE_TYPE (arg); - /* Remember last param with pointer and associate it - with following pointer bounds. */ - if (CALL_WITH_BOUNDS_P (exp) - && chkp_type_has_pointer (argtype)) - { - if (slots) - BITMAP_FREE (slots); - ptr_arg = j; - if (!BOUNDED_TYPE_P (argtype)) - { - slots = BITMAP_ALLOC (NULL); - chkp_find_bound_slots (argtype, slots); - } - } - else if (CALL_WITH_BOUNDS_P (exp) - && pass_by_reference (NULL, TYPE_MODE (argtype), argtype, - argpos < n_named_args)) - { - if (slots) - BITMAP_FREE (slots); - ptr_arg = j; - } - else if (POINTER_BOUNDS_TYPE_P (argtype)) - { - /* We expect bounds in instrumented calls only. - Otherwise it is a sign we lost flag due to some optimization - and may emit call args incorrectly. */ - gcc_assert (CALL_WITH_BOUNDS_P (exp)); - - /* For structures look for the next available pointer. */ - if (ptr_arg != -1 && slots) - { - unsigned bnd_no = bitmap_first_set_bit (slots); - args[j].pointer_offset = - bnd_no * POINTER_SIZE / BITS_PER_UNIT; - - bitmap_clear_bit (slots, bnd_no); - - /* Check we have no more pointers in the structure. */ - if (bitmap_empty_p (slots)) - BITMAP_FREE (slots); - } - args[j].pointer_arg = ptr_arg; - - /* Check we covered all pointers in the previous - non bounds arg. */ - if (!slots) - ptr_arg = -1; - } - else - ptr_arg = -1; - if (targetm.calls.split_complex_arg && argtype && TREE_CODE (argtype) == COMPLEX_TYPE @@ -2205,11 +2120,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, || (args[i].pass_on_stack && args[i].reg != 0)) *must_preallocate = 1; - /* No stack allocation and padding for bounds. */ - if (POINTER_BOUNDS_P (args[i].tree_value)) - ; /* Compute the stack-size of this argument. */ - else if (args[i].reg == 0 || args[i].partial != 0 + if (args[i].reg == 0 || args[i].partial != 0 || reg_parm_stack_space > 0 || args[i].pass_on_stack) locate_and_pad_parm (mode, type, @@ -2442,12 +2354,6 @@ finalize_must_preallocate (int must_preallocate, int num_actuals, partial_seen = 1; else if (partial_seen && args[i].reg == 0) must_preallocate = 1; - /* We preallocate in case there are bounds passed - in the bounds table to have precomputed address - for bounds association. */ - else if (POINTER_BOUNDS_P (args[i].tree_value) - && !args[i].reg) - must_preallocate = 1; if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode && (TREE_CODE (args[i].tree_value) == CALL_EXPR @@ -2506,10 +2412,6 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals if (TYPE_EMPTY_P (TREE_TYPE (args[i].tree_value))) continue; - /* Pointer Bounds are never passed on the stack. */ - if (POINTER_BOUNDS_P (args[i].tree_value)) - continue; - addr = simplify_gen_binary (PLUS, Pmode, arg_reg, offset); addr = plus_constant (Pmode, addr, arg_offset); @@ -3320,8 +3222,6 @@ expand_call (tree exp, rtx target, int ignore) /* Register in which non-BLKmode value will be returned, or 0 if no value or if value is BLKmode. */ rtx valreg; - /* Register(s) in which bounds are returned. */ - rtx valbnd = NULL; /* Address where we should return a BLKmode value; 0 if value not BLKmode. */ rtx structure_value_addr = 0; @@ -3589,7 +3489,7 @@ expand_call (tree exp, rtx target, int ignore) structure_value_addr_value = make_tree (build_pointer_type (TREE_TYPE (funtype)), temp); - structure_value_addr_parm = CALL_WITH_BOUNDS_P (exp) ? 2 : 1; + structure_value_addr_parm = 1; } /* Count the arguments and set NUM_ACTUALS. */ @@ -4126,10 +4026,7 @@ expand_call (tree exp, rtx target, int ignore) for (i = 0; i < num_actuals; i++) { - /* Delay bounds until all other args are stored. */ - if (POINTER_BOUNDS_P (args[i].tree_value)) - continue; - else if (args[i].reg == 0 || args[i].pass_on_stack) + if (args[i].reg == 0 || args[i].pass_on_stack) { rtx_insn *before_arg = get_last_insn (); @@ -4203,28 +4100,15 @@ expand_call (tree exp, rtx target, int ignore) /* Figure out the register where the value, if any, will come back. */ valreg = 0; - valbnd = 0; if (TYPE_MODE (rettype) != VOIDmode && ! structure_value_addr) { if (pcc_struct_value) - { - valreg = hard_function_value (build_pointer_type (rettype), - fndecl, NULL, (pass == 0)); - if (CALL_WITH_BOUNDS_P (exp)) - valbnd = targetm.calls. - chkp_function_value_bounds (build_pointer_type (rettype), - fndecl, (pass == 0)); - } + valreg = hard_function_value (build_pointer_type (rettype), + fndecl, NULL, (pass == 0)); else - { - valreg = hard_function_value (rettype, fndecl, fntype, - (pass == 0)); - if (CALL_WITH_BOUNDS_P (exp)) - valbnd = targetm.calls.chkp_function_value_bounds (rettype, - fndecl, - (pass == 0)); - } + valreg = hard_function_value (rettype, fndecl, fntype, + (pass == 0)); /* If VALREG is a PARALLEL whose first member has a zero offset, use that. This is for targets such as m68k that @@ -4240,17 +4124,6 @@ expand_call (tree exp, rtx target, int ignore) } } - /* Store all bounds not passed in registers. */ - for (i = 0; i < num_actuals; i++) - { - if (POINTER_BOUNDS_P (args[i].tree_value) - && !args[i].reg) - store_bounds (&args[i], - args[i].pointer_arg == -1 - ? NULL - : &args[args[i].pointer_arg]); - } - /* If register arguments require space on the stack and stack space was not preallocated, allocate stack space here for arguments passed in registers. */ @@ -4655,10 +4528,6 @@ expand_call (tree exp, rtx target, int ignore) free (stack_usage_map_buf); free (args); - - /* Join result with returned bounds so caller may use them if needed. */ - target = chkp_join_splitted_slot (target, valbnd); - return target; } @@ -5513,67 +5382,6 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, } -/* Store pointer bounds argument ARG into Bounds Table entry - associated with PARM. */ -static void -store_bounds (struct arg_data *arg, struct arg_data *parm) -{ - rtx slot = NULL, ptr = NULL, addr = NULL; - - /* We may pass bounds not associated with any pointer. */ - if (!parm) - { - gcc_assert (arg->special_slot); - slot = arg->special_slot; - ptr = const0_rtx; - } - /* Find pointer associated with bounds and where it is - passed. */ - else - { - if (!parm->reg) - { - gcc_assert (!arg->special_slot); - - addr = adjust_address (parm->stack, Pmode, arg->pointer_offset); - } - else if (REG_P (parm->reg)) - { - gcc_assert (arg->special_slot); - slot = arg->special_slot; - - if (MEM_P (parm->value)) - addr = adjust_address (parm->value, Pmode, arg->pointer_offset); - else if (REG_P (parm->value)) - ptr = gen_rtx_SUBREG (Pmode, parm->value, arg->pointer_offset); - else - { - gcc_assert (!arg->pointer_offset); - ptr = parm->value; - } - } - else - { - gcc_assert (GET_CODE (parm->reg) == PARALLEL); - - gcc_assert (arg->special_slot); - slot = arg->special_slot; - - if (parm->parallel_value) - ptr = chkp_get_value_with_offs (parm->parallel_value, - GEN_INT (arg->pointer_offset)); - else - gcc_unreachable (); - } - } - - /* Expand bounds. */ - if (!arg->value) - arg->value = expand_normal (arg->tree_value); - - targetm.calls.store_bounds_for_arg (ptr, addr, arg->value, slot); -} - /* Store a single argument for a function call into the register or memory area where it must be passed. *ARG describes the argument value and where to pass it. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index c61104d1683..bf8c54bf873 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -74,8 +74,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-address.h" #include "output.h" #include "builtins.h" -#include "tree-chkp.h" -#include "rtl-chkp.h" /* Some systems use __main in a way incompatible with its use in gcc, in these cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to @@ -2665,7 +2663,6 @@ expand_call_stmt (gcall *stmt) CALL_EXPR_VA_ARG_PACK (exp) = gimple_call_va_arg_pack_p (stmt); CALL_EXPR_BY_DESCRIPTOR (exp) = gimple_call_by_descriptor_p (stmt); SET_EXPR_LOCATION (exp, gimple_location (stmt)); - CALL_WITH_BOUNDS_P (exp) = gimple_call_with_bounds_p (stmt); /* Ensure RTL is created for debug args. */ if (decl && DECL_HAS_DEBUG_ARGS_P (decl)) @@ -3444,12 +3441,11 @@ expand_value_return (rtx val) from the current function. */ static void -expand_return (tree retval, tree bounds) +expand_return (tree retval) { rtx result_rtl; rtx val = 0; tree retval_rhs; - rtx bounds_rtl; /* If function wants no value, give it none. */ if (TREE_CODE (TREE_TYPE (TREE_TYPE (current_function_decl))) == VOID_TYPE) @@ -3475,71 +3471,6 @@ expand_return (tree retval, tree bounds) result_rtl = DECL_RTL (DECL_RESULT (current_function_decl)); - /* Put returned bounds to the right place. */ - bounds_rtl = DECL_BOUNDS_RTL (DECL_RESULT (current_function_decl)); - if (bounds_rtl) - { - rtx addr = NULL; - rtx bnd = NULL; - - if (bounds && bounds != error_mark_node) - { - bnd = expand_normal (bounds); - targetm.calls.store_returned_bounds (bounds_rtl, bnd); - } - else if (REG_P (bounds_rtl)) - { - if (bounds) - bnd = chkp_expand_zero_bounds (); - else - { - addr = expand_normal (build_fold_addr_expr (retval_rhs)); - addr = gen_rtx_MEM (Pmode, addr); - bnd = targetm.calls.load_bounds_for_arg (addr, NULL, NULL); - } - - targetm.calls.store_returned_bounds (bounds_rtl, bnd); - } - else - { - int n; - - gcc_assert (GET_CODE (bounds_rtl) == PARALLEL); - - if (bounds) - bnd = chkp_expand_zero_bounds (); - else - { - addr = expand_normal (build_fold_addr_expr (retval_rhs)); - addr = gen_rtx_MEM (Pmode, addr); - } - - for (n = 0; n < XVECLEN (bounds_rtl, 0); n++) - { - rtx slot = XEXP (XVECEXP (bounds_rtl, 0, n), 0); - if (!bounds) - { - rtx offs = XEXP (XVECEXP (bounds_rtl, 0, n), 1); - rtx from = adjust_address (addr, Pmode, INTVAL (offs)); - bnd = targetm.calls.load_bounds_for_arg (from, NULL, NULL); - } - targetm.calls.store_returned_bounds (slot, bnd); - } - } - } - else if (chkp_function_instrumented_p (current_function_decl) - && !BOUNDED_P (retval_rhs) - && chkp_type_has_pointer (TREE_TYPE (retval_rhs)) - && TREE_CODE (retval_rhs) != RESULT_DECL) - { - rtx addr = expand_normal (build_fold_addr_expr (retval_rhs)); - addr = gen_rtx_MEM (Pmode, addr); - - gcc_assert (MEM_P (result_rtl)); - - chkp_copy_bounds_for_stack_parm (result_rtl, addr, TREE_TYPE (retval_rhs)); - } - /* If we are returning the RESULT_DECL, then the value has already been stored into it, so we don't have to do anything special. */ if (TREE_CODE (retval_rhs) == RESULT_DECL) @@ -3646,19 +3577,12 @@ expand_gimple_stmt_1 (gimple *stmt) case GIMPLE_RETURN: { - tree bnd = gimple_return_retbnd (as_a <greturn *> (stmt)); op0 = gimple_return_retval (as_a <greturn *> (stmt)); if (op0 && op0 != error_mark_node) { tree result = DECL_RESULT (current_function_decl); - /* Mark we have return statement with missing bounds. */ - if (!bnd - && chkp_function_instrumented_p (cfun->decl) - && !DECL_P (op0)) - bnd = error_mark_node; - /* If we are not returning the current function's RESULT_DECL, build an assignment to it. */ if (op0 != result) @@ -3680,7 +3604,7 @@ expand_gimple_stmt_1 (gimple *stmt) if (!op0) expand_null_return (); else - expand_return (op0, bnd); + expand_return (op0); } break; @@ -6267,9 +6191,6 @@ pass_expand::execute (function *fun) rtl_profile_for_bb (ENTRY_BLOCK_PTR_FOR_FN (fun)); - if (chkp_function_instrumented_p (current_function_decl)) - chkp_reset_rtl_bounds (); - insn_locations_init (); if (!DECL_IS_BUILTIN (current_function_decl)) { diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 9f3a2929f6b..f922b70a430 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -58,7 +58,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-dfa.h" #include "profile.h" #include "params.h" -#include "tree-chkp.h" #include "context.h" #include "gimplify.h" #include "stringpool.h" @@ -1275,7 +1274,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void) tree decl = gimple_call_fndecl (e->call_stmt); gcall *new_stmt; gimple_stmt_iterator gsi; - bool skip_bounds = false; if (e->speculative) { @@ -1333,24 +1331,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void) e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt, false); e->count = gimple_bb (e->call_stmt)->count; - - /* Fix edges for BUILT_IN_CHKP_BNDRET calls attached to the - processed call stmt. */ - if (gimple_call_with_bounds_p (new_stmt) - && gimple_call_lhs (new_stmt) - && chkp_retbnd_call_by_val (gimple_call_lhs (e2->call_stmt))) - { - tree dresult = gimple_call_lhs (new_stmt); - tree iresult = gimple_call_lhs (e2->call_stmt); - gcall *dbndret = chkp_retbnd_call_by_val (dresult); - gcall *ibndret = chkp_retbnd_call_by_val (iresult); - struct cgraph_edge *iedge - = e2->caller->cgraph_node::get_edge (ibndret); - - if (dbndret) - iedge->caller->create_edge (iedge->callee, dbndret, e->count); - } - e2->speculative = false; e2->count = gimple_bb (e2->call_stmt)->count; ref->speculative = false; @@ -1364,16 +1344,9 @@ cgraph_edge::redirect_call_stmt_to_callee (void) } } - /* We might propagate instrumented function pointer into - not instrumented function and vice versa. In such a - case we need to either fix function declaration or - remove bounds from call statement. */ - if (flag_check_pointer_bounds && e->callee) - skip_bounds = chkp_redirect_edge (e); if (e->indirect_unknown_callee - || (decl == e->callee->decl - && !skip_bounds)) + || decl == e->callee->decl) return e->call_stmt; if (flag_checking && decl) @@ -1395,8 +1368,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void) } } - if (e->callee->clone.combined_args_to_skip - || skip_bounds) + if (e->callee->clone.combined_args_to_skip) { int lp_nr; @@ -1405,9 +1377,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void) new_stmt = gimple_call_copy_skip_args (new_stmt, e->callee->clone.combined_args_to_skip); - if (skip_bounds) - new_stmt = chkp_copy_call_skip_bounds (new_stmt); - tree old_fntype = gimple_call_fntype (e->call_stmt); gimple_call_set_fndecl (new_stmt, e->callee->decl); cgraph_node *origin = e->callee; @@ -1906,12 +1875,6 @@ cgraph_node::remove (void) call_site_hash = NULL; } - if (instrumented_version) - { - instrumented_version->instrumented_version = NULL; - instrumented_version = NULL; - } - symtab->release_symbol (this, uid); } @@ -2234,11 +2197,6 @@ cgraph_node::dump (FILE *f) if (edge->indirect_info->polymorphic) edge->indirect_info->context.dump (f); } - - if (instrumentation_clone) - fprintf (f, " Is instrumented version.\n"); - else if (instrumented_version) - fprintf (f, " Has instrumented version.\n"); } /* Dump call graph node NODE to stderr. */ @@ -3335,9 +3293,7 @@ cgraph_node::verify_node (void) error_found = true; } for (i = 0; iterate_reference (i, ref); i++) - if (ref->use == IPA_REF_CHKP) - ; - else if (ref->use != IPA_REF_ALIAS) + if (ref->use != IPA_REF_ALIAS) { error ("Alias has non-alias reference"); error_found = true; @@ -3356,77 +3312,6 @@ cgraph_node::verify_node (void) } } - /* Check instrumented version reference. */ - if (instrumented_version - && instrumented_version->instrumented_version != this) - { - error ("Instrumentation clone does not reference original node"); - error_found = true; - } - - /* Cannot have orig_decl for not instrumented nodes. */ - if (!instrumentation_clone && orig_decl) - { - error ("Not instrumented node has non-NULL original declaration"); - error_found = true; - } - - /* If original not instrumented node still exists then we may check - original declaration is set properly. */ - if (instrumented_version - && orig_decl - && orig_decl != instrumented_version->decl) - { - error ("Instrumented node has wrong original declaration"); - error_found = true; - } - - /* Check all nodes have chkp reference to their instrumented versions. */ - if (analyzed - && instrumented_version - && !instrumentation_clone) - { - bool ref_found = false; - int i; - struct ipa_ref *ref; - - for (i = 0; iterate_reference (i, ref); i++) - if (ref->use == IPA_REF_CHKP) - { - if (ref_found) - { - error ("Node has more than one chkp reference"); - error_found = true; - } - if (ref->referred != instrumented_version) - { - error ("Wrong node is referenced with chkp reference"); - error_found = true; - } - ref_found = true; - } - - if (!ref_found) - { - error ("Analyzed node has no reference to instrumented version"); - error_found = true; - } - } - - if (instrumentation_clone - && DECL_BUILT_IN_CLASS (decl) == NOT_BUILT_IN) - { - tree name = DECL_ASSEMBLER_NAME (decl); - tree orig_name = DECL_ASSEMBLER_NAME (orig_decl); - - if (!IDENTIFIER_TRANSPARENT_ALIAS (name) - || TREE_CHAIN (name) != orig_name) - { - error ("Alias chain for instrumented node is broken"); - error_found = true; - } - } - if (analyzed && thunk.thunk_p) { if (!callees) @@ -3444,12 +3329,6 @@ cgraph_node::verify_node (void) error ("Thunk is not supposed to have body"); error_found = true; } - if (thunk.add_pointer_bounds_args - && !instrumented_version->semantically_equivalent_p (callees->callee)) - { - error ("Instrumentation thunk has wrong edge callee"); - error_found = true; - } } else if (analyzed && gimple_has_body_p (decl) && !TREE_ASM_WRITTEN (decl) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index afb2745a841..f0f9961b1b5 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1362,13 +1362,6 @@ public: cgraph_node *prev_sibling_clone; cgraph_node *clones; cgraph_node *clone_of; - /* If instrumentation_clone is 1 then instrumented_version points - to the original function used to make instrumented version. - Otherwise points to instrumented version of the function. */ - cgraph_node *instrumented_version; - /* If instrumentation_clone is 1 then orig_decl is the original - function declaration. */ - tree orig_decl; /* For functions with many calls sites it holds map from call expression to the edge to speed up cgraph_edge function. */ hash_table<cgraph_edge_hasher> *GTY(()) call_site_hash; @@ -1433,9 +1426,6 @@ public: unsigned calls_comdat_local : 1; /* True if node has been created by merge operation in IPA-ICF. */ unsigned icf_merged: 1; - /* True when function is clone created for Pointer Bounds Checker - instrumentation. */ - unsigned instrumentation_clone : 1; /* True if call to node can't result in a call to free, munmap or other operation that could make previously non-trapping memory accesses trapping. */ @@ -2386,9 +2376,6 @@ bool ipa_discover_readonly_nonaddressable_vars (void); /* In varpool.c */ tree ctor_for_folding (tree); -/* In tree-chkp.c */ -extern bool chkp_function_instrumented_p (tree fndecl); - /* In ipa-inline-analysis.c */ void initialize_inline_failed (struct cgraph_edge *); bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining); @@ -2449,8 +2436,6 @@ symtab_node::get_alias_target (void) { ipa_ref *ref = NULL; iterate_reference (0, ref); - if (ref->use == IPA_REF_CHKP) - iterate_reference (1, ref); gcc_checking_assert (ref->use == IPA_REF_ALIAS); return ref->referred; } @@ -2905,12 +2890,6 @@ inline bool cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void) { gcc_checking_assert (!global.inlined_to); - /* Instrumentation clones should not be removed before - instrumentation happens. New callers may appear after - instrumentation. */ - if (instrumentation_clone - && !chkp_function_instrumented_p (decl)) - return false; /* Extern inlines can always go, we will use the external definition. */ if (DECL_EXTERNAL (decl)) return true; @@ -3318,18 +3297,6 @@ ipa_polymorphic_call_context::useless_p () const return (!outer_type && !speculative_outer_type); } -/* Return true if NODE is local. Instrumentation clones are counted as local - only when original function is local. */ - -static inline bool -cgraph_local_p (cgraph_node *node) -{ - if (!node->instrumentation_clone || !node->instrumented_version) - return node->local.local; - - return node->local.local && node->instrumented_version->local.local; -} - /* When using fprintf (or similar), problems can arise with transient generated strings. Many string-generation APIs only support one result being alive at once (e.g. by diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index c453a2d7991..c2ad5cf2ef7 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -429,11 +429,6 @@ cgraph_edge::rebuild_edges (void) } record_eh_tables (node, cfun); gcc_assert (!node->global.inlined_to); - - if (node->instrumented_version - && !node->instrumentation_clone) - node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL); - return 0; } @@ -464,10 +459,6 @@ cgraph_edge::rebuild_references (void) node->record_stmt_references (gsi_stmt (gsi)); } record_eh_tables (node, cfun); - - if (node->instrumented_version - && !node->instrumentation_clone) - node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL); } namespace { diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index b2dafc669dd..04b6919be48 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -202,7 +202,6 @@ along with GCC; see the file COPYING3. If not see #include "pass_manager.h" #include "tree-nested.h" #include "dbgcnt.h" -#include "tree-chkp.h" #include "lto-section-names.h" #include "stringpool.h" #include "attribs.h" @@ -865,9 +864,6 @@ varpool_node::finalize_decl (tree decl) || (node->no_reorder && symtab->state == EXPANSION)) node->assemble_decl (); - - if (DECL_INITIAL (decl)) - chkp_register_var_initializer (decl); } /* EDGE is an polymorphic call. Mark all possible targets as reachable @@ -941,10 +937,6 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets, edge->make_direct (target); edge->redirect_call_stmt_to_callee (); - /* Call to __builtin_unreachable shouldn't be instrumented. */ - if (!targets.length ()) - gimple_call_set_with_bounds (edge->call_stmt, false); - if (symtab->dump_file) { fprintf (symtab->dump_file, @@ -1924,7 +1916,6 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs); callees->call_stmt = call; gimple_call_set_from_thunk (call, true); - gimple_call_set_with_bounds (call, instrumentation_clone); /* Return slot optimization is always possible and in fact requred to return values with DECL_BY_REFERENCE. */ @@ -1942,17 +1933,6 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) gsi_insert_after (&bsi, call, GSI_NEW_STMT); if (!alias_is_noreturn) { - if (instrumentation_clone - && !DECL_BY_REFERENCE (resdecl) - && restmp - && BOUNDED_P (restmp)) - { - resbnd = chkp_insert_retbnd_call (NULL, restmp, &bsi); - create_edge (get_create (gimple_call_fndecl (gsi_stmt (bsi))), - as_a <gcall *> (gsi_stmt (bsi)), - callees->count); - } - if (restmp && !this_adjusting && (fixed_offset || virtual_offset)) { @@ -2503,13 +2483,9 @@ void symbol_table::output_weakrefs (void) { symtab_node *node; - cgraph_node *cnode; FOR_EACH_SYMBOL (node) if (node->alias && !TREE_ASM_WRITTEN (node->decl) - && (!(cnode = dyn_cast <cgraph_node *> (node)) - || !cnode->instrumented_version - || !TREE_ASM_WRITTEN (cnode->instrumented_version->decl)) && node->weakref) { tree target; diff --git a/gcc/chkp-builtins.def b/gcc/chkp-builtins.def deleted file mode 100644 index 559391446bb..00000000000 --- a/gcc/chkp-builtins.def +++ /dev/null @@ -1,71 +0,0 @@ -/* This file contains the definitions and documentation for the - builtins used in the GNU compiler. - Copyright (C) 2013-2018 Free Software Foundation, Inc. - -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/>. */ - -/* Before including this file, you should define macros: - - DEF_BUILTIN_STUB(ENUM, NAME) - DEF_CHKP_BUILTIN(ENUM, NAME, TYPE, ATTRS) - - See builtins.def for details. */ - -/* Following builtins are used by compiler for Pointer Bounds Checker - instrumentation. Currently these generic builtins are not - implemented and target has to provide his own version. See - builtin_chkp_function target hook documentation for more details. */ -DEF_BUILTIN_STUB (BUILT_IN_CHKP_INTERSECT, "__chkp_intersect") -DEF_BUILTIN_STUB (BUILT_IN_CHKP_SIZEOF, "__chkp_sizeof") -DEF_BUILTIN_STUB (BUILT_IN_CHKP_NARROW, "__chkp_narrow") -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDCL, "__chkp_bndcl", BT_FN_VOID_PTR_BND, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDCU, "__chkp_bndcu", BT_FN_VOID_PTR_BND, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDSTX, "__chkp_bndstx", BT_FN_VOID_CONST_PTR_BND_CONST_PTR, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDLDX, "__chkp_bndldx", BT_FN_CONST_PTR_CONST_PTR_CONST_PTR, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDRET, "__chkp_bndret", BT_FN_BND_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BNDMK, "__chkp_bndmk", BT_FN_BND_CONST_PTR_SIZE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_EXTRACT_LOWER, "__chkp_extract_lower", BT_FN_CONST_PTR_BND, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_EXTRACT_UPPER, "__chkp_extract_upper", BT_FN_CONST_PTR_BND, ATTR_CONST_NOTHROW_LEAF_LIST) - -/* Pointer Bounds Checker builtins for users. - All builtins calls are expanded in the - Pointer Bounds Checker pass. */ -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_SET_PTR_BOUNDS, "__bnd_set_ptr_bounds", BT_FN_PTR_CONST_PTR_SIZE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_INIT_PTR_BOUNDS, "__bnd_init_ptr_bounds", BT_FN_PTR_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_NULL_PTR_BOUNDS, "__bnd_null_ptr_bounds", BT_FN_PTR_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_COPY_PTR_BOUNDS, "__bnd_copy_ptr_bounds", BT_FN_PTR_CONST_PTR_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_NARROW_PTR_BOUNDS, "__bnd_narrow_ptr_bounds", BT_FN_PTR_CONST_PTR_CONST_PTR_SIZE, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_STORE_PTR_BOUNDS, "__bnd_store_ptr_bounds", BT_FN_VOID_PTRPTR_CONST_PTR, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_CHECK_PTR_LBOUNDS, "__bnd_chk_ptr_lbounds", BT_FN_VOID_CONST_PTR, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_CHECK_PTR_UBOUNDS, "__bnd_chk_ptr_ubounds", BT_FN_VOID_CONST_PTR, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_CHECK_PTR_BOUNDS, "__bnd_chk_ptr_bounds", BT_FN_VOID_CONST_PTR_SIZE, ATTR_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_GET_PTR_LBOUND, "__bnd_get_ptr_lbound", BT_FN_CONST_PTR_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_GET_PTR_UBOUND, "__bnd_get_ptr_ubound", BT_FN_CONST_PTR_CONST_PTR, ATTR_CONST_NOTHROW_LEAF_LIST) - -/* Pointer Bounds Checker specific versions of string functions. */ -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMCPY_NOBND, "chkp_memcpy_nobnd", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMCPY_NOCHK, "chkp_memcpy_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK, "chkp_memcpy_nobnd_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMMOVE_NOBND, "chkp_memmove_nobnd", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMMOVE_NOCHK, "chkp_memmove_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMMOVE_NOBND_NOCHK, "chkp_memmove_nobnd_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMPCPY_NOBND, "chkp_mempcpy_nobnd", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMPCPY_NOCHK, "chkp_mempcpy_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK, "chkp_mempcpy_nobnd_nochk", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMSET_NOBND, "chkp_memset_nobnd", BT_FN_PTR_PTR_INT_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMSET_NOCHK, "chkp_memset_nochk", BT_FN_PTR_PTR_INT_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) -DEF_CHKP_BUILTIN (BUILT_IN_CHKP_MEMSET_NOBND_NOCHK, "chkp_memset_nobnd_nochk", BT_FN_PTR_PTR_INT_SIZE, ATTR_RET1_NOTHROW_NONNULL_LEAF) diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index 3aa32f5934b..664240e7e8d 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -273,7 +273,7 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA2_AVX512F_UNSET \ (OPTION_MASK_ISA_AVX5124FMAPS_UNSET | OPTION_MASK_ISA_AVX5124VNNIW_UNSET) #define OPTION_MASK_ISA2_GENERAL_REGS_ONLY_UNSET \ - (OPTION_MASK_ISA2_AVX512F_UNSET | OPTION_MASK_ISA_MPX) + (OPTION_MASK_ISA2_AVX512F_UNSET) /* Implement TARGET_HANDLE_OPTION. */ @@ -291,7 +291,7 @@ ix86_handle_option (struct gcc_options *opts, case OPT_mgeneral_regs_only: if (value) { - /* Disable MPX, MMX, SSE and x87 instructions if only + /* Disable MMX, SSE and x87 instructions if only general registers are allowed. */ opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_GENERAL_REGS_ONLY_UNSET; diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index 51f0f518632..132365743e1 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -94,9 +94,6 @@ (define_register_constraint "v" "TARGET_SSE ? ALL_SSE_REGS : NO_REGS" "Any EVEX encodable SSE register (@code{%xmm0-%xmm31}).") -(define_register_constraint "w" "TARGET_MPX ? BND_REGS : NO_REGS" - "@internal Any bound register.") - ;; We use the Y prefix to denote any number of conditional register sets: ;; z First SSE register. ;; d any EVEX encodable SSE register for AVX512BW target or @@ -319,11 +316,3 @@ (define_address_constraint "Ts" "Address operand without segment register" (match_operand 0 "address_no_seg_operand")) - -(define_address_constraint "Ti" - "MPX address operand without index" - (match_operand 0 "address_mpx_no_index_operand")) - -(define_address_constraint "Tb" - "MPX address operand without base" - (match_operand 0 "address_mpx_no_base_operand")) diff --git a/gcc/config/i386/i386-builtin-types.def b/gcc/config/i386/i386-builtin-types.def index 6a75415d1fd..886cf1b6ecc 100644 --- a/gcc/config/i386/i386-builtin-types.def +++ b/gcc/config/i386/i386-builtin-types.def @@ -47,7 +47,6 @@ DEF_PRIMITIVE_TYPE (UCHAR, unsigned_char_type_node) DEF_PRIMITIVE_TYPE (QI, char_type_node) DEF_PRIMITIVE_TYPE (HI, intHI_type_node) DEF_PRIMITIVE_TYPE (SI, intSI_type_node) -DEF_PRIMITIVE_TYPE (BND, pointer_bounds_type_node) # ??? Logically this should be intDI_type_node, but that maps to "long" # with 64-bit, and that's not how the emmintrin.h is written. Again, # changing this would change name mangling. @@ -1208,17 +1207,6 @@ DEF_FUNCTION_TYPE_ALIAS (V4SF_FTYPE_V4SF_V4SF, TF) DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V4SI_V4SI, TF) DEF_FUNCTION_TYPE_ALIAS (V8HI_FTYPE_V8HI_V8HI, TF) -# MPX builtins -DEF_FUNCTION_TYPE (BND, PCVOID, ULONG) -DEF_FUNCTION_TYPE (VOID, PCVOID, BND) -DEF_FUNCTION_TYPE (VOID, PCVOID, BND, PCVOID) -DEF_FUNCTION_TYPE (BND, PCVOID, PCVOID) -DEF_FUNCTION_TYPE (BND, PCVOID) -DEF_FUNCTION_TYPE (BND, BND, BND) -DEF_FUNCTION_TYPE (PVOID, PCVOID, BND, ULONG) -DEF_FUNCTION_TYPE (ULONG, VOID) -DEF_FUNCTION_TYPE (PVOID, BND) - #GFNI builtins DEF_FUNCTION_TYPE (V64QI, V64QI, V64QI, INT) DEF_FUNCTION_TYPE (V64QI, V64QI, V64QI, INT, V64QI, UDI) diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def index 14041293795..383f9cc890c 100644 --- a/gcc/config/i386/i386-builtin.def +++ b/gcc/config/i386/i386-builtin.def @@ -2847,29 +2847,7 @@ BDESC_FIRST (special_args2, SPECIAL_ARGS2, OPTION_MASK_ISA_WBNOINVD, CODE_FOR_wbnoinvd, "__builtin_ia32_wbnoinvd", IX86_BUILTIN_WBNOINVD, UNKNOWN, (int) VOID_FTYPE_VOID) BDESC (OPTION_MASK_ISA_MOVDIR64B, CODE_FOR_nothing, "__builtin_ia32_movdir64b", IX86_BUILTIN_MOVDIR64B, UNKNOWN, (int) VOID_FTYPE_PVOID_PCVOID) -BDESC_END (SPECIAL_ARGS2, MPX) - - -/* Builtins for MPX. */ -BDESC_FIRST (mpx, MPX, - OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndstx", IX86_BUILTIN_BNDSTX, UNKNOWN, (int) VOID_FTYPE_PCVOID_BND_PCVOID) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndcl", IX86_BUILTIN_BNDCL, UNKNOWN, (int) VOID_FTYPE_PCVOID_BND) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndcu", IX86_BUILTIN_BNDCU, UNKNOWN, (int) VOID_FTYPE_PCVOID_BND) - -BDESC_END (MPX, MPX_CONST) - -/* Const builtins for MPX. */ -BDESC_FIRST (mpx_const, MPX_CONST, - OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndmk", IX86_BUILTIN_BNDMK, UNKNOWN, (int) BND_FTYPE_PCVOID_ULONG) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndldx", IX86_BUILTIN_BNDLDX, UNKNOWN, (int) BND_FTYPE_PCVOID_PCVOID) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_narrow_bounds", IX86_BUILTIN_BNDNARROW, UNKNOWN, (int) PVOID_FTYPE_PCVOID_BND_ULONG) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndint", IX86_BUILTIN_BNDINT, UNKNOWN, (int) BND_FTYPE_BND_BND) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_sizeof", IX86_BUILTIN_SIZEOF, UNKNOWN, (int) ULONG_FTYPE_VOID) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndlower", IX86_BUILTIN_BNDLOWER, UNKNOWN, (int) PVOID_FTYPE_BND) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndupper", IX86_BUILTIN_BNDUPPER, UNKNOWN, (int) PVOID_FTYPE_BND) -BDESC (OPTION_MASK_ISA_MPX, (enum insn_code)0, "__builtin_ia32_bndret", IX86_BUILTIN_BNDRET, UNKNOWN, (int) BND_FTYPE_PCVOID) - -BDESC_END (MPX_CONST, MULTI_ARG) +BDESC_END (SPECIAL_ARGS2, MULTI_ARG) /* FMA4 and XOP. */ BDESC_FIRST (multi_arg, MULTI_ARG, diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c index 8996a8531a7..005e1a5b308 100644 --- a/gcc/config/i386/i386-c.c +++ b/gcc/config/i386/i386-c.c @@ -508,8 +508,6 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag, def_or_undef (parse_in, "__XSAVEC__"); if (isa_flag & OPTION_MASK_ISA_XSAVES) def_or_undef (parse_in, "__XSAVES__"); - if (isa_flag2 & OPTION_MASK_ISA_MPX) - def_or_undef (parse_in, "__MPX__"); if (isa_flag & OPTION_MASK_ISA_CLWB) def_or_undef (parse_in, "__CLWB__"); if (isa_flag2 & OPTION_MASK_ISA_MWAITX) diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 02991a55509..d1d59633dc0 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -232,8 +232,6 @@ extern void ix86_expand_sse2_mulv4si3 (rtx, rtx, rtx); extern void ix86_expand_sse2_mulvxdi3 (rtx, rtx, rtx); extern void ix86_expand_sse2_abs (rtx, rtx); -extern bool ix86_bnd_prefixed_insn_p (rtx); - /* In i386-c.c */ extern void ix86_target_macros (void); extern void ix86_register_pragmas (void); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b95f0612562..de32377efb3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -73,8 +73,6 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "rtl-iter.h" #include "tree-iterator.h" -#include "tree-chkp.h" -#include "rtl-chkp.h" #include "dbgcnt.h" #include "case-cfn-macros.h" #include "regrename.h" @@ -263,8 +261,6 @@ enum reg_class const regclass_map[FIRST_PSEUDO_REGISTER] = /* Mask registers. */ MASK_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, MASK_EVEX_REGS, - /* MPX bound registers */ - BND_REGS, BND_REGS, BND_REGS, BND_REGS, }; /* The "default" register map used in 32bit mode. */ @@ -2765,7 +2761,6 @@ ix86_target_string (HOST_WIDE_INT isa, HOST_WIDE_INT isa2, static struct ix86_target_opts isa2_opts[] = { { "-mcx16", OPTION_MASK_ISA_CX16 }, - { "-mmpx", OPTION_MASK_ISA_MPX }, { "-mvaes", OPTION_MASK_ISA_VAES }, { "-mrdpid", OPTION_MASK_ISA_RDPID }, { "-mpconfig", OPTION_MASK_ISA_PCONFIG }, @@ -3433,7 +3428,7 @@ ix86_option_override_internal (bool main_args_p, const wide_int_bitmask PTA_AVX512ER (HOST_WIDE_INT_1U << 41); const wide_int_bitmask PTA_AVX512PF (HOST_WIDE_INT_1U << 42); const wide_int_bitmask PTA_AVX512CD (HOST_WIDE_INT_1U << 43); - const wide_int_bitmask PTA_MPX (HOST_WIDE_INT_1U << 44); + /* Hole after PTA_MPX was removed. */ const wide_int_bitmask PTA_SHA (HOST_WIDE_INT_1U << 45); const wide_int_bitmask PTA_PREFETCHWT1 (HOST_WIDE_INT_1U << 46); const wide_int_bitmask PTA_CLFLUSHOPT (HOST_WIDE_INT_1U << 47); @@ -4135,9 +4130,6 @@ ix86_option_override_internal (bool main_args_p, if (((processor_alias_table[i].flags & PTA_AVX512VL) != 0) && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512VL)) opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VL; - if (((processor_alias_table[i].flags & PTA_MPX) != 0) - && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_MPX)) - opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_MPX; if (((processor_alias_table[i].flags & PTA_AVX512VBMI) != 0) && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512VBMI)) opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VBMI; @@ -4213,12 +4205,6 @@ ix86_option_override_internal (bool main_args_p, break; } - if (TARGET_X32 && (opts->x_ix86_isa_flags2 & OPTION_MASK_ISA_MPX)) - error ("Intel MPX does not support x32"); - - if (TARGET_X32 && (ix86_isa_flags2 & OPTION_MASK_ISA_MPX)) - error ("Intel MPX does not support x32"); - if (i == pta_size) { error (main_args_p @@ -5054,11 +5040,6 @@ ix86_conditional_register_usage (void) for (i = FIRST_MASK_REG; i <= LAST_MASK_REG; i++) fixed_regs[i] = call_used_regs[i] = 1, reg_names[i] = ""; } - - /* If MPX is disabled, squash the registers. */ - if (! TARGET_MPX) - for (i = FIRST_BND_REG; i <= LAST_BND_REG; i++) - fixed_regs[i] = call_used_regs[i] = 1, reg_names[i] = ""; } /* Canonicalize a comparison from one we don't have to one we do have. */ @@ -5392,7 +5373,6 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], IX86_ATTR_ISA ("lwp", OPT_mlwp), IX86_ATTR_ISA ("hle", OPT_mhle), IX86_ATTR_ISA ("fxsr", OPT_mfxsr), - IX86_ATTR_ISA ("mpx", OPT_mmpx), IX86_ATTR_ISA ("clwb", OPT_mclwb), IX86_ATTR_ISA ("rdpid", OPT_mrdpid), IX86_ATTR_ISA ("gfni", OPT_mgfni), @@ -5925,16 +5905,6 @@ ix86_set_indirect_branch_type (tree fndecl) ((cfun->machine->indirect_branch_type == indirect_branch_thunk_extern) ? "thunk-extern" : "thunk")); - - /* -mindirect-branch=thunk-extern, -fcf-protection=branch and - -fcheck-pointer-bounds are not compatible. */ - if ((cfun->machine->indirect_branch_type - == indirect_branch_thunk_extern) - && flag_check_pointer_bounds - && (flag_cf_protection & CF_BRANCH) != 0) - error ("%<-mindirect-branch=thunk-extern%>, " - "%<-fcf-protection=branch%> and " - "%<-fcheck-pointer-bounds%> are not compatible"); } if (cfun->machine->function_return_type == indirect_branch_unset) @@ -6050,12 +6020,10 @@ ix86_set_current_function (tree fndecl) if (cfun->machine->func_type != TYPE_NORMAL || cfun->machine->no_caller_saved_registers) { - /* Don't allow MPX, SSE, MMX nor x87 instructions since they + /* Don't allow SSE, MMX nor x87 instructions since they may change processor state. */ const char *isa; - if (TARGET_MPX) - isa = "MPX"; - else if (TARGET_SSE) + if (TARGET_SSE) isa = "SSE"; else if (TARGET_MMX) isa = "MMX/3Dnow"; @@ -7049,9 +7017,6 @@ ix86_function_arg_regno_p (int regno) enum calling_abi call_abi; const int *parm_regs; - if (TARGET_MPX && BND_REGNO_P (regno)) - return true; - if (!TARGET_64BIT) { if (TARGET_MACHO) @@ -7396,9 +7361,6 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, /* Argument info to initialize */ ? (!prototype_p (fntype) || stdarg_p (fntype)) : !libname); - cum->bnd_regno = FIRST_BND_REG; - cum->bnds_in_bt = 0; - cum->force_bnd_pass = 0; cum->decl = fndecl; cum->warn_empty = !warn_abi || cum->stdarg; @@ -8571,36 +8533,6 @@ ix86_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, if (type) mode = type_natural_mode (type, NULL, false); - if ((type && POINTER_BOUNDS_TYPE_P (type)) - || POINTER_BOUNDS_MODE_P (mode)) - { - /* If we pass bounds in BT then just update remained bounds count. */ - if (cum->bnds_in_bt) - { - cum->bnds_in_bt--; - return; - } - - /* Update remained number of bounds to force. */ - if (cum->force_bnd_pass) - cum->force_bnd_pass--; - - cum->bnd_regno++; - - return; - } - - /* The first arg not going to Bounds Tables resets this counter. */ - cum->bnds_in_bt = 0; - /* For unnamed args we always pass bounds to avoid bounds mess when - passed and received types do not match. If bounds do not follow - unnamed arg, still pretend required number of bounds were passed. */ - if (cum->force_bnd_pass) - { - cum->bnd_regno += cum->force_bnd_pass; - cum->force_bnd_pass = 0; - } - if (TARGET_64BIT) { enum calling_abi call_abi = cum ? cum->call_abi : ix86_abi; @@ -8613,10 +8545,6 @@ ix86_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, else nregs = function_arg_advance_32 (cum, mode, type, bytes, words); - /* For stdarg we expect bounds to be passed for each value passed - in register. */ - if (cum->stdarg) - cum->force_bnd_pass = nregs; /* For pointers passed in memory we expect bounds passed in Bounds Table. */ if (!nregs) @@ -8624,9 +8552,6 @@ ix86_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, /* Track if there are outgoing arguments on stack. */ if (cum->caller) cfun->machine->outgoing_args_on_stack = true; - - if (flag_check_pointer_bounds) - cum->bnds_in_bt = chkp_type_bounds_count (type); } } @@ -8914,23 +8839,6 @@ ix86_function_arg (cumulative_args_t cum_v, machine_mode omode, return arg; } - /* All pointer bounds arguments are handled separately here. */ - if ((type && POINTER_BOUNDS_TYPE_P (type)) - || POINTER_BOUNDS_MODE_P (mode)) - { - /* Return NULL if bounds are forced to go in Bounds Table. */ - if (cum->bnds_in_bt) - arg = NULL; - /* Return the next available bound reg if any. */ - else if (cum->bnd_regno <= LAST_BND_REG) - arg = gen_rtx_REG (BNDmode, cum->bnd_regno); - /* Return the next special slot number otherwise. */ - else - arg = GEN_INT (cum->bnd_regno - LAST_BND_REG - 1); - - return arg; - } - if (mode == BLKmode) bytes = int_size_in_bytes (type); else @@ -8973,11 +8881,6 @@ ix86_pass_by_reference (cumulative_args_t cum_v, machine_mode mode, { CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); - /* Bounds are never passed by reference. */ - if ((type && POINTER_BOUNDS_TYPE_P (type)) - || POINTER_BOUNDS_MODE_P (mode)) - return false; - if (TARGET_64BIT) { enum calling_abi call_abi = cum ? cum->call_abi : ix86_abi; @@ -9221,10 +9124,6 @@ ix86_function_value_regno_p (const unsigned int regno) case SI_REG: return TARGET_64BIT && ix86_cfun_abi () != MS_ABI; - case BND0_REG: - case BND1_REG: - return chkp_function_instrumented_p (current_function_decl); - /* Complex values are returned in %st(0)/%st(1) pair. */ case ST0_REG: case ST1_REG: @@ -9408,10 +9307,7 @@ ix86_function_value_1 (const_tree valtype, const_tree fntype_or_decl, fn = fntype_or_decl; fntype = fn ? TREE_TYPE (fn) : fntype_or_decl; - if ((valtype && POINTER_BOUNDS_TYPE_P (valtype)) - || POINTER_BOUNDS_MODE_P (mode)) - return gen_rtx_REG (BNDmode, FIRST_BND_REG); - else if (TARGET_64BIT && ix86_function_type_abi (fntype) == MS_ABI) + if (TARGET_64BIT && ix86_function_type_abi (fntype) == MS_ABI) return function_value_ms_64 (orig_mode, mode, valtype); else if (TARGET_64BIT) return function_value_64 (orig_mode, mode, valtype); @@ -9429,57 +9325,6 @@ ix86_function_value (const_tree valtype, const_tree fntype_or_decl, bool) return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode); } -/* Return an RTX representing a place where a function returns - or recieves pointer bounds or NULL if no bounds are returned. - - VALTYPE is a data type of a value returned by the function. - - FN_DECL_OR_TYPE is a tree node representing FUNCTION_DECL - or FUNCTION_TYPE of the function. - - If OUTGOING is false, return a place in which the caller will - see the return value. Otherwise, return a place where a - function returns a value. */ - -static rtx -ix86_function_value_bounds (const_tree valtype, - const_tree fntype_or_decl ATTRIBUTE_UNUSED, - bool outgoing ATTRIBUTE_UNUSED) -{ - rtx res = NULL_RTX; - - if (BOUNDED_TYPE_P (valtype)) - res = gen_rtx_REG (BNDmode, FIRST_BND_REG); - else if (chkp_type_has_pointer (valtype)) - { - bitmap slots; - rtx bounds[2]; - bitmap_iterator bi; - unsigned i, bnd_no = 0; - - bitmap_obstack_initialize (NULL); - slots = BITMAP_ALLOC (NULL); - chkp_find_bound_slots (valtype, slots); - - EXECUTE_IF_SET_IN_BITMAP (slots, 0, i, bi) - { - rtx reg = gen_rtx_REG (BNDmode, FIRST_BND_REG + bnd_no); - rtx offs = GEN_INT (i * POINTER_SIZE / BITS_PER_UNIT); - gcc_assert (bnd_no < 2); - bounds[bnd_no++] = gen_rtx_EXPR_LIST (VOIDmode, reg, offs); - } - - res = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (bnd_no, bounds)); - - BITMAP_FREE (slots); - bitmap_obstack_release (NULL); - } - else - res = NULL_RTX; - - return res; -} - /* Pointer function arguments and return values are promoted to word_mode for normal functions. */ @@ -9528,9 +9373,6 @@ ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) const machine_mode mode = type_natural_mode (type, NULL, true); HOST_WIDE_INT size; - if (POINTER_BOUNDS_TYPE_P (type)) - return false; - if (TARGET_64BIT) { if (ix86_function_type_abi (fntype) == MS_ABI) @@ -9858,8 +9700,7 @@ ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v, CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); CUMULATIVE_ARGS next_cum; tree fntype; - rtx save_area; - int bnd_reg, i, max; + int max; gcc_assert (!no_rtl); @@ -9875,40 +9716,10 @@ ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v, if (stdarg_p (fntype)) ix86_function_arg_advance (pack_cumulative_args (&next_cum), mode, type, true); - save_area = frame_pointer_rtx; max = cum->regno + cfun->va_list_gpr_size / UNITS_PER_WORD; if (max > X86_64_REGPARM_MAX) max = X86_64_REGPARM_MAX; - - bnd_reg = cum->bnd_regno + cum->force_bnd_pass; - if (chkp_function_instrumented_p (current_function_decl)) - for (i = cum->regno; i < max; i++) - { - rtx addr = plus_constant (Pmode, save_area, i * UNITS_PER_WORD); - rtx ptr = gen_rtx_REG (Pmode, - x86_64_int_parameter_registers[i]); - rtx bounds; - - if (bnd_reg <= LAST_BND_REG) - bounds = gen_rtx_REG (BNDmode, bnd_reg); - else - { - rtx ldx_addr = - plus_constant (Pmode, arg_pointer_rtx, - (LAST_BND_REG - bnd_reg) * GET_MODE_SIZE (Pmode)); - bounds = gen_reg_rtx (BNDmode); - emit_insn (BNDmode == BND64mode - ? gen_bnd64_ldx (bounds, ldx_addr, ptr) - : gen_bnd32_ldx (bounds, ldx_addr, ptr)); - } - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_stx (addr, ptr, bounds) - : gen_bnd32_stx (addr, ptr, bounds)); - - bnd_reg++; - } } @@ -9986,13 +9797,6 @@ ix86_va_start (tree valist, rtx nextarg) crtl->args.arg_offset_rtx, NULL_RTX, 0, OPTAB_LIB_WIDEN); convert_move (va_r, next, 0); - - /* Store zero bounds for va_list. */ - if (chkp_function_instrumented_p (current_function_decl)) - chkp_expand_bounds_reset_for_mem (valist, - make_tree (TREE_TYPE (valist), - next)); - } return; } @@ -10047,10 +9851,6 @@ ix86_va_start (tree valist, rtx nextarg) if (words != 0) t = fold_build_pointer_plus_hwi (t, words * UNITS_PER_WORD); - /* Store zero bounds for overflow area pointer. */ - if (chkp_function_instrumented_p (current_function_decl)) - chkp_expand_bounds_reset_for_mem (ovf, t); - t = build2 (MODIFY_EXPR, type, ovf, t); TREE_SIDE_EFFECTS (t) = 1; expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); @@ -10064,10 +9864,6 @@ ix86_va_start (tree valist, rtx nextarg) if (!ix86_varargs_gpr_size) t = fold_build_pointer_plus_hwi (t, -8 * X86_64_REGPARM_MAX); - /* Store zero bounds for save area pointer. */ - if (chkp_function_instrumented_p (current_function_decl)) - chkp_expand_bounds_reset_for_mem (sav, t); - t = build2 (MODIFY_EXPR, type, sav, t); TREE_SIDE_EFFECTS (t) = 1; expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); @@ -10869,9 +10665,7 @@ enum indirect_thunk_prefix indirect_thunk_need_prefix (rtx_insn *insn) { enum indirect_thunk_prefix need_prefix; - if (ix86_bnd_prefixed_insn_p (insn)) - need_prefix = indirect_thunk_prefix_bnd; - else if ((cfun->machine->indirect_branch_type + if ((cfun->machine->indirect_branch_type == indirect_branch_thunk_extern) && ix86_notrack_prefixed_insn_p (insn)) { @@ -18086,7 +17880,7 @@ print_reg (rtx x, int code, FILE *file) ; -- print a semicolon (after prefixes due to bug in older gas). ~ -- print "i" if TARGET_AVX2, "f" otherwise. ^ -- print addr32 prefix if TARGET_64BIT and Pmode != word_mode - ! -- print MPX prefix for jxx/call/ret instructions if required. + ! -- print NOTRACK prefix for jxx/call/ret instructions if required. */ void @@ -18639,8 +18433,6 @@ ix86_print_operand (FILE *file, rtx x, int code) return; case '!': - if (ix86_bnd_prefixed_insn_p (current_output_insn)) - fputs ("bnd ", file); if (ix86_notrack_prefixed_insn_p (current_output_insn)) fputs ("notrack ", file); return; @@ -28595,30 +28387,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1, call = gen_rtx_CALL (VOIDmode, fnaddr, callarg1); if (retval) - { - /* We should add bounds as destination register in case - pointer with bounds may be returned. */ - if (TARGET_MPX && SCALAR_INT_MODE_P (GET_MODE (retval))) - { - rtx b0 = gen_rtx_REG (BND64mode, FIRST_BND_REG); - rtx b1 = gen_rtx_REG (BND64mode, FIRST_BND_REG + 1); - if (GET_CODE (retval) == PARALLEL) - { - b0 = gen_rtx_EXPR_LIST (VOIDmode, b0, const0_rtx); - b1 = gen_rtx_EXPR_LIST (VOIDmode, b1, const0_rtx); - rtx par = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, b0, b1)); - retval = chkp_join_splitted_slot (retval, par); - } - else - { - retval = gen_rtx_PARALLEL (VOIDmode, - gen_rtvec (3, retval, b0, b1)); - chkp_put_regs_to_expr_list (retval); - } - } - - call = gen_rtx_SET (retval, call); - } + call = gen_rtx_SET (retval, call); vec[vec_len++] = call; if (pop) @@ -29034,7 +28803,7 @@ ix86_output_function_return (bool long_p) return ""; } - if (!long_p || ix86_bnd_prefixed_insn_p (current_output_insn)) + if (!long_p) return "%!ret"; return "rep%; ret"; @@ -29348,8 +29117,6 @@ reg_encoded_number (rtx reg) return regno - FIRST_REX_INT_REG; if (IN_RANGE (regno, FIRST_MASK_REG, LAST_MASK_REG)) return regno - FIRST_MASK_REG; - if (IN_RANGE (regno, FIRST_BND_REG, LAST_BND_REG)) - return regno - FIRST_BND_REG; return -1; } @@ -31297,12 +31064,8 @@ BDESC_VERIFYS (IX86_BUILTIN__BDESC_ARGS2_FIRST, IX86_BUILTIN__BDESC_ROUND_ARGS_LAST, 1); BDESC_VERIFYS (IX86_BUILTIN__BDESC_SPECIAL_ARGS2_FIRST, IX86_BUILTIN__BDESC_ARGS2_LAST, 1); -BDESC_VERIFYS (IX86_BUILTIN__BDESC_MPX_FIRST, - IX86_BUILTIN__BDESC_SPECIAL_ARGS2_LAST, 1); -BDESC_VERIFYS (IX86_BUILTIN__BDESC_MPX_CONST_FIRST, - IX86_BUILTIN__BDESC_MPX_LAST, 1); BDESC_VERIFYS (IX86_BUILTIN__BDESC_MULTI_ARG_FIRST, - IX86_BUILTIN__BDESC_MPX_CONST_LAST, 1); + IX86_BUILTIN__BDESC_SPECIAL_ARGS2_LAST, 1); BDESC_VERIFYS (IX86_BUILTIN__BDESC_CET_FIRST, IX86_BUILTIN__BDESC_MULTI_ARG_LAST, 1); BDESC_VERIFYS (IX86_BUILTIN__BDESC_CET_NORMAL_FIRST, @@ -32051,74 +31814,6 @@ ix86_init_mmx_sse_builtins (void) ARRAY_SIZE (bdesc_cet_rdssp) - 1); } -static void -ix86_init_mpx_builtins () -{ - const struct builtin_description * d; - enum ix86_builtin_func_type ftype; - tree decl; - size_t i; - - for (i = 0, d = bdesc_mpx; - i < ARRAY_SIZE (bdesc_mpx); - i++, d++) - { - BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_MPX_FIRST, i); - if (d->name == 0) - continue; - - ftype = (enum ix86_builtin_func_type) d->flag; - decl = def_builtin2 (d->mask, d->name, ftype, d->code); - - /* With no leaf and nothrow flags for MPX builtins - abnormal edges may follow its call when setjmp - presents in the function. Since we may have a lot - of MPX builtins calls it causes lots of useless - edges and enormous PHI nodes. To avoid this we mark - MPX builtins as leaf and nothrow. */ - if (decl) - { - DECL_ATTRIBUTES (decl) = build_tree_list (get_identifier ("leaf"), - NULL_TREE); - TREE_NOTHROW (decl) = 1; - } - else - { - ix86_builtins_isa[(int)d->code].leaf_p = true; - ix86_builtins_isa[(int)d->code].nothrow_p = true; - } - } - BDESC_VERIFYS (IX86_BUILTIN__BDESC_MPX_LAST, - IX86_BUILTIN__BDESC_MPX_FIRST, - ARRAY_SIZE (bdesc_mpx) - 1); - - for (i = 0, d = bdesc_mpx_const; - i < ARRAY_SIZE (bdesc_mpx_const); - i++, d++) - { - BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_MPX_CONST_FIRST, i); - if (d->name == 0) - continue; - - ftype = (enum ix86_builtin_func_type) d->flag; - decl = def_builtin_const2 (d->mask, d->name, ftype, d->code); - - if (decl) - { - DECL_ATTRIBUTES (decl) = build_tree_list (get_identifier ("leaf"), - NULL_TREE); - TREE_NOTHROW (decl) = 1; - } - else - { - ix86_builtins_isa[(int)d->code].leaf_p = true; - ix86_builtins_isa[(int)d->code].nothrow_p = true; - } - } - BDESC_VERIFYS (IX86_BUILTIN__BDESC_MPX_CONST_LAST, - IX86_BUILTIN__BDESC_MPX_CONST_FIRST, - ARRAY_SIZE (bdesc_mpx_const) - 1); -} #undef BDESC_VERIFY #undef BDESC_VERIFYS @@ -34350,7 +34045,6 @@ ix86_init_builtins (void) ix86_init_tm_builtins (); ix86_init_mmx_sse_builtins (); - ix86_init_mpx_builtins (); if (TARGET_LP64) ix86_init_builtins_va_builtins_abi (); @@ -37032,36 +36726,6 @@ ix86_expand_vec_set_builtin (tree exp) return target; } -/* Emit conditional move of SRC to DST with condition - OP1 CODE OP2. */ -static void -ix86_emit_cmove (rtx dst, rtx src, enum rtx_code code, rtx op1, rtx op2) -{ - rtx t; - - if (TARGET_CMOVE) - { - t = ix86_expand_compare (code, op1, op2); - emit_insn (gen_rtx_SET (dst, gen_rtx_IF_THEN_ELSE (GET_MODE (dst), t, - src, dst))); - } - else - { - rtx_code_label *nomove = gen_label_rtx (); - emit_cmp_and_jump_insns (op1, op2, reverse_condition (code), - const0_rtx, GET_MODE (op1), 1, nomove); - emit_move_insn (dst, src); - emit_label (nomove); - } -} - -/* Choose max of DST and SRC and put it to DST. */ -static void -ix86_emit_move_max (rtx dst, rtx src) -{ - ix86_emit_cmove (dst, src, LTU, dst, src); -} - /* Expand an expression EXP that calls a built-in function, with result going to TARGET if that's convenient (and in mode MODE if that's convenient). @@ -37143,342 +36807,6 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, switch (fcode) { - case IX86_BUILTIN_BNDMK: - if (!target - || GET_MODE (target) != BNDmode - || !register_operand (target, BNDmode)) - target = gen_reg_rtx (BNDmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - - if (!register_operand (op0, Pmode)) - op0 = ix86_zero_extend_to_Pmode (op0); - if (!register_operand (op1, Pmode)) - op1 = ix86_zero_extend_to_Pmode (op1); - - /* Builtin arg1 is size of block but instruction op1 should - be (size - 1). */ - op1 = expand_simple_binop (Pmode, PLUS, op1, constm1_rtx, - NULL_RTX, 1, OPTAB_DIRECT); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_mk (target, op0, op1) - : gen_bnd32_mk (target, op0, op1)); - return target; - - case IX86_BUILTIN_BNDSTX: - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - arg2 = CALL_EXPR_ARG (exp, 2); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - op2 = expand_normal (arg2); - - if (!register_operand (op0, Pmode)) - op0 = ix86_zero_extend_to_Pmode (op0); - if (!register_operand (op1, BNDmode)) - op1 = copy_to_mode_reg (BNDmode, op1); - if (!register_operand (op2, Pmode)) - op2 = ix86_zero_extend_to_Pmode (op2); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_stx (op2, op0, op1) - : gen_bnd32_stx (op2, op0, op1)); - return 0; - - case IX86_BUILTIN_BNDLDX: - if (!target - || GET_MODE (target) != BNDmode - || !register_operand (target, BNDmode)) - target = gen_reg_rtx (BNDmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - - if (!register_operand (op0, Pmode)) - op0 = ix86_zero_extend_to_Pmode (op0); - if (!register_operand (op1, Pmode)) - op1 = ix86_zero_extend_to_Pmode (op1); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_ldx (target, op0, op1) - : gen_bnd32_ldx (target, op0, op1)); - return target; - - case IX86_BUILTIN_BNDCL: - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - - if (!register_operand (op0, Pmode)) - op0 = ix86_zero_extend_to_Pmode (op0); - if (!register_operand (op1, BNDmode)) - op1 = copy_to_mode_reg (BNDmode, op1); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_cl (op1, op0) - : gen_bnd32_cl (op1, op0)); - return 0; - - case IX86_BUILTIN_BNDCU: - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - - if (!register_operand (op0, Pmode)) - op0 = ix86_zero_extend_to_Pmode (op0); - if (!register_operand (op1, BNDmode)) - op1 = copy_to_mode_reg (BNDmode, op1); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_cu (op1, op0) - : gen_bnd32_cu (op1, op0)); - return 0; - - case IX86_BUILTIN_BNDRET: - arg0 = CALL_EXPR_ARG (exp, 0); - target = chkp_get_rtl_bounds (arg0); - - /* If no bounds were specified for returned value, - then use INIT bounds. It usually happens when - some built-in function is expanded. */ - if (!target) - { - rtx t1 = gen_reg_rtx (Pmode); - rtx t2 = gen_reg_rtx (Pmode); - target = gen_reg_rtx (BNDmode); - emit_move_insn (t1, const0_rtx); - emit_move_insn (t2, constm1_rtx); - emit_insn (BNDmode == BND64mode - ? gen_bnd64_mk (target, t1, t2) - : gen_bnd32_mk (target, t1, t2)); - } - - gcc_assert (target && REG_P (target)); - return target; - - case IX86_BUILTIN_BNDNARROW: - { - rtx m1, m1h1, m1h2, lb, ub, t1; - - /* Return value and lb. */ - arg0 = CALL_EXPR_ARG (exp, 0); - /* Bounds. */ - arg1 = CALL_EXPR_ARG (exp, 1); - /* Size. */ - arg2 = CALL_EXPR_ARG (exp, 2); - - lb = expand_normal (arg0); - op1 = expand_normal (arg1); - op2 = expand_normal (arg2); - - /* Size was passed but we need to use (size - 1) as for bndmk. */ - op2 = expand_simple_binop (Pmode, PLUS, op2, constm1_rtx, - NULL_RTX, 1, OPTAB_DIRECT); - - /* Add LB to size and inverse to get UB. */ - op2 = expand_simple_binop (Pmode, PLUS, op2, lb, - op2, 1, OPTAB_DIRECT); - ub = expand_simple_unop (Pmode, NOT, op2, op2, 1); - - if (!register_operand (lb, Pmode)) - lb = ix86_zero_extend_to_Pmode (lb); - if (!register_operand (ub, Pmode)) - ub = ix86_zero_extend_to_Pmode (ub); - - /* We need to move bounds to memory before any computations. */ - if (MEM_P (op1)) - m1 = op1; - else - { - m1 = assign_386_stack_local (BNDmode, SLOT_TEMP); - emit_move_insn (m1, op1); - } - - /* Generate mem expression to be used for access to LB and UB. */ - m1h1 = adjust_address (m1, Pmode, 0); - m1h2 = adjust_address (m1, Pmode, GET_MODE_SIZE (Pmode)); - - t1 = gen_reg_rtx (Pmode); - - /* Compute LB. */ - emit_move_insn (t1, m1h1); - ix86_emit_move_max (t1, lb); - emit_move_insn (m1h1, t1); - - /* Compute UB. UB is stored in 1's complement form. Therefore - we also use max here. */ - emit_move_insn (t1, m1h2); - ix86_emit_move_max (t1, ub); - emit_move_insn (m1h2, t1); - - op2 = gen_reg_rtx (BNDmode); - emit_move_insn (op2, m1); - - return chkp_join_splitted_slot (lb, op2); - } - - case IX86_BUILTIN_BNDINT: - { - rtx res, rh1, rh2, lb1, lb2, ub1, ub2; - - if (!target - || GET_MODE (target) != BNDmode - || !register_operand (target, BNDmode)) - target = gen_reg_rtx (BNDmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - arg1 = CALL_EXPR_ARG (exp, 1); - - op0 = expand_normal (arg0); - op1 = expand_normal (arg1); - - res = assign_386_stack_local (BNDmode, SLOT_TEMP); - rh1 = adjust_address (res, Pmode, 0); - rh2 = adjust_address (res, Pmode, GET_MODE_SIZE (Pmode)); - - /* Put first bounds to temporaries. */ - lb1 = gen_reg_rtx (Pmode); - ub1 = gen_reg_rtx (Pmode); - if (MEM_P (op0)) - { - emit_move_insn (lb1, adjust_address (op0, Pmode, 0)); - emit_move_insn (ub1, adjust_address (op0, Pmode, - GET_MODE_SIZE (Pmode))); - } - else - { - emit_move_insn (res, op0); - emit_move_insn (lb1, rh1); - emit_move_insn (ub1, rh2); - } - - /* Put second bounds to temporaries. */ - lb2 = gen_reg_rtx (Pmode); - ub2 = gen_reg_rtx (Pmode); - if (MEM_P (op1)) - { - emit_move_insn (lb2, adjust_address (op1, Pmode, 0)); - emit_move_insn (ub2, adjust_address (op1, Pmode, - GET_MODE_SIZE (Pmode))); - } - else - { - emit_move_insn (res, op1); - emit_move_insn (lb2, rh1); - emit_move_insn (ub2, rh2); - } - - /* Compute LB. */ - ix86_emit_move_max (lb1, lb2); - emit_move_insn (rh1, lb1); - - /* Compute UB. UB is stored in 1's complement form. Therefore - we also use max here. */ - ix86_emit_move_max (ub1, ub2); - emit_move_insn (rh2, ub1); - - emit_move_insn (target, res); - - return target; - } - - case IX86_BUILTIN_SIZEOF: - { - tree name; - rtx symbol; - - if (!target - || GET_MODE (target) != Pmode - || !register_operand (target, Pmode)) - target = gen_reg_rtx (Pmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - gcc_assert (VAR_P (arg0)); - - name = DECL_ASSEMBLER_NAME (arg0); - symbol = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (name)); - - emit_insn (Pmode == SImode - ? gen_move_size_reloc_si (target, symbol) - : gen_move_size_reloc_di (target, symbol)); - - return target; - } - - case IX86_BUILTIN_BNDLOWER: - { - rtx mem, hmem; - - if (!target - || GET_MODE (target) != Pmode - || !register_operand (target, Pmode)) - target = gen_reg_rtx (Pmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - op0 = expand_normal (arg0); - - /* We need to move bounds to memory first. */ - if (MEM_P (op0)) - mem = op0; - else - { - mem = assign_386_stack_local (BNDmode, SLOT_TEMP); - emit_move_insn (mem, op0); - } - - /* Generate mem expression to access LB and load it. */ - hmem = adjust_address (mem, Pmode, 0); - emit_move_insn (target, hmem); - - return target; - } - - case IX86_BUILTIN_BNDUPPER: - { - rtx mem, hmem, res; - - if (!target - || GET_MODE (target) != Pmode - || !register_operand (target, Pmode)) - target = gen_reg_rtx (Pmode); - - arg0 = CALL_EXPR_ARG (exp, 0); - op0 = expand_normal (arg0); - - /* We need to move bounds to memory first. */ - if (MEM_P (op0)) - mem = op0; - else - { - mem = assign_386_stack_local (BNDmode, SLOT_TEMP); - emit_move_insn (mem, op0); - } - - /* Generate mem expression to access UB. */ - hmem = adjust_address (mem, Pmode, GET_MODE_SIZE (Pmode)); - - /* We need to inverse all bits of UB. */ - res = expand_simple_unop (Pmode, NOT, hmem, target, 1); - - if (res != target) - emit_move_insn (target, res); - - return target; - } - case IX86_BUILTIN_MASKMOVQ: case IX86_BUILTIN_MASKMOVDQU: icode = (fcode == IX86_BUILTIN_MASKMOVQ @@ -39449,199 +38777,6 @@ static tree ix86_get_builtin (enum ix86_builtins code) return NULL_TREE; } -/* Return function decl for target specific builtin - for given MPX builtin passed i FCODE. */ -static tree -ix86_builtin_mpx_function (unsigned fcode) -{ - switch (fcode) - { - case BUILT_IN_CHKP_BNDMK: - return ix86_builtins[IX86_BUILTIN_BNDMK]; - - case BUILT_IN_CHKP_BNDSTX: - return ix86_builtins[IX86_BUILTIN_BNDSTX]; - - case BUILT_IN_CHKP_BNDLDX: - return ix86_builtins[IX86_BUILTIN_BNDLDX]; - - case BUILT_IN_CHKP_BNDCL: - return ix86_builtins[IX86_BUILTIN_BNDCL]; - - case BUILT_IN_CHKP_BNDCU: - return ix86_builtins[IX86_BUILTIN_BNDCU]; - - case BUILT_IN_CHKP_BNDRET: - return ix86_builtins[IX86_BUILTIN_BNDRET]; - - case BUILT_IN_CHKP_INTERSECT: - return ix86_builtins[IX86_BUILTIN_BNDINT]; - - case BUILT_IN_CHKP_NARROW: - return ix86_builtins[IX86_BUILTIN_BNDNARROW]; - - case BUILT_IN_CHKP_SIZEOF: - return ix86_builtins[IX86_BUILTIN_SIZEOF]; - - case BUILT_IN_CHKP_EXTRACT_LOWER: - return ix86_builtins[IX86_BUILTIN_BNDLOWER]; - - case BUILT_IN_CHKP_EXTRACT_UPPER: - return ix86_builtins[IX86_BUILTIN_BNDUPPER]; - - default: - return NULL_TREE; - } - - gcc_unreachable (); -} - -/* Helper function for ix86_load_bounds and ix86_store_bounds. - - Return an address to be used to load/store bounds for pointer - passed in SLOT. - - SLOT_NO is an integer constant holding number of a target - dependent special slot to be used in case SLOT is not a memory. - - SPECIAL_BASE is a pointer to be used as a base of fake address - to access special slots in Bounds Table. SPECIAL_BASE[-1], - SPECIAL_BASE[-2] etc. will be used as fake pointer locations. */ - -static rtx -ix86_get_arg_address_for_bt (rtx slot, rtx slot_no, rtx special_base) -{ - rtx addr = NULL; - - /* NULL slot means we pass bounds for pointer not passed to the - function at all. Register slot means we pass pointer in a - register. In both these cases bounds are passed via Bounds - Table. Since we do not have actual pointer stored in memory, - we have to use fake addresses to access Bounds Table. We - start with (special_base - sizeof (void*)) and decrease this - address by pointer size to get addresses for other slots. */ - if (!slot || REG_P (slot)) - { - gcc_assert (CONST_INT_P (slot_no)); - addr = plus_constant (Pmode, special_base, - -(INTVAL (slot_no) + 1) * GET_MODE_SIZE (Pmode)); - } - /* If pointer is passed in a memory then its address is used to - access Bounds Table. */ - else if (MEM_P (slot)) - { - addr = XEXP (slot, 0); - if (!register_operand (addr, Pmode)) - addr = copy_addr_to_reg (addr); - } - else - gcc_unreachable (); - - return addr; -} - -/* Expand pass uses this hook to load bounds for function parameter - PTR passed in SLOT in case its bounds are not passed in a register. - - If SLOT is a memory, then bounds are loaded as for regular pointer - loaded from memory. PTR may be NULL in case SLOT is a memory. - In such case value of PTR (if required) may be loaded from SLOT. - - If SLOT is NULL or a register then SLOT_NO is an integer constant - holding number of the target dependent special slot which should be - used to obtain bounds. - - Return loaded bounds. */ - -static rtx -ix86_load_bounds (rtx slot, rtx ptr, rtx slot_no) -{ - rtx reg = gen_reg_rtx (BNDmode); - rtx addr; - - /* Get address to be used to access Bounds Table. Special slots start - at the location of return address of the current function. */ - addr = ix86_get_arg_address_for_bt (slot, slot_no, arg_pointer_rtx); - - /* Load pointer value from a memory if we don't have it. */ - if (!ptr) - { - gcc_assert (MEM_P (slot)); - ptr = copy_addr_to_reg (slot); - } - - if (!register_operand (ptr, Pmode)) - ptr = ix86_zero_extend_to_Pmode (ptr); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_ldx (reg, addr, ptr) - : gen_bnd32_ldx (reg, addr, ptr)); - - return reg; -} - -/* Expand pass uses this hook to store BOUNDS for call argument PTR - passed in SLOT in case BOUNDS are not passed in a register. - - If SLOT is a memory, then BOUNDS are stored as for regular pointer - stored in memory. PTR may be NULL in case SLOT is a memory. - In such case value of PTR (if required) may be loaded from SLOT. - - If SLOT is NULL or a register then SLOT_NO is an integer constant - holding number of the target dependent special slot which should be - used to store BOUNDS. */ - -static void -ix86_store_bounds (rtx ptr, rtx slot, rtx bounds, rtx slot_no) -{ - rtx addr; - - /* Get address to be used to access Bounds Table. Special slots start - at the location of return address of a called function. */ - addr = ix86_get_arg_address_for_bt (slot, slot_no, stack_pointer_rtx); - - /* Load pointer value from a memory if we don't have it. */ - if (!ptr) - { - gcc_assert (MEM_P (slot)); - ptr = copy_addr_to_reg (slot); - } - - if (!register_operand (ptr, Pmode)) - ptr = ix86_zero_extend_to_Pmode (ptr); - - gcc_assert (POINTER_BOUNDS_MODE_P (GET_MODE (bounds))); - if (!register_operand (bounds, BNDmode)) - bounds = copy_to_mode_reg (BNDmode, bounds); - - emit_insn (BNDmode == BND64mode - ? gen_bnd64_stx (addr, ptr, bounds) - : gen_bnd32_stx (addr, ptr, bounds)); -} - -/* Load and return bounds returned by function in SLOT. */ - -static rtx -ix86_load_returned_bounds (rtx slot) -{ - rtx res; - - gcc_assert (REG_P (slot)); - res = gen_reg_rtx (BNDmode); - emit_move_insn (res, slot); - - return res; -} - -/* Store BOUNDS returned by function into SLOT. */ - -static void -ix86_store_returned_bounds (rtx slot, rtx bounds) -{ - gcc_assert (REG_P (slot)); - emit_move_insn (slot, bounds); -} - /* Returns a function decl for a vectorized version of the combined function with combined_fn code FN and the result vector type TYPE, or NULL_TREE if it is not available. */ @@ -40656,7 +39791,6 @@ ix86_class_likely_spilled_p (reg_class_t rclass) case SSE_FIRST_REG: case FP_TOP_REG: case FP_SECOND_REG: - case BND_REGS: return true; default: @@ -41066,8 +40200,6 @@ ix86_hard_regno_mode_ok (unsigned int regno, machine_mode mode) return (VALID_MASK_REG_MODE (mode) || (TARGET_AVX512BW && VALID_MASK_AVX512BW_MODE (mode))); - if (BND_REGNO_P (regno)) - return VALID_BND_REG_MODE (mode); if (SSE_REGNO_P (regno)) { /* We implement the move patterns for all vector modes into and @@ -42064,10 +41196,6 @@ x86_order_regs_for_local_alloc (void) for (i = FIRST_MASK_REG; i <= LAST_MASK_REG; i++) reg_alloc_order [pos++] = i; - /* MPX bound registers. */ - for (i = FIRST_BND_REG; i <= LAST_BND_REG; i++) - reg_alloc_order [pos++] = i; - /* x87 registers. */ if (TARGET_SSE_MATH) for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++) @@ -43088,7 +42216,6 @@ ix86_mitigate_rop (void) set_rop_modrm_reg_bits (FIRST_REX_SSE_REG, input_risky, output_risky); set_rop_modrm_reg_bits (FIRST_EXT_REX_SSE_REG, input_risky, output_risky); set_rop_modrm_reg_bits (FIRST_MASK_REG, input_risky, output_risky); - set_rop_modrm_reg_bits (FIRST_BND_REG, input_risky, output_risky); COPY_HARD_REG_SET (inout_risky, input_risky); IOR_HARD_REG_SET (inout_risky, output_risky); @@ -50417,27 +49544,6 @@ ix86_expand_sse2_mulvxdi3 (rtx op0, rtx op1, rtx op2) } /* Return 1 if control tansfer instruction INSN - should be encoded with bnd prefix. - If insn is NULL then return 1 when control - transfer instructions should be prefixed with - bnd by default for current function. */ - -bool -ix86_bnd_prefixed_insn_p (rtx insn) -{ - /* For call insns check special flag. */ - if (insn && CALL_P (insn)) - { - rtx call = get_call_rtx_from (insn); - if (call) - return CALL_EXPR_WITH_BOUNDS_P (call); - } - - /* All other insns are prefixed only if function is instrumented. */ - return chkp_function_instrumented_p (current_function_decl); -} - -/* Return 1 if control tansfer instruction INSN should be encoded with notrack prefix. */ static bool @@ -51744,73 +50850,6 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) atomic_feraiseexcept_call); } -/* Return mode to be used for bounds or VOIDmode - if bounds are not supported. */ - -static machine_mode -ix86_mpx_bound_mode () -{ - /* Do not support pointer checker if MPX - is not enabled. */ - if (!TARGET_MPX) - { - if (flag_check_pointer_bounds) - warning (0, "Pointer Checker requires MPX support on this target." - " Use -mmpx options to enable MPX."); - return VOIDmode; - } - - return BNDmode; -} - -/* Return constant used to statically initialize constant bounds. - - This function is used to create special bound values. For now - only INIT bounds and NONE bounds are expected. More special - values may be added later. */ - -static tree -ix86_make_bounds_constant (HOST_WIDE_INT lb, HOST_WIDE_INT ub) -{ - tree low = lb ? build_minus_one_cst (pointer_sized_int_node) - : build_zero_cst (pointer_sized_int_node); - tree high = ub ? build_zero_cst (pointer_sized_int_node) - : build_minus_one_cst (pointer_sized_int_node); - - /* This function is supposed to be used to create INIT and - NONE bounds only. */ - gcc_assert ((lb == 0 && ub == -1) - || (lb == -1 && ub == 0)); - - return build_complex (NULL, low, high); -} - -/* Generate a list of statements STMTS to initialize pointer bounds - variable VAR with bounds LB and UB. Return the number of generated - statements. */ - -static int -ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts) -{ - tree bnd_ptr = build_pointer_type (pointer_sized_int_node); - tree lhs, modify, var_p; - - ub = build1 (BIT_NOT_EXPR, pointer_sized_int_node, ub); - var_p = fold_convert (bnd_ptr, build_fold_addr_expr (var)); - - lhs = build1 (INDIRECT_REF, pointer_sized_int_node, var_p); - modify = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, lb); - append_to_statement_list (modify, stmts); - - lhs = build1 (INDIRECT_REF, pointer_sized_int_node, - build2 (POINTER_PLUS_EXPR, bnd_ptr, var_p, - TYPE_SIZE_UNIT (pointer_sized_int_node))); - modify = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, ub); - append_to_statement_list (modify, stmts); - - return 2; -} - #if !TARGET_MACHO && !TARGET_DLLIMPORT_DECL_ATTRIBUTES /* For i386, common symbol is local only for non-PIE binaries. For x86-64, common symbol is local only for non-PIE binaries or linker @@ -52790,33 +51829,6 @@ ix86_run_selftests (void) #undef TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS #define TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS true -#undef TARGET_LOAD_BOUNDS_FOR_ARG -#define TARGET_LOAD_BOUNDS_FOR_ARG ix86_load_bounds - -#undef TARGET_STORE_BOUNDS_FOR_ARG -#define TARGET_STORE_BOUNDS_FOR_ARG ix86_store_bounds - -#undef TARGET_LOAD_RETURNED_BOUNDS -#define TARGET_LOAD_RETURNED_BOUNDS ix86_load_returned_bounds - -#undef TARGET_STORE_RETURNED_BOUNDS -#define TARGET_STORE_RETURNED_BOUNDS ix86_store_returned_bounds - -#undef TARGET_CHKP_BOUND_MODE -#define TARGET_CHKP_BOUND_MODE ix86_mpx_bound_mode - -#undef TARGET_BUILTIN_CHKP_FUNCTION -#define TARGET_BUILTIN_CHKP_FUNCTION ix86_builtin_mpx_function - -#undef TARGET_CHKP_FUNCTION_VALUE_BOUNDS -#define TARGET_CHKP_FUNCTION_VALUE_BOUNDS ix86_function_value_bounds - -#undef TARGET_CHKP_MAKE_BOUNDS_CONSTANT -#define TARGET_CHKP_MAKE_BOUNDS_CONSTANT ix86_make_bounds_constant - -#undef TARGET_CHKP_INITIALIZE_BOUNDS -#define TARGET_CHKP_INITIALIZE_BOUNDS ix86_initialize_bounds - #undef TARGET_SETUP_INCOMING_VARARG_BOUNDS #define TARGET_SETUP_INCOMING_VARARG_BOUNDS ix86_setup_incoming_vararg_bounds diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 05255dc2c9e..049760efe34 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -175,8 +175,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_XSAVEOPT_P(x) TARGET_ISA_XSAVEOPT_P(x) #define TARGET_PREFETCHWT1 TARGET_ISA_PREFETCHWT1 #define TARGET_PREFETCHWT1_P(x) TARGET_ISA_PREFETCHWT1_P(x) -#define TARGET_MPX TARGET_ISA_MPX -#define TARGET_MPX_P(x) TARGET_ISA_MPX_P(x) #define TARGET_CLWB TARGET_ISA_CLWB #define TARGET_CLWB_P(x) TARGET_ISA_CLWB_P(x) #define TARGET_MWAITX TARGET_ISA_MWAITX @@ -1157,9 +1155,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define VALID_MASK_AVX512BW_MODE(MODE) ((MODE) == SImode || (MODE) == DImode) -#define VALID_BND_REG_MODE(MODE) \ - (TARGET_64BIT ? (MODE) == BND64mode : (MODE) == BND32mode) - #define VALID_DFP_MODE_P(MODE) \ ((MODE) == SDmode || (MODE) == DDmode || (MODE) == TDmode) @@ -1261,9 +1256,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define FIRST_MASK_REG MASK0_REG #define LAST_MASK_REG MASK7_REG -#define FIRST_BND_REG BND0_REG -#define LAST_BND_REG BND3_REG - /* Override this in other tm.h files to cope with various OS lossage requiring a frame pointer. */ #ifndef SUBTARGET_FRAME_POINTER_REQUIRED @@ -1345,7 +1337,6 @@ enum reg_class NO_REX_SSE_REGS, SSE_REGS, EVEX_SSE_REGS, - BND_REGS, ALL_SSE_REGS, MMX_REGS, FP_TOP_SSE_REGS, @@ -1408,7 +1399,6 @@ enum reg_class "NO_REX_SSE_REGS", \ "SSE_REGS", \ "EVEX_SSE_REGS", \ - "BND_REGS", \ "ALL_SSE_REGS", \ "MMX_REGS", \ "FP_TOP_SSE_REGS", \ @@ -1451,7 +1441,6 @@ enum reg_class { 0x1fe00000, 0x000000, 0x0 }, /* NO_REX_SSE_REGS */ \ { 0x1fe00000, 0x1fe000, 0x0 }, /* SSE_REGS */ \ { 0x0,0xffe00000, 0x1f }, /* EVEX_SSE_REGS */ \ - { 0x0, 0x0,0x1e000 }, /* BND_REGS */ \ { 0x1fe00000,0xffffe000, 0x1f }, /* ALL_SSE_REGS */ \ { 0xe0000000, 0x1f, 0x0 }, /* MMX_REGS */ \ { 0x1fe00100,0xffffe000, 0x1f }, /* FP_TOP_SSE_REG */ \ @@ -1526,9 +1515,6 @@ enum reg_class #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X))) #define CC_REGNO_P(X) ((X) == FLAGS_REG || (X) == FPSR_REG) -#define BND_REG_P(X) (REG_P (X) && BND_REGNO_P (REGNO (X))) -#define BND_REGNO_P(N) IN_RANGE ((N), FIRST_BND_REG, LAST_BND_REG) - #define MOD4_SSE_REG_P(X) (REG_P (X) && MOD4_SSE_REGNO_P (REGNO (X))) #define MOD4_SSE_REGNO_P(N) ((N) == XMM0_REG \ || (N) == XMM4_REG \ @@ -1670,9 +1656,6 @@ typedef struct ix86_args { int float_in_sse; /* Set to 1 or 2 for 32bit targets if SFmode/DFmode arguments should be passed in SSE registers. Otherwise 0. */ - int bnd_regno; /* next available bnd register number */ - int bnds_in_bt; /* number of bounds expected in BT. */ - int force_bnd_pass; /* number of bounds expected for stdarg arg. */ int stdarg; /* Set to 1 if function is stdarg. */ enum calling_abi call_abi; /* Set to SYSV_ABI for sysv abi. Otherwise MS_ABI for ms abi. */ @@ -1964,9 +1947,6 @@ do { \ #define STACK_SAVEAREA_MODE(LEVEL) \ ((LEVEL) == SAVE_NONLOCAL ? (TARGET_64BIT ? TImode : DImode) : Pmode) -/* Specify the machine mode that bounds have. */ -#define BNDmode (ix86_pmode == PMODE_DI ? BND64mode : BND32mode) - /* A C expression whose value is zero if pointers that need to be extended from being `POINTER_SIZE' bits wide to `Pmode' are sign-extended and greater then zero if they are zero-extended and less then zero if the @@ -2257,15 +2237,6 @@ extern int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER]; /* Default threshold for putting data in large sections with x86-64 medium memory model */ #define DEFAULT_LARGE_SECTION_THRESHOLD 65536 - -/* Adjust the length of the insn with the length of BND prefix. */ - -#define ADJUST_INSN_LENGTH(INSN, LENGTH) \ -do { \ - if (NONDEBUG_INSN_P (INSN) && INSN_CODE (INSN) >= 0 \ - && get_attr_maybe_prefix_bnd (INSN)) \ - LENGTH += ix86_bnd_prefixed_insn_p (INSN); \ -} while (0) /* Which processor to tune code generation for. These must be in sync with processor_target_table in i386.c. */ diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index f1948468db5..eb77ef3c08f 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -62,7 +62,7 @@ ;; ; -- print a semicolon (after prefixes due to bug in older gas). ;; ~ -- print "i" if TARGET_AVX2, "f" otherwise. ;; ^ -- print addr32 prefix if TARGET_64BIT and Pmode != word_mode -;; ! -- print MPX or NOTRACK prefix for jxx/call/ret instructions if required. +;; ! -- print NOTRACK prefix for jxx/call/ret instructions if required. (define_c_enum "unspec" [ ;; Relocation specifiers @@ -550,9 +550,6 @@ (const_int 0) (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF")) (const_int 1) - (and (eq_attr "type" "ibr,call,callv") - (match_test "ix86_bnd_prefixed_insn_p (insn)")) - (const_int 1) ] (const_int 0))) @@ -596,9 +593,6 @@ ] (const_int 0))) -;; Set when BND opcode prefix may be used. -(define_attr "maybe_prefix_bnd" "" (const_int 0)) - ;; Prefix used: original, VEX or maybe VEX. (define_attr "prefix" "orig,vex,maybe_vex,evex,maybe_evex" (cond [(eq_attr "mode" "OI,V8SF,V4DF") @@ -1074,17 +1068,6 @@ (define_mode_iterator BND [(BND32 "!TARGET_LP64") (BND64 "TARGET_LP64")]) -;; Pointer mode corresponding to bound mode. -(define_mode_attr bnd_ptr [(BND32 "SI") (BND64 "DI")]) - -;; MPX check types -(define_int_iterator BNDCHECK [UNSPEC_BNDCL UNSPEC_BNDCU UNSPEC_BNDCN]) - -;; Check name -(define_int_attr bndcheck [(UNSPEC_BNDCL "cl") - (UNSPEC_BNDCU "cu") - (UNSPEC_BNDCN "cn")]) - ;; Instruction suffix for integer modes. (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")]) @@ -12601,8 +12584,7 @@ (lt (minus (match_dup 0) (pc)) (const_int 128))) (const_int 2) - (const_int 6))) - (set_attr "maybe_prefix_bnd" "1")]) + (const_int 6)))]) ;; In general it is not safe to assume too much about CCmode registers, ;; so simplify-rtx stops when it sees a second one. Under certain @@ -12670,8 +12652,7 @@ (lt (minus (match_dup 0) (pc)) (const_int 128))) (const_int 2) - (const_int 5))) - (set_attr "maybe_prefix_bnd" "1")]) + (const_int 5)))]) (define_expand "indirect_jump" [(set (pc) (match_operand 0 "indirect_branch_operand"))] @@ -12691,8 +12672,7 @@ != indirect_branch_keep)") (const_string "multi") (const_string "ibr"))) - (set_attr "length_immediate" "0") - (set_attr "maybe_prefix_bnd" "1")]) + (set_attr "length_immediate" "0")]) (define_expand "tablejump" [(parallel [(set (pc) (match_operand 0 "indirect_branch_operand")) @@ -12746,8 +12726,7 @@ != indirect_branch_keep)") (const_string "multi") (const_string "ibr"))) - (set_attr "length_immediate" "0") - (set_attr "maybe_prefix_bnd" "1")]) + (set_attr "length_immediate" "0")]) ;; Convert setcc + movzbl to xor + setcc if operands don't overlap. @@ -13444,8 +13423,7 @@ [(set_attr "length" "1") (set_attr "atom_unit" "jeu") (set_attr "length_immediate" "0") - (set_attr "modrm" "0") - (set_attr "maybe_prefix_bnd" "1")]) + (set_attr "modrm" "0")]) (define_insn "interrupt_return" [(simple_return) @@ -13480,8 +13458,7 @@ [(set_attr "length" "3") (set_attr "atom_unit" "jeu") (set_attr "length_immediate" "2") - (set_attr "modrm" "0") - (set_attr "maybe_prefix_bnd" "1")]) + (set_attr "modrm" "0")]) (define_expand "simple_return_indirect_internal" [(parallel @@ -13498,8 +13475,7 @@ != indirect_branch_keep)") (const_string "multi") (const_string "ibr"))) - (set_attr "length_immediate" "0") - (set_attr "maybe_prefix_bnd" "1")]) + (set_attr "length_immediate" "0")]) (define_insn "nop" [(const_int 0)] @@ -20844,161 +20820,6 @@ [(set_attr "length" "3") (set_attr "memory" "unknown")]) -;; MPX instructions - -(define_expand "<mode>_mk" - [(set (match_operand:BND 0 "register_operand") - (unspec:BND - [(mem:<bnd_ptr> - (match_par_dup 3 - [(match_operand:<bnd_ptr> 1 "register_operand") - (match_operand:<bnd_ptr> 2 "address_mpx_no_base_operand")]))] - UNSPEC_BNDMK))] - "TARGET_MPX" -{ - operands[3] = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[1], - operands[2]), - UNSPEC_BNDMK_ADDR); -}) - -(define_insn "*<mode>_mk" - [(set (match_operand:BND 0 "register_operand" "=w") - (unspec:BND - [(match_operator:<bnd_ptr> 3 "bnd_mem_operator" - [(unspec:<bnd_ptr> - [(match_operand:<bnd_ptr> 1 "register_operand" "r") - (match_operand:<bnd_ptr> 2 "address_mpx_no_base_operand" "Tb")] - UNSPEC_BNDMK_ADDR)])] - UNSPEC_BNDMK))] - "TARGET_MPX" - "bndmk\t{%3, %0|%0, %3}" - [(set_attr "type" "mpxmk")]) - -(define_expand "mov<mode>" - [(set (match_operand:BND 0 "general_operand") - (match_operand:BND 1 "general_operand"))] - "TARGET_MPX" - "ix86_expand_move (<MODE>mode, operands); DONE;") - -(define_insn "*mov<mode>_internal_mpx" - [(set (match_operand:BND 0 "nonimmediate_operand" "=w,m") - (match_operand:BND 1 "general_operand" "wm,w"))] - "TARGET_MPX" - "bndmov\t{%1, %0|%0, %1}" - [(set_attr "type" "mpxmov")]) - -(define_expand "<mode>_<bndcheck>" - [(parallel - [(unspec - [(match_operand:BND 0 "register_operand") - (match_operand:<bnd_ptr> 1 "address_no_seg_operand")] BNDCHECK) - (set (match_dup 2) - (unspec:BLK [(match_dup 2)] UNSPEC_MPX_FENCE))])] - "TARGET_MPX" -{ - operands[2] = gen_rtx_MEM (BLKmode, operands[1]); - MEM_VOLATILE_P (operands[2]) = 1; -}) - -(define_insn "*<mode>_<bndcheck>" - [(unspec - [(match_operand:BND 0 "register_operand" "w") - (match_operand:<bnd_ptr> 1 "address_no_seg_operand" "Ts")] BNDCHECK) - (set (match_operand:BLK 2 "bnd_mem_operator") - (unspec:BLK [(match_dup 2)] UNSPEC_MPX_FENCE))] - "TARGET_MPX" - "bnd<bndcheck>\t{%a1, %0|%0, %a1}" - [(set_attr "type" "mpxchk")]) - -(define_expand "<mode>_ldx" - [(parallel - [(set (match_operand:BND 0 "register_operand") - (unspec:BND - [(mem:<bnd_ptr> - (match_par_dup 3 - [(match_operand:<bnd_ptr> 1 "address_mpx_no_index_operand") - (match_operand:<bnd_ptr> 2 "register_operand")]))] - UNSPEC_BNDLDX)) - (use (mem:BLK (match_dup 1)))])] - "TARGET_MPX" -{ - /* Avoid registers which cannot be used as index. */ - if (!index_register_operand (operands[2], Pmode)) - operands[2] = copy_addr_to_reg (operands[2]); - - operands[3] = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[1], - operands[2]), - UNSPEC_BNDLDX_ADDR); -}) - -(define_insn "*<mode>_ldx" - [(set (match_operand:BND 0 "register_operand" "=w") - (unspec:BND - [(match_operator:<bnd_ptr> 3 "bnd_mem_operator" - [(unspec:<bnd_ptr> - [(match_operand:<bnd_ptr> 1 "address_mpx_no_index_operand" "Ti") - (match_operand:<bnd_ptr> 2 "register_operand" "l")] - UNSPEC_BNDLDX_ADDR)])] - UNSPEC_BNDLDX)) - (use (mem:BLK (match_dup 1)))] - "TARGET_MPX" - "bndldx\t{%3, %0|%0, %3}" - [(set_attr "type" "mpxld")]) - -(define_expand "<mode>_stx" - [(parallel - [(unspec - [(mem:<bnd_ptr> - (match_par_dup 3 - [(match_operand:<bnd_ptr> 0 "address_mpx_no_index_operand") - (match_operand:<bnd_ptr> 1 "register_operand")])) - (match_operand:BND 2 "register_operand")] - UNSPEC_BNDSTX) - (set (match_dup 4) - (unspec:BLK [(match_dup 4)] UNSPEC_MPX_FENCE))])] - "TARGET_MPX" -{ - /* Avoid registers which cannot be used as index. */ - if (!index_register_operand (operands[1], Pmode)) - operands[1] = copy_addr_to_reg (operands[1]); - - operands[3] = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[0], - operands[1]), - UNSPEC_BNDLDX_ADDR); - operands[4] = gen_rtx_MEM (BLKmode, operands[0]); - MEM_VOLATILE_P (operands[4]) = 1; -}) - -(define_insn "*<mode>_stx" - [(unspec - [(match_operator:<bnd_ptr> 3 "bnd_mem_operator" - [(unspec:<bnd_ptr> - [(match_operand:<bnd_ptr> 0 "address_mpx_no_index_operand" "Ti") - (match_operand:<bnd_ptr> 1 "register_operand" "l")] - UNSPEC_BNDLDX_ADDR)]) - (match_operand:BND 2 "register_operand" "w")] - UNSPEC_BNDSTX) - (set (match_operand:BLK 4 "bnd_mem_operator") - (unspec:BLK [(match_dup 4)] UNSPEC_MPX_FENCE))] - "TARGET_MPX" - "bndstx\t{%2, %3|%3, %2}" - [(set_attr "type" "mpxst")]) - -(define_insn "move_size_reloc_<mode>" - [(set (match_operand:SWI48 0 "register_operand" "=r") - (unspec:SWI48 - [(match_operand:SWI48 1 "symbol_operand")] - UNSPEC_SIZEOF))] - "TARGET_MPX" -{ - if (x86_64_immediate_size_operand (operands[1], VOIDmode)) - return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}"; - else - return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}"; -} - [(set_attr "type" "imov") - (set_attr "mode" "<MODE>")]) - ;; RDPKRU and WRPKRU (define_expand "rdpkru" diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 58d097371d8..01a0385dfa4 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -951,8 +951,8 @@ Target Report Mask(ISA_RTM) Var(ix86_isa_flags) Save Support RTM built-in functions and code generation. mmpx -Target Report Mask(ISA_MPX) Var(ix86_isa_flags2) Save -Support MPX code generation. +Target Report +Deprecated in GCC 9. This switch has no effect. mmwaitx Target Report Mask(ISA_MWAITX) Var(ix86_isa_flags2) Save diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index d877387021b..3eeb66c1618 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -54,31 +54,6 @@ along with GCC; see the file COPYING3. If not see GNU_USER_TARGET_MATHFILE_SPEC " " \ ANDROID_ENDFILE_SPEC) -#ifndef LIBMPX_LIBS -#define LIBMPX_LIBS "\ - %:include(libmpx.spec)%(link_libmpx)" -#endif - -#ifndef LINK_MPX -#if defined (HAVE_LD_BNDPLT_SUPPORT) -#define LINK_MPX "-z bndplt " -#else -#define LINK_MPX \ - "%nGCC was configured with a linker with no '-z bndplt' support. " \ - "It significantly reduces MPX coverage for dynamic codes. " \ - "It is strongly recommended to use GCC properly configured for MPX." -#endif -#endif - -#ifndef MPX_SPEC -#ifdef SPEC_64 -#define MPX_SPEC "\ - %{mmpx:%{fcheck-pointer-bounds:%{!static:%{" SPEC_64 ":" LINK_MPX "}}}}" -#else -#define MPX_SPEC "" -#endif -#endif - #ifdef HAVE_LD_PUSHPOPSTATE_SUPPORT #define MPX_LD_AS_NEEDED_GUARD_PUSH "--push-state --no-as-needed" #define MPX_LD_AS_NEEDED_GUARD_POP "--pop-state" @@ -87,41 +62,6 @@ along with GCC; see the file COPYING3. If not see #define MPX_LD_AS_NEEDED_GUARD_POP "" #endif -#ifndef LIBMPX_SPEC -#if defined(HAVE_LD_STATIC_DYNAMIC) -#define LIBMPX_SPEC "\ -%{mmpx:%{fcheck-pointer-bounds:\ - %{static:--whole-archive -lmpx --no-whole-archive" LIBMPX_LIBS "}\ - %{!static:%{static-libmpx:" LD_STATIC_OPTION " --whole-archive}\ - %{!static-libmpx:" MPX_LD_AS_NEEDED_GUARD_PUSH "} -lmpx \ - %{!static-libmpx:" MPX_LD_AS_NEEDED_GUARD_POP "} \ - %{static-libmpx:--no-whole-archive " LD_DYNAMIC_OPTION \ - LIBMPX_LIBS "}}}}" -#else -#define LIBMPX_SPEC "\ -%{mmpx:%{fcheck-pointer-bounds:-lmpx" LIBMPX_LIBS "}}" -#endif -#endif - -#ifndef LIBMPXWRAPPERS_SPEC -#if defined(HAVE_LD_STATIC_DYNAMIC) -#define LIBMPXWRAPPERS_SPEC "\ -%{mmpx:%{fcheck-pointer-bounds:%{!fno-chkp-use-wrappers:\ - %{static:-lmpxwrappers}\ - %{!static:%{static-libmpxwrappers:" LD_STATIC_OPTION "}\ - -lmpxwrappers %{static-libmpxwrappers: "\ - LD_DYNAMIC_OPTION "}}}}}" -#else -#define LIBMPXWRAPPERS_SPEC "\ -%{mmpx:%{fcheck-pointer-bounds:{!fno-chkp-use-wrappers:-lmpxwrappers}}}" -#endif -#endif - -#ifndef CHKP_SPEC -#define CHKP_SPEC "\ -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC -#endif - extern void file_end_indicate_exec_stack_and_cet (void); #undef TARGET_ASM_FILE_END diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index f6cdc86fc5f..babaf1d9433 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1132,68 +1132,6 @@ return true; }) -;; Return true if op is valid MPX address operand without base -(define_predicate "address_mpx_no_base_operand" - (match_test "address_operand (op, VOIDmode)") -{ - struct ix86_address parts; - int ok; - - ok = ix86_decompose_address (op, &parts); - gcc_assert (ok); - - if (parts.index && parts.base) - return false; - - if (parts.seg != ADDR_SPACE_GENERIC) - return false; - - /* Do not support (%rip). */ - if (parts.disp && flag_pic && TARGET_64BIT - && SYMBOLIC_CONST (parts.disp)) - { - if (GET_CODE (parts.disp) != CONST - || GET_CODE (XEXP (parts.disp, 0)) != PLUS - || GET_CODE (XEXP (XEXP (parts.disp, 0), 0)) != UNSPEC - || !CONST_INT_P (XEXP (XEXP (parts.disp, 0), 1)) - || (XINT (XEXP (XEXP (parts.disp, 0), 0), 1) != UNSPEC_DTPOFF - && XINT (XEXP (XEXP (parts.disp, 0), 0), 1) != UNSPEC_NTPOFF)) - return false; - } - - return true; -}) - -;; Return true if op is valid MPX address operand without index -(define_predicate "address_mpx_no_index_operand" - (match_test "address_operand (op, VOIDmode)") -{ - struct ix86_address parts; - int ok; - - ok = ix86_decompose_address (op, &parts); - gcc_assert (ok); - - if (parts.index) - return false; - - if (parts.seg != ADDR_SPACE_GENERIC) - return false; - - /* Do not support (%rip). */ - if (parts.disp && flag_pic && TARGET_64BIT - && SYMBOLIC_CONST (parts.disp) - && (GET_CODE (parts.disp) != CONST - || GET_CODE (XEXP (parts.disp, 0)) != PLUS - || GET_CODE (XEXP (XEXP (parts.disp, 0), 0)) != UNSPEC - || !CONST_INT_P (XEXP (XEXP (parts.disp, 0), 1)) - || (XINT (XEXP (XEXP (parts.disp, 0), 0), 1) != UNSPEC_DTPOFF - && XINT (XEXP (XEXP (parts.disp, 0), 0), 1) != UNSPEC_NTPOFF))) - return false; - - return true; -}) - (define_predicate "vsib_mem_operator" (match_code "mem")) diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 81575369224..459b7c2806f 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -2379,10 +2379,6 @@ dbxout_type (tree type, int full) dbxout_type (TREE_TYPE (type), 0); break; - case POINTER_BOUNDS_TYPE: - /* No debug info for pointer bounds type supported yet. */ - break; - default: /* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM named 'auto' in its type. diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 3e6c98a554a..e0a84b8b3c5 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -84,7 +84,6 @@ extensions, accepted by GCC in C90 mode and in C++. * x86 specific memory model extensions for transactional memory:: x86 memory models. * Object Size Checking:: Built-in functions for limited buffer overflow checking. -* Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker. * Other Builtins:: Other built-in functions. * Target Builtins:: Built-in functions specific to particular targets. * Target Format Checks:: Format checks specific to particular targets. @@ -2465,19 +2464,6 @@ declares that @code{my_alloc1} returns 16-byte aligned pointer and that @code{my_alloc2} returns a pointer whose value modulo 32 is equal to 8. -@item bnd_instrument -@cindex @code{bnd_instrument} function attribute -The @code{bnd_instrument} attribute on functions is used to inform the -compiler that the function should be instrumented when compiled -with the @option{-fchkp-instrument-marked-only} option. - -@item bnd_legacy -@cindex @code{bnd_legacy} function attribute -@cindex Pointer Bounds Checker attributes -The @code{bnd_legacy} attribute on functions is used to inform the -compiler that the function should not be instrumented when compiled -with the @option{-fcheck-pointer-bounds} option. - @item cold @cindex @code{cold} function attribute The @code{cold} attribute on functions is used to inform the compiler that @@ -5589,7 +5575,7 @@ caller-saved registers. That is, all registers are callee-saved. For example, this attribute can be used for a function called from an interrupt handler. The compiler generates proper function entry and exit sequences to save and restore any modified registers, except for -the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87 +the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87 states, the GCC option @option{-mgeneral-regs-only} should be used to compile functions with @code{no_caller_saved_registers} attribute. @@ -5603,7 +5589,7 @@ this attribute is present. The @code{IRET} instruction, instead of the @code{RET} instruction, is used to return from interrupt handlers. All registers, except for the EFLAGS register which is restored by the @code{IRET} instruction, are preserved by the compiler. Since GCC -doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option +doesn't preserve SSE, MMX nor x87 states, the GCC option @option{-mgeneral-regs-only} should be used to compile interrupt and exception handlers. @@ -7004,38 +6990,6 @@ struct foo This warning can be disabled by @option{-Wno-if-not-aligned}. -@item bnd_variable_size -@cindex @code{bnd_variable_size} type attribute -@cindex Pointer Bounds Checker attributes -When applied to a structure field, this attribute tells Pointer -Bounds Checker that the size of this field should not be computed -using static type information. It may be used to mark variably-sized -static array fields placed at the end of a structure. - -@smallexample -struct S -@{ - int size; - char data[1]; -@} -S *p = (S *)malloc (sizeof(S) + 100); -p->data[10] = 0; //Bounds violation -@end smallexample - -@noindent -By using an attribute for the field we may avoid unwanted bound -violation checks: - -@smallexample -struct S -@{ - int size; - char data[1] __attribute__((bnd_variable_size)); -@} -S *p = (S *)malloc (sizeof(S) + 100); -p->data[10] = 0; //OK -@end smallexample - @item deprecated @itemx deprecated (@var{msg}) @cindex @code{deprecated} type attribute @@ -10924,182 +10878,6 @@ format string @var{fmt}. If the compiler is able to optimize them to @code{fputc} etc.@: functions, it does, otherwise the checking function is called and the @var{flag} argument passed to it. -@node Pointer Bounds Checker builtins -@section Pointer Bounds Checker Built-in Functions -@cindex Pointer Bounds Checker builtins -@findex __builtin___bnd_set_ptr_bounds -@findex __builtin___bnd_narrow_ptr_bounds -@findex __builtin___bnd_copy_ptr_bounds -@findex __builtin___bnd_init_ptr_bounds -@findex __builtin___bnd_null_ptr_bounds -@findex __builtin___bnd_store_ptr_bounds -@findex __builtin___bnd_chk_ptr_lbounds -@findex __builtin___bnd_chk_ptr_ubounds -@findex __builtin___bnd_chk_ptr_bounds -@findex __builtin___bnd_get_ptr_lbound -@findex __builtin___bnd_get_ptr_ubound - -GCC provides a set of built-in functions to control Pointer Bounds Checker -instrumentation. Note that all Pointer Bounds Checker builtins can be used -even if you compile with Pointer Bounds Checker off -(@option{-fno-check-pointer-bounds}). -The behavior may differ in such case as documented below. - -@deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size}) - -This built-in function returns a new pointer with the value of @var{q}, and -associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer -Bounds Checker off, the built-in function just returns the first argument. - -@smallexample -extern void *__wrap_malloc (size_t n) -@{ - void *p = (void *)__real_malloc (n); - if (!p) return __builtin___bnd_null_ptr_bounds (p); - return __builtin___bnd_set_ptr_bounds (p, n); -@} -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size}) - -This built-in function returns a new pointer with the value of @var{p} -and associates it with the narrowed bounds formed by the intersection -of bounds associated with @var{q} and the bounds -[@var{p}, @var{p} + @var{size} - 1]. -With Pointer Bounds Checker off, the built-in function just returns the first -argument. - -@smallexample -void init_objects (object *objs, size_t size) -@{ - size_t i; - /* Initialize objects one-by-one passing pointers with bounds of - an object, not the full array of objects. */ - for (i = 0; i < size; i++) - init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, - sizeof(object))); -@} -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r}) - -This built-in function returns a new pointer with the value of @var{q}, -and associates it with the bounds already associated with pointer @var{r}. -With Pointer Bounds Checker off, the built-in function just returns the first -argument. - -@smallexample -/* Here is a way to get pointer to object's field but - still with the full object's bounds. */ -int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, - objptr); -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q}) - -This built-in function returns a new pointer with the value of @var{q}, and -associates it with INIT (allowing full memory access) bounds. With Pointer -Bounds Checker off, the built-in function just returns the first argument. - -@end deftypefn - -@deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q}) - -This built-in function returns a new pointer with the value of @var{q}, and -associates it with NULL (allowing no memory access) bounds. With Pointer -Bounds Checker off, the built-in function just returns the first argument. - -@end deftypefn - -@deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val}) - -This built-in function stores the bounds associated with pointer @var{ptr_val} -and location @var{ptr_addr} into Bounds Table. This can be useful to propagate -bounds from legacy code without touching the associated pointer's memory when -pointers are copied as integers. With Pointer Bounds Checker off, the built-in -function call is ignored. - -@end deftypefn - -@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q}) - -This built-in function checks if the pointer @var{q} is within the lower -bound of its associated bounds. With Pointer Bounds Checker off, the built-in -function call is ignored. - -@smallexample -extern void *__wrap_memset (void *dst, int c, size_t len) -@{ - if (len > 0) - @{ - __builtin___bnd_chk_ptr_lbounds (dst); - __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1); - __real_memset (dst, c, len); - @} - return dst; -@} -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q}) - -This built-in function checks if the pointer @var{q} is within the upper -bound of its associated bounds. With Pointer Bounds Checker off, the built-in -function call is ignored. - -@end deftypefn - -@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size}) - -This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within -the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker -off, the built-in function call is ignored. - -@smallexample -extern void *__wrap_memcpy (void *dst, const void *src, size_t n) -@{ - if (n > 0) - @{ - __bnd_chk_ptr_bounds (dst, n); - __bnd_chk_ptr_bounds (src, n); - __real_memcpy (dst, src, n); - @} - return dst; -@} -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q}) - -This built-in function returns the lower bound associated -with the pointer @var{q}, as a pointer value. -This is useful for debugging using @code{printf}. -With Pointer Bounds Checker off, the built-in function returns 0. - -@smallexample -void *lb = __builtin___bnd_get_ptr_lbound (q); -void *ub = __builtin___bnd_get_ptr_ubound (q); -printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub); -@end smallexample - -@end deftypefn - -@deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q}) - -This built-in function returns the upper bound (which is a pointer) associated -with the pointer @var{q}. With Pointer Bounds Checker off, -the built-in function returns -1. - -@end deftypefn - @node Other Builtins @section Other Built-in Functions Provided by GCC @cindex built-in functions diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 74cb9027dc2..79c47f4bb51 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -269,7 +269,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol -Wc++-compat -Wc++11-compat -Wc++14-compat @gol -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol --Wchar-subscripts -Wchkp -Wcatch-value -Wcatch-value=@var{n} @gol +-Wchar-subscripts -Wcatch-value -Wcatch-value=@var{n} @gol -Wclobbered -Wcomment -Wconditionally-supported @gol -Wconversion -Wcoverage-mismatch -Wno-cpp -Wdangling-else -Wdate-time @gol -Wdelete-incomplete @gol @@ -459,15 +459,6 @@ Objective-C and Objective-C++ Dialects}. -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol -fsanitize-undefined-trap-on-error -fbounds-check @gol --fcheck-pointer-bounds -fchkp-check-incomplete-type @gol --fchkp-first-field-has-own-bounds -fchkp-narrow-bounds @gol --fchkp-narrow-to-innermost-array -fchkp-optimize @gol --fchkp-use-fast-string-functions -fchkp-use-nochk-string-functions @gol --fchkp-use-static-bounds -fchkp-use-static-const-bounds @gol --fchkp-treat-zero-dynamic-size-as-infinite -fchkp-check-read @gol --fchkp-check-read -fchkp-check-write -fchkp-store-bounds @gol --fchkp-instrument-calls -fchkp-instrument-marked-only @gol --fchkp-use-wrappers -fchkp-flexible-struct-trailing-arrays@gol -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} @gol -fstack-protector -fstack-protector-all -fstack-protector-strong @gol -fstack-protector-explicit -fstack-check @gol @@ -508,7 +499,6 @@ Objective-C and Objective-C++ Dialects}. -nostartfiles -nodefaultlibs -nostdlib -pie -pthread -rdynamic @gol -s -static -static-pie -static-libgcc -static-libstdc++ @gol -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol --static-libmpx -static-libmpxwrappers @gol -shared -shared-libgcc -symbolic @gol -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol} -z @var{keyword}} @@ -1258,7 +1248,7 @@ See RS/6000 and PowerPC Options. -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol -mprefetchwt1 -mclflushopt -mxsavec -mxsaves @gol -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol --mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp -mmpx @gol +-mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp @gol -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol -mshstk -mforce-indirect-call -mavx512vbmi2 @gol -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @@ -4061,11 +4051,6 @@ of error, as programmers often forget that this type is signed on some machines. This warning is enabled by @option{-Wall}. -@item -Wchkp -@opindex Wchkp -Warn about an invalid memory access that is found by Pointer Bounds Checker -(@option{-fcheck-pointer-bounds}). - @item -Wno-coverage-mismatch @opindex Wno-coverage-mismatch Warn if feedback profiles do not match when using the @@ -11135,12 +11120,6 @@ If the size of a local variable in bytes is smaller or equal to this number, directly poison (or unpoison) shadow memory instead of using run-time callbacks. The default value is 256. -@item chkp-max-ctor-size -Static constructors generated by Pointer Bounds Checker may become very -large and significantly increase compile time at optimization level -@option{-O1} and higher. This parameter is a maximum number of statements -in a single generated constructor. Default value is 5000. - @item max-fsm-thread-path-insns Maximum number of instructions to copy when duplicating blocks on a finite state automaton jump thread path. The default is 100. @@ -11403,22 +11382,19 @@ more details. The run-time behavior can be influenced using the the available options are shown at startup of the instrumented program. See @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} for a list of supported options. -The option cannot be combined with @option{-fsanitize=thread} -and/or @option{-fcheck-pointer-bounds}. +The option cannot be combined with @option{-fsanitize=thread}. @item -fsanitize=kernel-address @opindex fsanitize=kernel-address Enable AddressSanitizer for Linux kernel. See @uref{https://github.com/google/kasan/wiki} for more details. -The option cannot be combined with @option{-fcheck-pointer-bounds}. @item -fsanitize=pointer-compare @opindex fsanitize=pointer-compare Instrument comparison operation (<, <=, >, >=) with pointer operands. The option must be combined with either @option{-fsanitize=kernel-address} or @option{-fsanitize=address} -The option cannot be combined with @option{-fsanitize=thread} -and/or @option{-fcheck-pointer-bounds}. +The option cannot be combined with @option{-fsanitize=thread}. Note: By default the check is disabled at run time. To enable it, add @code{detect_invalid_pointer_pairs=2} to the environment variable @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects @@ -11429,8 +11405,7 @@ invalid operation only when both pointers are non-null. Instrument subtraction with pointer operands. The option must be combined with either @option{-fsanitize=kernel-address} or @option{-fsanitize=address} -The option cannot be combined with @option{-fsanitize=thread} -and/or @option{-fcheck-pointer-bounds}. +The option cannot be combined with @option{-fsanitize=thread}. Note: By default the check is disabled at run time. To enable it, add @code{detect_invalid_pointer_pairs=2} to the environment variable @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects @@ -11446,7 +11421,7 @@ environment variable; see @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of supported options. The option cannot be combined with @option{-fsanitize=address}, -@option{-fsanitize=leak} and/or @option{-fcheck-pointer-bounds}. +@option{-fsanitize=leak}. Note that sanitized atomic builtins cannot throw exceptions when operating on invalid memory addresses with non-call exceptions @@ -11539,15 +11514,13 @@ a++; This option enables instrumentation of array bounds. Various out of bounds accesses are detected. Flexible array members, flexible array member-like arrays, and initializers of variables with static storage are not instrumented. -The option cannot be combined with @option{-fcheck-pointer-bounds}. @item -fsanitize=bounds-strict @opindex fsanitize=bounds-strict This option enables strict instrumentation of array bounds. Most out of bounds accesses are detected, including flexible array members and flexible array member-like arrays. Initializers of variables with static storage are not -instrumented. The option cannot be combined -with @option{-fcheck-pointer-bounds}. +instrumented. @item -fsanitize=alignment @opindex fsanitize=alignment @@ -11721,171 +11694,6 @@ operand constant, @code{__sanitizer_cov_trace_cmpf} or @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and @code{__sanitizer_cov_trace_switch} for switch statements. -@item -fbounds-check -@opindex fbounds-check -For front ends that support it, generate additional code to check that -indices used to access arrays are within the declared range. This is -currently only supported by the Fortran front end, where this option -defaults to false. - -@item -fcheck-pointer-bounds -@opindex fcheck-pointer-bounds -@opindex fno-check-pointer-bounds -@cindex Pointer Bounds Checker options -Enable Pointer Bounds Checker instrumentation. Each memory reference -is instrumented with checks of the pointer used for memory access against -bounds associated with that pointer. - -Currently there -is only an implementation for Intel MPX available, thus x86 GNU/Linux target -and @option{-mmpx} are required to enable this feature. -MPX-based instrumentation requires -a runtime library to enable MPX in hardware and handle bounds -violation signals. By default when @option{-fcheck-pointer-bounds} -and @option{-mmpx} options are used to link a program, the GCC driver -links against the @file{libmpx} and @file{libmpxwrappers} libraries. -Bounds checking on calls to dynamic libraries requires a linker -with @option{-z bndplt} support; if GCC was configured with a linker -without support for this option (including the Gold linker and older -versions of ld), a warning is given if you link with @option{-mmpx} -without also specifying @option{-static}, since the overall effectiveness -of the bounds checking protection is reduced. -See also @option{-static-libmpxwrappers}. - -MPX-based instrumentation -may be used for debugging and also may be included in production code -to increase program security. Depending on usage, you may -have different requirements for the runtime library. The current version -of the MPX runtime library is more oriented for use as a debugging -tool. MPX runtime library usage implies @option{-lpthread}. See -also @option{-static-libmpx}. The runtime library behavior can be -influenced using various @env{CHKP_RT_*} environment variables. See -@uref{https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler} -for more details. - -Generated instrumentation may be controlled by various -@option{-fchkp-*} options and by the @code{bnd_variable_size} -structure field attribute (@pxref{Type Attributes}) and -@code{bnd_legacy}, and @code{bnd_instrument} function attributes -(@pxref{Function Attributes}). GCC also provides a number of built-in -functions for controlling the Pointer Bounds Checker. @xref{Pointer -Bounds Checker builtins}, for more information. - -@item -fchkp-check-incomplete-type -@opindex fchkp-check-incomplete-type -@opindex fno-chkp-check-incomplete-type -Generate pointer bounds checks for variables with incomplete type. -Enabled by default. - -@item -fchkp-narrow-bounds -@opindex fchkp-narrow-bounds -@opindex fno-chkp-narrow-bounds -Controls bounds used by Pointer Bounds Checker for pointers to object -fields. If narrowing is enabled then field bounds are used. Otherwise -object bounds are used. See also @option{-fchkp-narrow-to-innermost-array} -and @option{-fchkp-first-field-has-own-bounds}. Enabled by default. - -@item -fchkp-first-field-has-own-bounds -@opindex fchkp-first-field-has-own-bounds -@opindex fno-chkp-first-field-has-own-bounds -Forces Pointer Bounds Checker to use narrowed bounds for the address of the -first field in the structure. By default a pointer to the first field has -the same bounds as a pointer to the whole structure. - -@item -fchkp-flexible-struct-trailing-arrays -@opindex fchkp-flexible-struct-trailing-arrays -@opindex fno-chkp-flexible-struct-trailing-arrays -Forces Pointer Bounds Checker to treat all trailing arrays in structures as -possibly flexible. By default only array fields with zero length or that are -marked with attribute bnd_variable_size are treated as flexible. - -@item -fchkp-narrow-to-innermost-array -@opindex fchkp-narrow-to-innermost-array -@opindex fno-chkp-narrow-to-innermost-array -Forces Pointer Bounds Checker to use bounds of the innermost arrays in -case of nested static array access. By default this option is disabled and -bounds of the outermost array are used. - -@item -fchkp-optimize -@opindex fchkp-optimize -@opindex fno-chkp-optimize -Enables Pointer Bounds Checker optimizations. Enabled by default at -optimization levels @option{-O}, @option{-O2}, @option{-O3}. - -@item -fchkp-use-fast-string-functions -@opindex fchkp-use-fast-string-functions -@opindex fno-chkp-use-fast-string-functions -Enables use of @code{*_nobnd} versions of string functions (not copying bounds) -by Pointer Bounds Checker. Disabled by default. - -@item -fchkp-use-nochk-string-functions -@opindex fchkp-use-nochk-string-functions -@opindex fno-chkp-use-nochk-string-functions -Enables use of @code{*_nochk} versions of string functions (not checking bounds) -by Pointer Bounds Checker. Disabled by default. - -@item -fchkp-use-static-bounds -@opindex fchkp-use-static-bounds -@opindex fno-chkp-use-static-bounds -Allow Pointer Bounds Checker to generate static bounds holding -bounds of static variables. Enabled by default. - -@item -fchkp-use-static-const-bounds -@opindex fchkp-use-static-const-bounds -@opindex fno-chkp-use-static-const-bounds -Use statically-initialized bounds for constant bounds instead of -generating them each time they are required. By default enabled when -@option{-fchkp-use-static-bounds} is enabled. - -@item -fchkp-treat-zero-dynamic-size-as-infinite -@opindex fchkp-treat-zero-dynamic-size-as-infinite -@opindex fno-chkp-treat-zero-dynamic-size-as-infinite -With this option, objects with incomplete type whose -dynamically-obtained size is zero are treated as having infinite size -instead by Pointer Bounds -Checker. This option may be helpful if a program is linked with a library -missing size information for some symbols. Disabled by default. - -@item -fchkp-check-read -@opindex fchkp-check-read -@opindex fno-chkp-check-read -Instructs Pointer Bounds Checker to generate checks for all read -accesses to memory. Enabled by default. - -@item -fchkp-check-write -@opindex fchkp-check-write -@opindex fno-chkp-check-write -Instructs Pointer Bounds Checker to generate checks for all write -accesses to memory. Enabled by default. - -@item -fchkp-store-bounds -@opindex fchkp-store-bounds -@opindex fno-chkp-store-bounds -Instructs Pointer Bounds Checker to generate bounds stores for -pointer writes. Enabled by default. - -@item -fchkp-instrument-calls -@opindex fchkp-instrument-calls -@opindex fno-chkp-instrument-calls -Instructs Pointer Bounds Checker to pass pointer bounds to calls. -Enabled by default. - -@item -fchkp-instrument-marked-only -@opindex fchkp-instrument-marked-only -@opindex fno-chkp-instrument-marked-only -Instructs Pointer Bounds Checker to instrument only functions -marked with the @code{bnd_instrument} attribute -(@pxref{Function Attributes}). Disabled by default. - -@item -fchkp-use-wrappers -@opindex fchkp-use-wrappers -@opindex fno-chkp-use-wrappers -Allows Pointer Bounds Checker to replace calls to built-in functions -with calls to wrapper functions. When @option{-fchkp-use-wrappers} -is used to link a program, the GCC driver automatically links -against @file{libmpxwrappers}. See also @option{-static-libmpxwrappers}. -Enabled by default. - @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} @opindex fcf-protection Enable code instrumentation of control-flow transfers to increase @@ -12590,27 +12398,6 @@ option is not used, then this links against the shared version of driver to link @file{libubsan} statically, without necessarily linking other libraries statically. -@item -static-libmpx -@opindex static-libmpx -When the @option{-fcheck-pointer bounds} and @option{-mmpx} options are -used to link a program, the GCC driver automatically links against -@file{libmpx}. If @file{libmpx} is available as a shared library, -and the @option{-static} option is not used, then this links against -the shared version of @file{libmpx}. The @option{-static-libmpx} -option directs the GCC driver to link @file{libmpx} statically, -without necessarily linking other libraries statically. - -@item -static-libmpxwrappers -@opindex static-libmpxwrappers -When the @option{-fcheck-pointer bounds} and @option{-mmpx} options are used -to link a program without also using @option{-fno-chkp-use-wrappers}, the -GCC driver automatically links against @file{libmpxwrappers}. If -@file{libmpxwrappers} is available as a shared library, and the -@option{-static} option is not used, then this links against the shared -version of @file{libmpxwrappers}. The @option{-static-libmpxwrappers} -option directs the GCC driver to link @file{libmpxwrappers} statically, -without necessarily linking other libraries statically. - @item -static-libstdc++ @opindex static-libstdc++ When the @command{g++} program is used to link a C++ program, it @@ -27387,9 +27174,6 @@ preferred alignment to @option{-mpreferred-stack-boundary=2}. @itemx -mtbm @opindex mtbm @need 200 -@itemx -mmpx -@opindex mmpx -@need 200 @itemx -mmwaitx @opindex mmwaitx @need 200 @@ -27432,7 +27216,7 @@ These switches enable the use of instructions in the MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, AVX, AVX2, AVX512F, AVX512PF, AVX512ER, AVX512CD, SHA, AES, PCLMUL, FSGSBASE, RDRND, F16C, FMA, SSE4A, FMA4, XOP, LWP, ABM, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, BMI, BMI2, VAES, WAITPKG, -FXSR, XSAVE, XSAVEOPT, LZCNT, RTM, MPX, MWAITX, PKU, IBT, SHSTK, AVX512VBMI2, +FXSR, XSAVE, XSAVEOPT, LZCNT, RTM, MWAITX, PKU, IBT, SHSTK, AVX512VBMI2, GFNI, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512VPOPCNTDQ, CLDEMOTE, 3DNow!@: or enhanced 3DNow!@: extended instruction sets. Each has a corresponding @option{-mno-} option to disable use of these @@ -28018,9 +27802,8 @@ Note that @option{-mcmodel=large} is incompatible with not be reachable in the large code model. Note that @option{-mindirect-branch=thunk-extern} is incompatible with -@option{-fcf-protection=branch} and @option{-fcheck-pointer-bounds} -since the external thunk can not be modified to disable control-flow -check. +@option{-fcf-protection=branch} since the external thunk can not be modified +to disable control-flow check. @item -mfunction-return=@var{choice} @opindex -mfunction-return diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index be37619f340..a3ecb711eca 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -4189,12 +4189,6 @@ VSIB address operand. @item Ts Address operand without segment register. -@item Ti -MPX address operand without index. - -@item Tb -MPX address operand without base. - @end table @item Xstormy16---@file{config/stormy16/stormy16.h} diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 9d92ed1c3d3..1c5a80920f1 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5252,12 +5252,6 @@ This hook is used by expand pass to emit insn to store @var{bounds} returned by function call into @var{slot}. @end deftypefn -@deftypefn {Target Hook} rtx TARGET_CHKP_FUNCTION_VALUE_BOUNDS (const_tree @var{ret_type}, const_tree @var{fn_decl_or_type}, bool @var{outgoing}) -Define this to return an RTX representing the place where a function -returns bounds for returned pointers. Arguments meaning is similar to -@code{TARGET_FUNCTION_VALUE}. -@end deftypefn - @deftypefn {Target Hook} void TARGET_SETUP_INCOMING_VARARG_BOUNDS (cumulative_args_t @var{args_so_far}, machine_mode @var{mode}, tree @var{type}, int *@var{pretend_args_size}, int @var{second_time}) Use it to store bounds for anonymous register arguments stored into the stack. Arguments meaning is similar to @@ -11417,93 +11411,6 @@ ignored. This function should return the result of the call to the built-in function. @end deftypefn -@deftypefn {Target Hook} tree TARGET_BUILTIN_CHKP_FUNCTION (unsigned @var{fcode}) -This hook allows target to redefine built-in functions used by -Pointer Bounds Checker for code instrumentation. Hook should return -fndecl of function implementing generic builtin whose code is -passed in @var{fcode}. Currently following built-in functions are -obtained using this hook: -@deftypefn {Built-in Function} __bounds_type __chkp_bndmk (const void *@var{lb}, size_t @var{size}) -Function code - BUILT_IN_CHKP_BNDMK. This built-in function is used -by Pointer Bounds Checker to create bound values. @var{lb} holds low -bound of the resulting bounds. @var{size} holds size of created bounds. -@end deftypefn - -@deftypefn {Built-in Function} void __chkp_bndstx (const void *@var{ptr}, __bounds_type @var{b}, const void **@var{loc}) -Function code - @code{BUILT_IN_CHKP_BNDSTX}. This built-in function is used -by Pointer Bounds Checker to store bounds @var{b} for pointer @var{ptr} -when @var{ptr} is stored by address @var{loc}. -@end deftypefn - -@deftypefn {Built-in Function} __bounds_type __chkp_bndldx (const void **@var{loc}, const void *@var{ptr}) -Function code - @code{BUILT_IN_CHKP_BNDLDX}. This built-in function is used -by Pointer Bounds Checker to get bounds of pointer @var{ptr} loaded by -address @var{loc}. -@end deftypefn - -@deftypefn {Built-in Function} void __chkp_bndcl (const void *@var{ptr}, __bounds_type @var{b}) -Function code - @code{BUILT_IN_CHKP_BNDCL}. This built-in function is used -by Pointer Bounds Checker to perform check for pointer @var{ptr} against -lower bound of bounds @var{b}. -@end deftypefn - -@deftypefn {Built-in Function} void __chkp_bndcu (const void *@var{ptr}, __bounds_type @var{b}) -Function code - @code{BUILT_IN_CHKP_BNDCU}. This built-in function is used -by Pointer Bounds Checker to perform check for pointer @var{ptr} against -upper bound of bounds @var{b}. -@end deftypefn - -@deftypefn {Built-in Function} __bounds_type __chkp_bndret (void *@var{ptr}) -Function code - @code{BUILT_IN_CHKP_BNDRET}. This built-in function is used -by Pointer Bounds Checker to obtain bounds returned by a call statement. -@var{ptr} passed to built-in is @code{SSA_NAME} returned by the call. -@end deftypefn - -@deftypefn {Built-in Function} __bounds_type __chkp_intersect (__bounds_type @var{b1}, __bounds_type @var{b2}) -Function code - @code{BUILT_IN_CHKP_INTERSECT}. This built-in function -returns intersection of bounds @var{b1} and @var{b2}. -@end deftypefn - -@deftypefn {Built-in Function} __bounds_type __chkp_narrow (const void *@var{ptr}, __bounds_type @var{b}, size_t @var{s}) -Function code - @code{BUILT_IN_CHKP_NARROW}. This built-in function -returns intersection of bounds @var{b} and -[@var{ptr}, @var{ptr} + @var{s} - @code{1}]. -@end deftypefn - -@deftypefn {Built-in Function} size_t __chkp_sizeof (const void *@var{ptr}) -Function code - @code{BUILT_IN_CHKP_SIZEOF}. This built-in function -returns size of object referenced by @var{ptr}. @var{ptr} is always -@code{ADDR_EXPR} of @code{VAR_DECL}. This built-in is used by -Pointer Bounds Checker when bounds of object cannot be computed statically -(e.g. object has incomplete type). -@end deftypefn - -@deftypefn {Built-in Function} const void *__chkp_extract_lower (__bounds_type @var{b}) -Function code - @code{BUILT_IN_CHKP_EXTRACT_LOWER}. This built-in function -returns lower bound of bounds @var{b}. -@end deftypefn - -@deftypefn {Built-in Function} const void *__chkp_extract_upper (__bounds_type @var{b}) -Function code - @code{BUILT_IN_CHKP_EXTRACT_UPPER}. This built-in function -returns upper bound of bounds @var{b}. -@end deftypefn -@end deftypefn -@deftypefn {Target Hook} tree TARGET_CHKP_BOUND_TYPE (void) -Return type to be used for bounds -@end deftypefn -@deftypefn {Target Hook} machine_mode TARGET_CHKP_BOUND_MODE (void) -Return mode to be used for bounds. -@end deftypefn -@deftypefn {Target Hook} tree TARGET_CHKP_MAKE_BOUNDS_CONSTANT (HOST_WIDE_INT @var{lb}, HOST_WIDE_INT @var{ub}) -Return constant used to statically initialize constant bounds -with specified lower bound @var{lb} and upper bounds @var{ub}. -@end deftypefn -@deftypefn {Target Hook} int TARGET_CHKP_INITIALIZE_BOUNDS (tree @var{var}, tree @var{lb}, tree @var{ub}, tree *@var{stmts}) -Generate a list of statements @var{stmts} to initialize pointer -bounds variable @var{var} with bounds @var{lb} and @var{ub}. Return -the number of generated statements. -@end deftypefn - @deftypefn {Target Hook} tree TARGET_RESOLVE_OVERLOADED_BUILTIN (unsigned int @var{loc}, tree @var{fndecl}, void *@var{arglist}) Select a replacement for a machine specific built-in function that was set up by @samp{TARGET_INIT_BUILTINS}. This is done diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 5732a2a4515..bf2c64e15db 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -3761,8 +3761,6 @@ These machine description macros help implement varargs: @hook TARGET_STORE_RETURNED_BOUNDS -@hook TARGET_CHKP_FUNCTION_VALUE_BOUNDS - @hook TARGET_SETUP_INCOMING_VARARG_BOUNDS @node Trampolines @@ -7866,12 +7864,6 @@ to by @var{ce_info}. @hook TARGET_EXPAND_BUILTIN -@hook TARGET_BUILTIN_CHKP_FUNCTION -@hook TARGET_CHKP_BOUND_TYPE -@hook TARGET_CHKP_BOUND_MODE -@hook TARGET_CHKP_MAKE_BOUNDS_CONSTANT -@hook TARGET_CHKP_INITIALIZE_BOUNDS - @hook TARGET_RESOLVE_OVERLOADED_BUILTIN @hook TARGET_FOLD_BUILTIN diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index e3d24e86c15..a6b20b4912d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -12918,7 +12918,6 @@ is_base_type (tree type) case FIXED_POINT_TYPE: case COMPLEX_TYPE: case BOOLEAN_TYPE: - case POINTER_BOUNDS_TYPE: return 1; case VOID_TYPE: @@ -22295,21 +22294,18 @@ gen_formal_types_die (tree function_or_method_type, dw_die_ref context_die) break; /* Output a (nameless) DIE to represent the formal parameter itself. */ - if (!POINTER_BOUNDS_TYPE_P (formal_type)) + parm_die = gen_formal_parameter_die (formal_type, NULL, + true /* Emit name attribute. */, + context_die); + if (TREE_CODE (function_or_method_type) == METHOD_TYPE + && link == first_parm_type) { - parm_die = gen_formal_parameter_die (formal_type, NULL, - true /* Emit name attribute. */, - context_die); - if (TREE_CODE (function_or_method_type) == METHOD_TYPE - && link == first_parm_type) - { - add_AT_flag (parm_die, DW_AT_artificial, 1); - if (dwarf_version >= 3 || !dwarf_strict) - add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die); - } - else if (arg && DECL_ARTIFICIAL (arg)) - add_AT_flag (parm_die, DW_AT_artificial, 1); + add_AT_flag (parm_die, DW_AT_artificial, 1); + if (dwarf_version >= 3 || !dwarf_strict) + add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die); } + else if (arg && DECL_ARTIFICIAL (arg)) + add_AT_flag (parm_die, DW_AT_artificial, 1); link = TREE_CHAIN (link); if (arg) @@ -23176,7 +23172,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) gen_formal_parameter_pack_die (generic_decl_parm, parm, subr_die, &parm); - else if (parm && !POINTER_BOUNDS_P (parm)) + else if (parm) { dw_die_ref parm_die = gen_decl_die (parm, NULL, NULL, subr_die); @@ -25561,7 +25557,6 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die, case FIXED_POINT_TYPE: case COMPLEX_TYPE: case BOOLEAN_TYPE: - case POINTER_BOUNDS_TYPE: /* No DIEs needed for fundamental types. */ break; @@ -26141,12 +26136,6 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx, if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin)) return NULL; - /* Ignore pointer bounds decls. */ - if (DECL_P (decl_or_origin) - && TREE_TYPE (decl_or_origin) - && POINTER_BOUNDS_P (decl_or_origin)) - return NULL; - switch (TREE_CODE (decl_or_origin)) { case ERROR_MARK: @@ -26480,7 +26469,7 @@ dwarf2out_late_global_decl (tree decl) { /* Fill-in any location information we were unable to determine on the first pass. */ - if (VAR_P (decl) && !POINTER_BOUNDS_P (decl)) + if (VAR_P (decl)) { dw_die_ref die = lookup_decl_die (decl); diff --git a/gcc/expr.c b/gcc/expr.c index f15037adfb6..89430246d12 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -58,8 +58,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-outof-ssa.h" #include "tree-ssa-address.h" #include "builtins.h" -#include "tree-chkp.h" -#include "rtl-chkp.h" #include "ccmp.h" #include "rtx-vector-builder.h" @@ -5283,14 +5281,10 @@ expand_assignment (tree to, tree from, bool nontemporal) || TREE_CODE (to) == SSA_NAME)) { rtx value; - rtx bounds; push_temp_slots (); value = expand_normal (from); - /* Split value and bounds to store them separately. */ - chkp_split_slot (value, &value, &bounds); - if (to_rtx == 0) to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE); @@ -5325,14 +5319,6 @@ expand_assignment (tree to, tree from, bool nontemporal) emit_move_insn (to_rtx, value); } - /* Store bounds if required. */ - if (bounds - && (BOUNDED_P (to) || chkp_type_has_pointer (TREE_TYPE (to)))) - { - gcc_assert (MEM_P (to_rtx)); - chkp_emit_bounds_store (bounds, value, to_rtx); - } - preserve_temp_slots (to_rtx); pop_temp_slots (); return; @@ -5403,7 +5389,7 @@ expand_assignment (tree to, tree from, bool nontemporal) /* Compute FROM and store the value in the rtx we got. */ push_temp_slots (); - result = store_expr_with_bounds (from, to_rtx, 0, nontemporal, false, to); + result = store_expr (from, to_rtx, 0, nontemporal, false); preserve_temp_slots (result); pop_temp_slots (); return; @@ -5442,14 +5428,11 @@ emit_storent_insn (rtx to, rtx from) If NONTEMPORAL is true, try using a nontemporal store instruction. - If REVERSE is true, the store is to be done in reverse order. - - If BTARGET is not NULL then computed bounds of EXP are - associated with BTARGET. */ + If REVERSE is true, the store is to be done in reverse order. */ rtx -store_expr_with_bounds (tree exp, rtx target, int call_param_p, - bool nontemporal, bool reverse, tree btarget) +store_expr (tree exp, rtx target, int call_param_p, + bool nontemporal, bool reverse) { rtx temp; rtx alt_rtl = NULL_RTX; @@ -5470,9 +5453,8 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, part. */ expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL); - return store_expr_with_bounds (TREE_OPERAND (exp, 1), target, - call_param_p, nontemporal, reverse, - btarget); + return store_expr (TREE_OPERAND (exp, 1), target, + call_param_p, nontemporal, reverse); } else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode) { @@ -5487,13 +5469,13 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, NO_DEFER_POP; jumpifnot (TREE_OPERAND (exp, 0), lab1, profile_probability::uninitialized ()); - store_expr_with_bounds (TREE_OPERAND (exp, 1), target, call_param_p, - nontemporal, reverse, btarget); + store_expr (TREE_OPERAND (exp, 1), target, call_param_p, + nontemporal, reverse); emit_jump_insn (targetm.gen_jump (lab2)); emit_barrier (); emit_label (lab1); - store_expr_with_bounds (TREE_OPERAND (exp, 2), target, call_param_p, - nontemporal, reverse, btarget); + store_expr (TREE_OPERAND (exp, 2), target, call_param_p, + nontemporal, reverse); emit_label (lab2); OK_DEFER_POP; @@ -5546,18 +5528,6 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, temp = expand_expr (exp, inner_target, VOIDmode, call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL); - /* Handle bounds returned by call. */ - if (TREE_CODE (exp) == CALL_EXPR) - { - rtx bounds; - chkp_split_slot (temp, &temp, &bounds); - if (bounds && btarget) - { - gcc_assert (TREE_CODE (btarget) == SSA_NAME); - rtx tmp = targetm.calls.load_returned_bounds (bounds); - chkp_set_rtl_bounds (btarget, tmp); - } - } /* If TEMP is a VOIDmode constant, use convert_modes to make sure that we properly convert it. */ @@ -5639,19 +5609,6 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, (call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL), &alt_rtl, false); - - /* Handle bounds returned by call. */ - if (TREE_CODE (exp) == CALL_EXPR) - { - rtx bounds; - chkp_split_slot (temp, &temp, &bounds); - if (bounds && btarget) - { - gcc_assert (TREE_CODE (btarget) == SSA_NAME); - rtx tmp = targetm.calls.load_returned_bounds (bounds); - chkp_set_rtl_bounds (btarget, tmp); - } - } } /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not @@ -5831,15 +5788,6 @@ store_expr_with_bounds (tree exp, rtx target, int call_param_p, return NULL_RTX; } - -/* Same as store_expr_with_bounds but ignoring bounds of EXP. */ -rtx -store_expr (tree exp, rtx target, int call_param_p, bool nontemporal, - bool reverse) -{ - return store_expr_with_bounds (exp, target, call_param_p, nontemporal, - reverse, NULL); -} /* Return true if field F of structure TYPE is a flexible array. */ @@ -10954,11 +10902,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, if (fndecl && DECL_BUILT_IN (fndecl)) { gcc_assert (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_FRONTEND); - if (CALL_WITH_BOUNDS_P (exp)) - return expand_builtin_with_bounds (exp, target, subtarget, - tmode, ignore); - else - return expand_builtin (exp, target, subtarget, tmode, ignore); + return expand_builtin (exp, target, subtarget, tmode, ignore); } } return expand_call (exp, target, ignore); diff --git a/gcc/expr.h b/gcc/expr.h index 52a26e7c2a3..cf047d49e2e 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -254,7 +254,6 @@ extern void expand_assignment (tree, tree, bool); and storing the value into TARGET. If SUGGEST_REG is nonzero, copy the value through a register and return that register, if that is possible. */ -extern rtx store_expr_with_bounds (tree, rtx, int, bool, bool, tree); extern rtx store_expr (tree, rtx, int, bool, bool); /* Given an rtx that may include add and multiply operations, diff --git a/gcc/function.c b/gcc/function.c index 6b9fd597d41..47232a27611 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -73,8 +73,6 @@ along with GCC; see the file COPYING3. If not see #include "shrink-wrap.h" #include "toplev.h" #include "rtl-iter.h" -#include "tree-chkp.h" -#include "rtl-chkp.h" #include "tree-dfa.h" #include "tree-ssa.h" #include "stringpool.h" @@ -2201,14 +2199,6 @@ use_register_for_decl (const_tree decl) return false; } - /* Decl is implicitly addressible by bound stores and loads - if it is an aggregate holding bounds. */ - if (chkp_function_instrumented_p (current_function_decl) - && TREE_TYPE (decl) - && !BOUNDED_P (decl) - && chkp_type_has_pointer (TREE_TYPE (decl))) - return false; - /* Only register-like things go in registers. */ if (DECL_MODE (decl) == BLKmode) return false; @@ -2280,15 +2270,6 @@ struct assign_parm_data_one BOOL_BITFIELD loaded_in_reg : 1; }; -struct bounds_parm_data -{ - assign_parm_data_one parm_data; - tree bounds_parm; - tree ptr_parm; - rtx ptr_entry; - int bound_no; -}; - /* A subroutine of assign_parms. Initialize ALL. */ static void @@ -2403,23 +2384,6 @@ assign_parms_augmented_arg_list (struct assign_parm_data_all *all) fnargs.safe_insert (0, decl); all->function_result_decl = decl; - - /* If function is instrumented then bounds of the - passed structure address is the second argument. */ - if (chkp_function_instrumented_p (fndecl)) - { - decl = build_decl (DECL_SOURCE_LOCATION (fndecl), - PARM_DECL, get_identifier (".result_bnd"), - pointer_bounds_type_node); - DECL_ARG_TYPE (decl) = pointer_bounds_type_node; - DECL_ARTIFICIAL (decl) = 1; - DECL_NAMELESS (decl) = 1; - TREE_CONSTANT (decl) = 1; - - DECL_CHAIN (decl) = DECL_CHAIN (all->orig_fnargs); - DECL_CHAIN (all->orig_fnargs) = decl; - fnargs.safe_insert (1, decl); - } } /* If the target wants to split complex arguments into scalars, do so. */ @@ -2563,7 +2527,7 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all, it came in a register so that REG_PARM_STACK_SPACE isn't skipped. In this case, we call FUNCTION_ARG with NAMED set to 1 instead of 0 as it was the previous time. */ - in_regs = (entry_parm != 0) || POINTER_BOUNDS_TYPE_P (data->passed_type); + in_regs = (entry_parm != 0); #ifdef STACK_PARMS_IN_REG_PARM_AREA in_regs = true; #endif @@ -2652,12 +2616,8 @@ static bool assign_parm_is_stack_parm (struct assign_parm_data_all *all, struct assign_parm_data_one *data) { - /* Bounds are never passed on the stack to keep compatibility - with not instrumented code. */ - if (POINTER_BOUNDS_TYPE_P (data->passed_type)) - return false; /* Trivially true if we've no incoming register. */ - else if (data->entry_parm == NULL) + if (data->entry_parm == NULL) ; /* Also true if we're partially in registers and partially not, since we've arranged to drop the entire argument on the stack. */ @@ -3572,121 +3532,6 @@ assign_parms_unsplit_complex (struct assign_parm_data_all *all, } } -/* Load bounds of PARM from bounds table. */ -static void -assign_parm_load_bounds (struct assign_parm_data_one *data, - tree parm, - rtx entry, - unsigned bound_no) -{ - bitmap_iterator bi; - unsigned i, offs = 0; - int bnd_no = -1; - rtx slot = NULL, ptr = NULL; - - if (parm) - { - bitmap slots; - bitmap_obstack_initialize (NULL); - slots = BITMAP_ALLOC (NULL); - chkp_find_bound_slots (TREE_TYPE (parm), slots); - EXECUTE_IF_SET_IN_BITMAP (slots, 0, i, bi) - { - if (bound_no) - bound_no--; - else - { - bnd_no = i; - break; - } - } - BITMAP_FREE (slots); - bitmap_obstack_release (NULL); - } - - /* We may have bounds not associated with any pointer. */ - if (bnd_no != -1) - offs = bnd_no * POINTER_SIZE / BITS_PER_UNIT; - - /* Find associated pointer. */ - if (bnd_no == -1) - { - /* If bounds are not associated with any bounds, - then it is passed in a register or special slot. */ - gcc_assert (data->entry_parm); - ptr = const0_rtx; - } - else if (MEM_P (entry)) - slot = adjust_address (entry, Pmode, offs); - else if (REG_P (entry)) - ptr = gen_rtx_REG (Pmode, REGNO (entry) + bnd_no); - else if (GET_CODE (entry) == PARALLEL) - ptr = chkp_get_value_with_offs (entry, GEN_INT (offs)); - else - gcc_unreachable (); - data->entry_parm = targetm.calls.load_bounds_for_arg (slot, ptr, - data->entry_parm); -} - -/* Assign RTL expressions to the function's bounds parameters BNDARGS. */ - -static void -assign_bounds (vec<bounds_parm_data> &bndargs, - struct assign_parm_data_all &all, - bool assign_regs, bool assign_special, - bool assign_bt) -{ - unsigned i, pass; - bounds_parm_data *pbdata; - - if (!bndargs.exists ()) - return; - - /* We make few passes to store input bounds. Firstly handle bounds - passed in registers. After that we load bounds passed in special - slots. Finally we load bounds from Bounds Table. */ - for (pass = 0; pass < 3; pass++) - FOR_EACH_VEC_ELT (bndargs, i, pbdata) - { - /* Pass 0 => regs only. */ - if (pass == 0 - && (!assign_regs - ||(!pbdata->parm_data.entry_parm - || GET_CODE (pbdata->parm_data.entry_parm) != REG))) - continue; - /* Pass 1 => slots only. */ - else if (pass == 1 - && (!assign_special - || (!pbdata->parm_data.entry_parm - || GET_CODE (pbdata->parm_data.entry_parm) == REG))) - continue; - /* Pass 2 => BT only. */ - else if (pass == 2 - && (!assign_bt - || pbdata->parm_data.entry_parm)) - continue; - - if (!pbdata->parm_data.entry_parm - || GET_CODE (pbdata->parm_data.entry_parm) != REG) - assign_parm_load_bounds (&pbdata->parm_data, pbdata->ptr_parm, - pbdata->ptr_entry, pbdata->bound_no); - - set_decl_incoming_rtl (pbdata->bounds_parm, - pbdata->parm_data.entry_parm, false); - - if (assign_parm_setup_block_p (&pbdata->parm_data)) - assign_parm_setup_block (&all, pbdata->bounds_parm, - &pbdata->parm_data); - else if (pbdata->parm_data.passed_pointer - || use_register_for_decl (pbdata->bounds_parm)) - assign_parm_setup_reg (&all, pbdata->bounds_parm, - &pbdata->parm_data); - else - assign_parm_setup_stack (&all, pbdata->bounds_parm, - &pbdata->parm_data); - } -} - /* Assign RTL expressions to the function's parameters. This may involve copying them into registers and using those registers as the DECL_RTL. */ @@ -3696,11 +3541,7 @@ assign_parms (tree fndecl) struct assign_parm_data_all all; tree parm; vec<tree> fnargs; - unsigned i, bound_no = 0; - tree last_arg = NULL; - rtx last_arg_entry = NULL; - vec<bounds_parm_data> bndargs = vNULL; - bounds_parm_data bdata; + unsigned i; crtl->args.internal_arg_pointer = targetm.calls.internal_arg_pointer (); @@ -3751,15 +3592,6 @@ assign_parms (tree fndecl) assign_parm_find_stack_rtl (parm, &data); assign_parm_adjust_entry_rtl (&data); } - if (!POINTER_BOUNDS_TYPE_P (data.passed_type)) - { - /* Remember where last non bounds arg was passed in case - we have to load associated bounds for it from Bounds - Table. */ - last_arg = parm; - last_arg_entry = data.entry_parm; - bound_no = 0; - } /* Record permanently how this parm was passed. */ if (data.passed_pointer) { @@ -3773,64 +3605,21 @@ assign_parms (tree fndecl) assign_parm_adjust_stack_rtl (&data); - /* Bounds should be loaded in the particular order to - have registers allocated correctly. Collect info about - input bounds and load them later. */ - if (POINTER_BOUNDS_TYPE_P (data.passed_type)) - { - /* Expect bounds in instrumented functions only. */ - gcc_assert (chkp_function_instrumented_p (fndecl)); - - bdata.parm_data = data; - bdata.bounds_parm = parm; - bdata.ptr_parm = last_arg; - bdata.ptr_entry = last_arg_entry; - bdata.bound_no = bound_no; - bndargs.safe_push (bdata); - } + if (assign_parm_setup_block_p (&data)) + assign_parm_setup_block (&all, parm, &data); + else if (data.passed_pointer || use_register_for_decl (parm)) + assign_parm_setup_reg (&all, parm, &data); else - { - if (assign_parm_setup_block_p (&data)) - assign_parm_setup_block (&all, parm, &data); - else if (data.passed_pointer || use_register_for_decl (parm)) - assign_parm_setup_reg (&all, parm, &data); - else - assign_parm_setup_stack (&all, parm, &data); - } + assign_parm_setup_stack (&all, parm, &data); if (cfun->stdarg && !DECL_CHAIN (parm)) - { - int pretend_bytes = 0; - - assign_parms_setup_varargs (&all, &data, false); - - if (chkp_function_instrumented_p (fndecl)) - { - /* We expect this is the last parm. Otherwise it is wrong - to assign bounds right now. */ - gcc_assert (i == (fnargs.length () - 1)); - assign_bounds (bndargs, all, true, false, false); - targetm.calls.setup_incoming_vararg_bounds (all.args_so_far, - data.promoted_mode, - data.passed_type, - &pretend_bytes, - false); - assign_bounds (bndargs, all, false, true, true); - bndargs.release (); - } - } + assign_parms_setup_varargs (&all, &data, false); /* Update info on where next arg arrives in registers. */ targetm.calls.function_arg_advance (all.args_so_far, data.promoted_mode, data.passed_type, data.named_arg); - - if (POINTER_BOUNDS_TYPE_P (data.passed_type)) - bound_no++; } - assign_bounds (bndargs, all, true, true, true); - bndargs.release (); - if (targetm.calls.split_complex_arg) assign_parms_unsplit_complex (&all, fnargs); @@ -3953,10 +3742,6 @@ assign_parms (tree fndecl) real_decl_rtl = targetm.calls.function_value (TREE_TYPE (decl_result), fndecl, true); - if (chkp_function_instrumented_p (fndecl)) - crtl->return_bnd - = targetm.calls.chkp_function_value_bounds (TREE_TYPE (decl_result), - fndecl, true); REG_FUNCTION_VALUE_P (real_decl_rtl) = 1; /* The delay slot scheduler assumes that crtl->return_rtx holds the hard register containing the return value, not a @@ -5238,14 +5023,6 @@ expand_function_start (tree subr) /* Set DECL_REGISTER flag so that expand_function_end will copy the result to the real return register(s). */ DECL_REGISTER (res) = 1; - - if (chkp_function_instrumented_p (current_function_decl)) - { - tree return_type = TREE_TYPE (res); - rtx bounds = targetm.calls.chkp_function_value_bounds (return_type, - subr, 1); - SET_DECL_BOUNDS_RTL (res, bounds); - } } /* Initialize rtx for parameters and local variables. diff --git a/gcc/gcc.c b/gcc/gcc.c index 2c597ec086a..a631caafd3f 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1012,10 +1012,6 @@ proper position among the other output files. */ #endif #endif -#ifndef CHKP_SPEC -#define CHKP_SPEC "" -#endif - /* -u* was put back because both BSD and SysV seem to support it. */ /* %{static|no-pie|static-pie:} simply prevents an error message: 1. If the target machine doesn't handle -static. @@ -1039,7 +1035,7 @@ proper position among the other output files. */ "%X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ %{static|no-pie|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ - VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ %:include(libgomp.spec)%(link_gomp)}\ %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\ diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index f6d758a6828..c1d84420c6e 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -55,7 +55,6 @@ along with GCC; see the file COPYING3. If not see #include "gomp-constants.h" #include "optabs-query.h" #include "omp-general.h" -#include "ipa-chkp.h" #include "tree-cfg.h" #include "fold-const-call.h" #include "stringpool.h" @@ -728,18 +727,6 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, unsigned int src_align, dest_align; tree off0; - /* Inlining of memcpy/memmove may cause bounds lost (if we copy - pointers as wide integer) and also may result in huge function - size because of inlined bounds copy. Thus don't inline for - functions we want to instrument. */ - if (flag_check_pointer_bounds - && chkp_instrumentable_p (cfun->decl) - /* Even if data may contain pointers we can inline if copy - less than a pointer size. */ - && (!tree_fits_uhwi_p (len) - || compare_tree_int (len, POINTER_SIZE_UNITS) >= 0)) - return false; - /* Build accesses at offset zero with a ref-all character type. */ off0 = build_int_cst (build_pointer_type_for_mode (char_type_node, ptr_mode, true), 0); diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 637ed3cc290..cc50fba21d7 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -589,20 +589,14 @@ builtin_access::builtin_access (gcall *call, builtin_memref &dst, /* The size argument number (depends on the built-in). */ unsigned sizeargno = 2; - if (gimple_call_with_bounds_p (call)) - sizeargno += 2; tree func = gimple_call_fndecl (call); switch (DECL_FUNCTION_CODE (func)) { case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMPCPY_CHKP: - case BUILT_IN_MEMPCPY_CHK_CHKP: ostype = 0; depends_p = false; detect_overlap = &builtin_access::generic_overlap; @@ -610,8 +604,6 @@ builtin_access::builtin_access (gcall *call, builtin_memref &dst, case BUILT_IN_MEMMOVE: case BUILT_IN_MEMMOVE_CHK: - case BUILT_IN_MEMMOVE_CHKP: - case BUILT_IN_MEMMOVE_CHK_CHKP: /* For memmove there is never any overlap to check for. */ ostype = 0; depends_p = false; @@ -628,19 +620,13 @@ builtin_access::builtin_access (gcall *call, builtin_memref &dst, case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: detect_overlap = &builtin_access::strcpy_overlap; break; case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHKP: - case BUILT_IN_STRCAT_CHK_CHKP: detect_overlap = &builtin_access::strcat_overlap; break; @@ -654,8 +640,7 @@ builtin_access::builtin_access (gcall *call, builtin_memref &dst, default: /* Handle other string functions here whose access may need to be validated for in-bounds offsets and non-overlapping - copies. (Not all _chkp functions have BUILT_IN_XXX_CHKP - macros so they need to be handled here.) */ + copies. */ return; } @@ -1738,8 +1723,6 @@ wrestrict_dom_walker::check_call (gcall *call) if (!func || DECL_BUILT_IN_CLASS (func) != BUILT_IN_NORMAL) return; - bool with_bounds = gimple_call_with_bounds_p (call); - /* Argument number to extract from the call (depends on the built-in and its kind). */ unsigned dst_idx = -1; @@ -1754,16 +1737,10 @@ wrestrict_dom_walker::check_call (gcall *call) { case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMPCPY_CHKP: - case BUILT_IN_MEMPCPY_CHK_CHKP: case BUILT_IN_MEMMOVE: case BUILT_IN_MEMMOVE_CHK: - case BUILT_IN_MEMMOVE_CHKP: - case BUILT_IN_MEMMOVE_CHK_CHKP: strfun = false; /* Fall through. */ @@ -1774,31 +1751,24 @@ wrestrict_dom_walker::check_call (gcall *call) case BUILT_IN_STRNCPY: case BUILT_IN_STRNCPY_CHK: dst_idx = 0; - src_idx = 1 + with_bounds; - bnd_idx = 2 + 2 * with_bounds; + src_idx = 1; + bnd_idx = 2; break; case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHKP: - case BUILT_IN_STRCAT_CHK_CHKP: dst_idx = 0; - src_idx = 1 + with_bounds; + src_idx = 1; break; default: /* Handle other string functions here whose access may need to be validated for in-bounds offsets and non-overlapping - copies. (Not all _chkp functions have BUILT_IN_XXX_CHKP - macros so they need to be handled here.) */ + copies. */ return; } diff --git a/gcc/gimple.c b/gcc/gimple.c index 4b91151873c..abd28079b2d 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -385,7 +385,6 @@ gimple_build_call_from_tree (tree t, tree fnptrtype) gimple_call_set_nothrow (call, TREE_NOTHROW (t)); gimple_call_set_by_descriptor (call, CALL_EXPR_BY_DESCRIPTOR (t)); gimple_set_no_warning (call, TREE_NO_WARNING (t)); - gimple_call_set_with_bounds (call, CALL_WITH_BOUNDS_P (t)); if (fnptrtype) { diff --git a/gcc/gimple.h b/gcc/gimple.h index 265e3e24398..00a9f207bdf 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -145,7 +145,6 @@ enum gf_mask { GF_CALL_ALLOCA_FOR_VAR = 1 << 5, GF_CALL_INTERNAL = 1 << 6, GF_CALL_CTRL_ALTERING = 1 << 7, - GF_CALL_WITH_BOUNDS = 1 << 8, GF_CALL_MUST_TAIL_CALL = 1 << 9, GF_CALL_BY_DESCRIPTOR = 1 << 10, GF_CALL_NOCF_CHECK = 1 << 11, @@ -2856,44 +2855,6 @@ gimple_call_internal_p (const gimple *gs) return gimple_call_internal_p (gc); } - -/* Return true if call GS is marked as instrumented by - Pointer Bounds Checker. */ - -static inline bool -gimple_call_with_bounds_p (const gcall *gs) -{ - return (gs->subcode & GF_CALL_WITH_BOUNDS) != 0; -} - -static inline bool -gimple_call_with_bounds_p (const gimple *gs) -{ - const gcall *gc = GIMPLE_CHECK2<const gcall *> (gs); - return gimple_call_with_bounds_p (gc); -} - - -/* If INSTRUMENTED_P is true, marm statement GS as instrumented by - Pointer Bounds Checker. */ - -static inline void -gimple_call_set_with_bounds (gcall *gs, bool with_bounds) -{ - if (with_bounds) - gs->subcode |= GF_CALL_WITH_BOUNDS; - else - gs->subcode &= ~GF_CALL_WITH_BOUNDS; -} - -static inline void -gimple_call_set_with_bounds (gimple *gs, bool with_bounds) -{ - gcall *gc = GIMPLE_CHECK2<gcall *> (gs); - gimple_call_set_with_bounds (gc, with_bounds); -} - - /* Return true if call GS is marked as nocf_check. */ static inline bool diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 44cb784620a..32d7ad63ac9 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4859,19 +4859,11 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, individual element initialization. Also don't do this for small all-zero initializers (which aren't big enough to merit clearing), and don't try to make bitwise copies of - TREE_ADDRESSABLE types. + TREE_ADDRESSABLE types. */ - We cannot apply such transformation when compiling chkp static - initializer because creation of initializer image in the memory - will require static initialization of bounds for it. It should - result in another gimplification of similar initializer and we - may fall into infinite loop. */ if (valid_const_initializer && !(cleared || num_nonzero_elements == 0) - && !TREE_ADDRESSABLE (type) - && (!current_function_decl - || !lookup_attribute ("chkp ctor", - DECL_ATTRIBUTES (current_function_decl)))) + && !TREE_ADDRESSABLE (type)) { HOST_WIDE_INT size = int_size_in_bytes (type); unsigned int align; diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c deleted file mode 100644 index b38b542ccb0..00000000000 --- a/gcc/ipa-chkp.c +++ /dev/null @@ -1,876 +0,0 @@ -/* Pointer Bounds Checker IPA passes. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - Contributed by Ilya Enkovich (ilya.enkovich@intel.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/>. */ - -#include "config.h" -#define INCLUDE_STRING -#include "system.h" -#include "coretypes.h" -#include "backend.h" -#include "tree.h" -#include "gimple.h" -#include "tree-pass.h" -#include "stringpool.h" -#include "lto-streamer.h" -#include "stor-layout.h" -#include "calls.h" -#include "cgraph.h" -#include "tree-chkp.h" -#include "tree-inline.h" -#include "ipa-chkp.h" -#include "stringpool.h" -#include "attribs.h" - -/* Pointer Bounds Checker has two IPA passes to support code instrumentation. - - In instrumented code each pointer is provided with bounds. For input - pointer parameters it means we also have bounds passed. For calls it - means we have additional bounds arguments for pointer arguments. - - To have all IPA optimizations working correctly we have to express - dataflow between passed and received bounds explicitly via additional - entries in function declaration arguments list and in function type. - Since we may have both instrumented and not instrumented code at the - same time, we cannot replace all original functions with their - instrumented variants. Therefore we create clones (versions) instead. - - Instrumentation clones creation is a separate IPA pass which is a part - of early local passes. Clones are created after SSA is built (because - instrumentation pass works on SSA) and before any transformations - which may change pointer flow and therefore lead to incorrect code - instrumentation (possibly causing false bounds check failures). - - Instrumentation clones have pointer bounds arguments added right after - pointer arguments. Clones have assembler name of the original - function with suffix added. New assembler name is in transparent - alias chain with the original name. Thus we expect all calls to the - original and instrumented functions look similar in assembler. - - During instrumentation versioning pass we create instrumented versions - of all function with body and also for all their aliases and thunks. - Clones for functions with no body are created on demand (usually - during call instrumentation). - - Original and instrumented function nodes are connected with IPA - reference IPA_REF_CHKP. It is mostly done to have reachability - analysis working correctly. We may have no references to the - instrumented function in the code but it still should be counted - as reachable if the original function is reachable. - - When original function bodies are not needed anymore we release - them and transform functions into a special kind of thunks. Each - thunk has a call edge to the instrumented version. These thunks - help to keep externally visible instrumented functions visible - when linker resolution files are used. Linker has no info about - connection between original and instrumented function and - therefore we may wrongly decide (due to difference in assembler - names) that instrumented function version is local and can be - removed. */ - -#define CHKP_BOUNDS_OF_SYMBOL_PREFIX "__chkp_bounds_of_" -#define CHKP_WRAPPER_SYMBOL_PREFIX "__mpx_wrapper_" - -/* Return 1 calls to FNDECL should be replaced with - a call to wrapper function. */ -bool -chkp_wrap_function (tree fndecl) -{ - if (!flag_chkp_use_wrappers) - return false; - - if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) - { - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_STRLEN: - case BUILT_IN_STRCPY: - case BUILT_IN_STRNCPY: - case BUILT_IN_STPCPY: - case BUILT_IN_STPNCPY: - case BUILT_IN_STRCAT: - case BUILT_IN_STRNCAT: - case BUILT_IN_MEMCPY: - case BUILT_IN_MEMPCPY: - case BUILT_IN_MEMSET: - case BUILT_IN_MEMMOVE: - case BUILT_IN_BZERO: - case BUILT_IN_MALLOC: - case BUILT_IN_CALLOC: - case BUILT_IN_REALLOC: - return 1; - - default: - return 0; - } - } - - return false; -} - -static const char * -chkp_wrap_function_name (tree fndecl) -{ - gcc_assert (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL); - - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_STRLEN: - return CHKP_WRAPPER_SYMBOL_PREFIX "strlen"; - case BUILT_IN_STRCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "strcpy"; - case BUILT_IN_STRNCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "strncpy"; - case BUILT_IN_STPCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "stpcpy"; - case BUILT_IN_STPNCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "stpncpy"; - case BUILT_IN_STRCAT: - return CHKP_WRAPPER_SYMBOL_PREFIX "strcat"; - case BUILT_IN_STRNCAT: - return CHKP_WRAPPER_SYMBOL_PREFIX "strncat"; - case BUILT_IN_MEMCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "memcpy"; - case BUILT_IN_MEMPCPY: - return CHKP_WRAPPER_SYMBOL_PREFIX "mempcpy"; - case BUILT_IN_MEMSET: - return CHKP_WRAPPER_SYMBOL_PREFIX "memset"; - case BUILT_IN_MEMMOVE: - return CHKP_WRAPPER_SYMBOL_PREFIX "memmove"; - case BUILT_IN_BZERO: - return CHKP_WRAPPER_SYMBOL_PREFIX "bzero"; - case BUILT_IN_MALLOC: - return CHKP_WRAPPER_SYMBOL_PREFIX "malloc"; - case BUILT_IN_CALLOC: - return CHKP_WRAPPER_SYMBOL_PREFIX "calloc"; - case BUILT_IN_REALLOC: - return CHKP_WRAPPER_SYMBOL_PREFIX "realloc"; - - default: - gcc_unreachable (); - } - - return ""; -} - -/* Build a clone of FNDECL with a modified name. */ - -static tree -chkp_build_instrumented_fndecl (tree fndecl) -{ - tree new_decl = copy_node (fndecl); - tree new_name; - std::string s; - - /* called_as_built_in checks DECL_NAME to identify calls to - builtins. We want instrumented calls to builtins to be - recognized by called_as_built_in. Therefore use original - DECL_NAME for cloning with no prefixes. */ - s = IDENTIFIER_POINTER (DECL_NAME (fndecl)); - s += ".chkp"; - DECL_NAME (new_decl) = get_identifier (s.c_str ()); - - /* References to the original and to the instrumented version - should look the same in the output assembly. And we cannot - use the same assembler name for the instrumented version - because it conflicts with decl merging algorithms in LTO. - Achieve the result by using transparent alias name for the - instrumented version. */ - if (chkp_wrap_function(fndecl)) - { - new_name = get_identifier (chkp_wrap_function_name (fndecl)); - DECL_VISIBILITY (new_decl) = VISIBILITY_DEFAULT; - } - else - { - s = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)); - s += ".chkp"; - new_name = get_identifier (s.c_str ()); - IDENTIFIER_TRANSPARENT_ALIAS (new_name) = 1; - TREE_CHAIN (new_name) = DECL_ASSEMBLER_NAME (fndecl); - } - SET_DECL_ASSEMBLER_NAME (new_decl, new_name); - - /* For functions with body versioning will make a copy of arguments. - For functions with no body we need to do it here. */ - if (!gimple_has_body_p (fndecl)) - { - tree arg; - - DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl)); - for (arg = DECL_ARGUMENTS (new_decl); arg; arg = DECL_CHAIN (arg)) - DECL_CONTEXT (arg) = new_decl; - } - - /* We are going to modify attributes list and therefore should - make own copy. */ - DECL_ATTRIBUTES (new_decl) = copy_list (DECL_ATTRIBUTES (fndecl)); - - /* Change builtin function code. */ - if (DECL_BUILT_IN (new_decl)) - { - gcc_assert (DECL_BUILT_IN_CLASS (new_decl) == BUILT_IN_NORMAL); - gcc_assert (DECL_FUNCTION_CODE (new_decl) < BEGIN_CHKP_BUILTINS); - DECL_FUNCTION_CODE (new_decl) - = (enum built_in_function)(DECL_FUNCTION_CODE (new_decl) - + BEGIN_CHKP_BUILTINS + 1); - } - - return new_decl; -} - - -/* Fix operands of attribute from ATTRS list named ATTR_NAME. - Integer operands are replaced with values according to - INDEXES map having LEN elements. For operands out of len - we just add DELTA. */ - -static void -chkp_map_attr_arg_indexes (tree attrs, const char *attr_name, - unsigned *indexes, int len, int delta) -{ - tree attr = lookup_attribute (attr_name, attrs); - tree op; - - if (!attr) - return; - - TREE_VALUE (attr) = copy_list (TREE_VALUE (attr)); - for (op = TREE_VALUE (attr); op; op = TREE_CHAIN (op)) - { - int idx; - - if (TREE_CODE (TREE_VALUE (op)) != INTEGER_CST) - continue; - - idx = TREE_INT_CST_LOW (TREE_VALUE (op)); - - /* If idx exceeds indexes length then we just - keep it at the same distance from the last - known arg. */ - if (idx > len) - idx += delta; - else - idx = indexes[idx - 1] + 1; - TREE_VALUE (op) = build_int_cst (TREE_TYPE (TREE_VALUE (op)), idx); - } -} - -/* Make a copy of function type ORIG_TYPE adding pointer - bounds as additional arguments. */ - -tree -chkp_copy_function_type_adding_bounds (tree orig_type) -{ - tree type; - tree arg_type, attrs; - unsigned len = list_length (TYPE_ARG_TYPES (orig_type)); - unsigned *indexes = XALLOCAVEC (unsigned, len); - unsigned idx = 0, new_idx = 0; - - for (arg_type = TYPE_ARG_TYPES (orig_type); - arg_type; - arg_type = TREE_CHAIN (arg_type)) - if (TREE_VALUE (arg_type) == void_type_node) - continue; - else if (BOUNDED_TYPE_P (TREE_VALUE (arg_type)) - || pass_by_reference (NULL, TYPE_MODE (TREE_VALUE (arg_type)), - TREE_VALUE (arg_type), true) - || chkp_type_has_pointer (TREE_VALUE (arg_type))) - break; - - /* We may use original type if there are no bounds passed. */ - if (!arg_type) - return orig_type; - - type = build_distinct_type_copy (orig_type); - TYPE_ARG_TYPES (type) = copy_list (TYPE_ARG_TYPES (type)); - - for (arg_type = TYPE_ARG_TYPES (type); - arg_type; - arg_type = TREE_CHAIN (arg_type)) - { - indexes[idx++] = new_idx++; - - /* pass_by_reference returns 1 for void type, - so check for it first. */ - if (TREE_VALUE (arg_type) == void_type_node) - continue; - else if (BOUNDED_TYPE_P (TREE_VALUE (arg_type)) - || pass_by_reference (NULL, TYPE_MODE (TREE_VALUE (arg_type)), - TREE_VALUE (arg_type), true)) - { - tree new_type = build_tree_list (NULL_TREE, - pointer_bounds_type_node); - TREE_CHAIN (new_type) = TREE_CHAIN (arg_type); - TREE_CHAIN (arg_type) = new_type; - - arg_type = TREE_CHAIN (arg_type); - new_idx++; - } - else if (chkp_type_has_pointer (TREE_VALUE (arg_type))) - { - bitmap slots = BITMAP_ALLOC (NULL); - bitmap_iterator bi; - unsigned bnd_no; - - chkp_find_bound_slots (TREE_VALUE (arg_type), slots); - - EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi) - { - tree new_type = build_tree_list (NULL_TREE, - pointer_bounds_type_node); - TREE_CHAIN (new_type) = TREE_CHAIN (arg_type); - TREE_CHAIN (arg_type) = new_type; - - arg_type = TREE_CHAIN (arg_type); - new_idx++; - } - BITMAP_FREE (slots); - } - } - - /* If function type has attribute with arg indexes then - we have to copy it fixing attribute ops. Map for - fixing is in indexes array. */ - attrs = TYPE_ATTRIBUTES (type); - if (lookup_attribute ("nonnull", attrs) - || lookup_attribute ("format", attrs) - || lookup_attribute ("format_arg", attrs)) - { - int delta = new_idx - len; - attrs = copy_list (TYPE_ATTRIBUTES (type)); - chkp_map_attr_arg_indexes (attrs, "nonnull", indexes, len, delta); - chkp_map_attr_arg_indexes (attrs, "format", indexes, len, delta); - chkp_map_attr_arg_indexes (attrs, "format_arg", indexes, len, delta); - TYPE_ATTRIBUTES (type) = attrs; - } - - return type; -} - -/* For given function FNDECL add bounds arguments to arguments - list. */ - -static void -chkp_add_bounds_params_to_function (tree fndecl) -{ - tree arg; - - for (arg = DECL_ARGUMENTS (fndecl); arg; arg = DECL_CHAIN (arg)) - if (BOUNDED_P (arg)) - { - std::string new_name = CHKP_BOUNDS_OF_SYMBOL_PREFIX; - tree new_arg; - - if (DECL_NAME (arg)) - new_name += IDENTIFIER_POINTER (DECL_NAME (arg)); - else - { - char uid[25]; - snprintf (uid, 25, "D.%u", DECL_UID (arg)); - new_name += uid; - } - - new_arg = build_decl (DECL_SOURCE_LOCATION (arg), PARM_DECL, - get_identifier (new_name.c_str ()), - pointer_bounds_type_node); - DECL_ARG_TYPE (new_arg) = pointer_bounds_type_node; - DECL_CONTEXT (new_arg) = DECL_CONTEXT (arg); - DECL_ARTIFICIAL (new_arg) = 1; - DECL_CHAIN (new_arg) = DECL_CHAIN (arg); - DECL_CHAIN (arg) = new_arg; - - arg = DECL_CHAIN (arg); - - } - else if (chkp_type_has_pointer (TREE_TYPE (arg))) - { - tree orig_arg = arg; - bitmap slots = BITMAP_ALLOC (NULL); - bitmap_iterator bi; - unsigned bnd_no; - - chkp_find_bound_slots (TREE_TYPE (arg), slots); - - EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi) - { - std::string new_name = CHKP_BOUNDS_OF_SYMBOL_PREFIX; - tree new_arg; - char offs[25]; - - if (DECL_NAME (orig_arg)) - new_name += IDENTIFIER_POINTER (DECL_NAME (orig_arg)); - else - { - snprintf (offs, 25, "D.%u", DECL_UID (arg)); - new_name += offs; - } - snprintf (offs, 25, "__%u", bnd_no * POINTER_SIZE / BITS_PER_UNIT); - - new_arg = build_decl (DECL_SOURCE_LOCATION (orig_arg), - PARM_DECL, - get_identifier (new_name.c_str ()), - pointer_bounds_type_node); - DECL_ARG_TYPE (new_arg) = pointer_bounds_type_node; - DECL_CONTEXT (new_arg) = DECL_CONTEXT (orig_arg); - DECL_ARTIFICIAL (new_arg) = 1; - DECL_CHAIN (new_arg) = DECL_CHAIN (arg); - DECL_CHAIN (arg) = new_arg; - - arg = DECL_CHAIN (arg); - } - BITMAP_FREE (slots); - } - - TREE_TYPE (fndecl) = - chkp_copy_function_type_adding_bounds (TREE_TYPE (fndecl)); -} - -/* Return an instrumentation clone for builtin function - FNDECL. Create one if needed. */ - -tree -chkp_maybe_clone_builtin_fndecl (tree fndecl) -{ - tree clone; - enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); - - gcc_assert (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && fcode < BEGIN_CHKP_BUILTINS); - - fcode = (enum built_in_function) (fcode + BEGIN_CHKP_BUILTINS + 1); - clone = builtin_decl_explicit (fcode); - if (clone) - return clone; - - clone = chkp_build_instrumented_fndecl (fndecl); - chkp_add_bounds_params_to_function (clone); - - gcc_assert (DECL_FUNCTION_CODE (clone) == fcode); - - set_builtin_decl (fcode, clone, false); - - return clone; -} - -/* Return 1 if function FNDECL should be instrumented. */ - -bool -chkp_instrumentable_p (tree fndecl) -{ - struct function *fn = DECL_STRUCT_FUNCTION (fndecl); - return (!lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl)) - && (!flag_chkp_instrument_marked_only - || lookup_attribute ("bnd_instrument", DECL_ATTRIBUTES (fndecl))) - && (!fn || !copy_forbidden (fn))); -} - -/* Return clone created for instrumentation of NODE or NULL. */ - -cgraph_node * -chkp_maybe_create_clone (tree fndecl) -{ - cgraph_node *node = cgraph_node::get_create (fndecl); - cgraph_node *clone = node->instrumented_version; - - gcc_assert (!node->instrumentation_clone); - - if (DECL_BUILT_IN (fndecl) - && (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL - || DECL_FUNCTION_CODE (fndecl) >= BEGIN_CHKP_BUILTINS)) - return NULL; - - clone = node->instrumented_version; - - /* Some instrumented builtin function calls may be optimized and - cgraph nodes may be removed as unreachable. Later optimizations - may generate new calls to removed functions and in this case - we have to recreate cgraph node. FUNCTION_DECL for instrumented - builtin still exists and should be reused in such case. */ - if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)) - && !clone) - { - enum built_in_function fncode = DECL_FUNCTION_CODE (fndecl); - tree new_decl; - - fncode = (enum built_in_function) (fncode + BEGIN_CHKP_BUILTINS + 1); - new_decl = builtin_decl_explicit (fncode); - - /* We've actually already created an instrumented clone once. - Restore it. */ - if (new_decl) - { - clone = cgraph_node::get (new_decl); - - if (!clone) - { - gcc_assert (!gimple_has_body_p (fndecl)); - clone = cgraph_node::get_create (new_decl); - clone->externally_visible = node->externally_visible; - clone->local = node->local; - clone->address_taken = node->address_taken; - clone->thunk = node->thunk; - clone->alias = node->alias; - clone->weakref = node->weakref; - clone->cpp_implicit_alias = node->cpp_implicit_alias; - clone->orig_decl = fndecl; - clone->instrumentation_clone = true; - } - - clone->instrumented_version = node; - node->instrumented_version = clone; - } - } - - if (!clone) - { - tree new_decl = chkp_build_instrumented_fndecl (fndecl); - struct cgraph_edge *e; - struct ipa_ref *ref; - int i; - - clone = node->create_version_clone (new_decl, vNULL, NULL); - clone->externally_visible = node->externally_visible; - clone->local = node->local; - clone->address_taken = node->address_taken; - clone->thunk = node->thunk; - clone->alias = node->alias; - clone->weakref = node->weakref; - clone->cpp_implicit_alias = node->cpp_implicit_alias; - clone->instrumented_version = node; - clone->orig_decl = fndecl; - clone->instrumentation_clone = true; - node->instrumented_version = clone; - - if (gimple_has_body_p (fndecl)) - { - gcc_assert (chkp_instrumentable_p (fndecl)); - tree_function_versioning (fndecl, new_decl, NULL, false, - NULL, false, NULL, NULL); - clone->lowered = true; - } - - /* New params are inserted after versioning because it - actually copies args list from the original decl. */ - chkp_add_bounds_params_to_function (new_decl); - - /* Remember builtin fndecl. */ - if (DECL_BUILT_IN_CLASS (clone->decl) == BUILT_IN_NORMAL - && fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) - { - gcc_assert (!builtin_decl_explicit (DECL_FUNCTION_CODE (clone->decl))); - set_builtin_decl (DECL_FUNCTION_CODE (clone->decl), - clone->decl, false); - } - - /* Clones have the same comdat group as originals. */ - if (node->same_comdat_group - || (DECL_ONE_ONLY (node->decl) - && !DECL_EXTERNAL (node->decl))) - clone->add_to_same_comdat_group (node); - - if (gimple_has_body_p (fndecl)) - symtab->call_cgraph_insertion_hooks (clone); - - /* Clone all aliases. */ - for (i = 0; node->iterate_direct_aliases (i, ref); i++) - chkp_maybe_create_clone (ref->referring->decl); - - /* Clone all thunks. */ - for (e = node->callers; e; e = e->next_caller) - if (e->caller->thunk.thunk_p - && !e->caller->thunk.add_pointer_bounds_args - && !e->caller->instrumentation_clone) - { - struct cgraph_node *thunk - = chkp_maybe_create_clone (e->caller->decl); - /* Redirect thunk clone edge to the node clone. */ - thunk->callees->redirect_callee (clone); - } - - /* For aliases and thunks we should make sure target is cloned - to have proper references and edges. */ - if (node->thunk.thunk_p) - chkp_maybe_create_clone (node->callees->callee->decl); - else if (node->alias) - { - struct cgraph_node *target; - - ref = node->ref_list.first_reference (); - if (ref) - { - target = chkp_maybe_create_clone (ref->referred->decl); - clone->create_reference (target, IPA_REF_ALIAS); - } - - if (node->alias_target) - { - if (TREE_CODE (node->alias_target) == FUNCTION_DECL) - { - target = chkp_maybe_create_clone (node->alias_target); - clone->alias_target = target->decl; - } - else - clone->alias_target = node->alias_target; - } - } - - /* Add IPA reference. It's main role is to keep instrumented - version reachable while original node is reachable. */ - ref = node->create_reference (clone, IPA_REF_CHKP, NULL); - } - - return clone; -} - -/* Create clone for all functions to be instrumented. */ - -static unsigned int -chkp_versioning (void) -{ - struct cgraph_node *node; - const char *reason; - - bitmap_obstack_initialize (NULL); - - FOR_EACH_DEFINED_FUNCTION (node) - { - tree decl = node->decl; - if (!node->instrumentation_clone - && !node->instrumented_version - && !node->alias - && !node->thunk.thunk_p - && (!DECL_BUILT_IN (decl) - || (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (decl) < BEGIN_CHKP_BUILTINS))) - { - if (chkp_instrumentable_p (decl)) - chkp_maybe_create_clone (decl); - else if ((reason = copy_forbidden (DECL_STRUCT_FUNCTION (decl)))) - { - if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wchkp, - "function cannot be instrumented")) - inform (DECL_SOURCE_LOCATION (decl), reason, decl); - } - } - } - - /* Mark all aliases and thunks of functions with no instrumented - version as legacy function. */ - FOR_EACH_DEFINED_FUNCTION (node) - { - if (!node->instrumentation_clone - && !node->instrumented_version - && (node->alias || node->thunk.thunk_p) - && !lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (node->decl))) - DECL_ATTRIBUTES (node->decl) - = tree_cons (get_identifier ("bnd_legacy"), NULL, - DECL_ATTRIBUTES (node->decl)); - } - - bitmap_obstack_release (NULL); - - return 0; -} - -/* In this pass we remove bodies of functions having - instrumented version. Functions with removed bodies - become a special kind of thunks to provide a connection - between calls to the original version and instrumented - function. */ - -static unsigned int -chkp_produce_thunks (bool early) -{ - struct cgraph_node *node; - - FOR_EACH_DEFINED_FUNCTION (node) - { - if (!node->instrumentation_clone - && node->instrumented_version - && gimple_has_body_p (node->decl) - && gimple_has_body_p (node->instrumented_version->decl) - && (!lookup_attribute ("always_inline", DECL_ATTRIBUTES (node->decl)) - || !early)) - { - node->release_body (); - node->remove_callees (); - node->remove_all_references (); - - node->thunk.thunk_p = true; - node->thunk.add_pointer_bounds_args = true; - node->create_edge (node->instrumented_version, NULL, - node->count); - node->create_reference (node->instrumented_version, - IPA_REF_CHKP, NULL); - /* Thunk shouldn't be a cdtor. */ - DECL_STATIC_CONSTRUCTOR (node->decl) = 0; - DECL_STATIC_DESTRUCTOR (node->decl) = 0; - } - } - - /* Mark instrumentation clones created for aliases and thunks - as insttrumented so they could be removed as unreachable - now. */ - if (!early) - { - FOR_EACH_DEFINED_FUNCTION (node) - { - if (node->instrumentation_clone - && (node->alias || node->thunk.thunk_p) - && !chkp_function_instrumented_p (node->decl)) - chkp_function_mark_instrumented (node->decl); - } - } - - return TODO_remove_functions; -} - -const pass_data pass_data_ipa_chkp_versioning = -{ - SIMPLE_IPA_PASS, /* type */ - "chkp_versioning", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ -}; - -const pass_data pass_data_ipa_chkp_early_produce_thunks = -{ - SIMPLE_IPA_PASS, /* type */ - "chkp_ecleanup", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ -}; - -const pass_data pass_data_ipa_chkp_produce_thunks = -{ - SIMPLE_IPA_PASS, /* type */ - "chkp_cleanup", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ -}; - -class pass_ipa_chkp_versioning : public simple_ipa_opt_pass -{ -public: - pass_ipa_chkp_versioning (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_ipa_chkp_versioning, ctxt) - {} - - /* opt_pass methods: */ - virtual opt_pass * clone () - { - return new pass_ipa_chkp_versioning (m_ctxt); - } - - virtual bool gate (function *) - { - return flag_check_pointer_bounds; - } - - virtual unsigned int execute (function *) - { - return chkp_versioning (); - } - -}; // class pass_ipa_chkp_versioning - -class pass_ipa_chkp_early_produce_thunks : public simple_ipa_opt_pass -{ -public: - pass_ipa_chkp_early_produce_thunks (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_ipa_chkp_early_produce_thunks, ctxt) - {} - - /* opt_pass methods: */ - virtual opt_pass * clone () - { - return new pass_ipa_chkp_early_produce_thunks (m_ctxt); - } - - virtual bool gate (function *) - { - return flag_check_pointer_bounds; - } - - virtual unsigned int execute (function *) - { - return chkp_produce_thunks (true); - } - -}; // class pass_chkp_produce_thunks - -class pass_ipa_chkp_produce_thunks : public simple_ipa_opt_pass -{ -public: - pass_ipa_chkp_produce_thunks (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_ipa_chkp_produce_thunks, ctxt) - {} - - /* opt_pass methods: */ - virtual opt_pass * clone () - { - return new pass_ipa_chkp_produce_thunks (m_ctxt); - } - - virtual bool gate (function *) - { - return flag_check_pointer_bounds; - } - - virtual unsigned int execute (function *) - { - return chkp_produce_thunks (false); - } - -}; // class pass_chkp_produce_thunks - -simple_ipa_opt_pass * -make_pass_ipa_chkp_versioning (gcc::context *ctxt) -{ - return new pass_ipa_chkp_versioning (ctxt); -} - -simple_ipa_opt_pass * -make_pass_ipa_chkp_early_produce_thunks (gcc::context *ctxt) -{ - return new pass_ipa_chkp_early_produce_thunks (ctxt); -} - -simple_ipa_opt_pass * -make_pass_ipa_chkp_produce_thunks (gcc::context *ctxt) -{ - return new pass_ipa_chkp_produce_thunks (ctxt); -} diff --git a/gcc/ipa-chkp.h b/gcc/ipa-chkp.h deleted file mode 100644 index 5693cba5f82..00000000000 --- a/gcc/ipa-chkp.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Declaration of interface functions of Pointer Bounds Checker. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - -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/>. */ - -#ifndef GCC_IPA_CHKP_H -#define GCC_IPA_CHKP_H - -extern tree chkp_copy_function_type_adding_bounds (tree orig_type); -extern tree chkp_maybe_clone_builtin_fndecl (tree fndecl); -extern cgraph_node *chkp_maybe_create_clone (tree fndecl); -extern bool chkp_instrumentable_p (tree fndecl); -extern bool chkp_wrap_function (tree fndecl); - -#endif /* GCC_IPA_CHKP_H */ diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index e868b9c2623..06611d3b5d7 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1177,7 +1177,7 @@ initialize_node_lattices (struct cgraph_node *node) int i; gcc_checking_assert (node->has_gimple_body_p ()); - if (cgraph_local_p (node)) + if (node->local.local) { int caller_count = 0; node->call_for_symbol_thunks_and_aliases (count_callers, &caller_count, @@ -2271,24 +2271,6 @@ propagate_constants_across_call (struct cgraph_edge *cs) if (parms_count == 0) return false; - /* No propagation through instrumentation thunks is available yet. - It should be possible with proper mapping of call args and - instrumented callee params in the propagation loop below. But - this case mostly occurs when legacy code calls instrumented code - and it is not a primary target for optimizations. - We detect instrumentation thunks in aliases and thunks chain by - checking instrumentation_clone flag for chain source and target. - Going through instrumentation thunks we always have it changed - from 0 to 1 and all other nodes do not change it. */ - if (!cs->callee->instrumentation_clone - && callee->instrumentation_clone) - { - for (i = 0; i < parms_count; i++) - ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, - i)); - return ret; - } - /* If this call goes through a thunk we must not propagate to the first (0th) parameter. However, we might need to uncover a thunk from below a series of aliases first. */ @@ -3967,9 +3949,7 @@ find_more_scalar_values_for_callers_subset (struct cgraph_node *node, if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)) || (i == 0 - && call_passes_through_thunk_p (cs)) - || (!cs->callee->instrumentation_clone - && cs->callee->function_symbol ()->instrumentation_clone)) + && call_passes_through_thunk_p (cs))) { newval = NULL_TREE; break; diff --git a/gcc/ipa-hsa.c b/gcc/ipa-hsa.c index 1df273c7f28..b1b897aeb3a 100644 --- a/gcc/ipa-hsa.c +++ b/gcc/ipa-hsa.c @@ -113,7 +113,7 @@ process_hsa_functions (void) TREE_PUBLIC (clone->decl) = TREE_PUBLIC (node->decl); clone->externally_visible = node->externally_visible; - if (!cgraph_local_p (node)) + if (!node->local.local) clone->force_output = true; hsa_summaries->link_functions (clone, node, HSA_FUNCTION, false); diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 6a5d1e96941..ba39ea36574 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -754,8 +754,7 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2) || gimple_call_return_slot_opt_p (s1) != gimple_call_return_slot_opt_p (s2) || gimple_call_from_thunk_p (s1) != gimple_call_from_thunk_p (s2) || gimple_call_va_arg_pack_p (s1) != gimple_call_va_arg_pack_p (s2) - || gimple_call_alloca_for_var_p (s1) != gimple_call_alloca_for_var_p (s2) - || gimple_call_with_bounds_p (s1) != gimple_call_with_bounds_p (s2)) + || gimple_call_alloca_for_var_p (s1) != gimple_call_alloca_for_var_p (s2)) return false; if (gimple_call_internal_p (s1) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 5a1e13560d6..8958421993a 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1220,8 +1220,7 @@ sem_function::merge (sem_item *alias_item) are not interposable. */ redirect_callers = alias->get_availability () > AVAIL_INTERPOSABLE - && original->get_availability () > AVAIL_INTERPOSABLE - && !alias->instrumented_version; + && original->get_availability () > AVAIL_INTERPOSABLE; /* TODO: We can redirect, but we need to produce alias of ORIGINAL with proper properties. */ if (!sem_item::compare_referenced_symbol_properties (NULL, original, alias, diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index b7f213f2eb7..1d524a9cd4f 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -2712,13 +2712,6 @@ early_inliner (function *fun) node->verify (); node->remove_all_references (); - /* Rebuild this reference because it dosn't depend on - function's body and it's required to pass cgraph_node - verification. */ - if (node->instrumented_version - && !node->instrumentation_clone) - node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL); - /* Even when not optimizing or not inlining inline always-inline functions. */ inlined = inline_always_inline_functions (node); diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 528ea6695ac..1e0bcae6264 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -259,10 +259,6 @@ warn_function_noreturn (tree decl) { tree original_decl = decl; - cgraph_node *node = cgraph_node::get (decl); - if (node->instrumentation_clone) - decl = node->instrumented_version->decl; - static hash_set<tree> *warned_about; if (!lang_hooks.missing_noreturn_ok_p (decl) && targetm.warn_func_return (decl)) @@ -276,10 +272,6 @@ warn_function_cold (tree decl) { tree original_decl = decl; - cgraph_node *node = cgraph_node::get (decl); - if (node->instrumentation_clone) - decl = node->instrumented_version->decl; - static hash_set<tree> *warned_about; warned_about = suggest_attribute (OPT_Wsuggest_attribute_cold, original_decl, @@ -1619,7 +1611,6 @@ propagate_pure_const (void) fprintf (dump_file, " global var write\n"); break; case IPA_REF_ADDR: - case IPA_REF_CHKP: break; default: gcc_unreachable (); diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h index ba788c2eef7..4e22d85ac03 100644 --- a/gcc/ipa-ref.h +++ b/gcc/ipa-ref.h @@ -32,8 +32,7 @@ enum GTY(()) ipa_ref_use IPA_REF_LOAD, IPA_REF_STORE, IPA_REF_ADDR, - IPA_REF_ALIAS, - IPA_REF_CHKP + IPA_REF_ALIAS }; /* Record of reference in callgraph or varpool. */ diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index b03ae02924a..23d1df99bea 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -104,7 +104,6 @@ along with GCC; see the file COPYING3. If not see #include "gimple-pretty-print.h" #include "ipa-fnsummary.h" #include "cfgloop.h" -#include "tree-chkp.h" /* Per basic block info. */ @@ -151,7 +150,6 @@ struct split_point best_split_point; static bitmap forbidden_dominators; static tree find_retval (basic_block return_bb); -static tree find_retbnd (basic_block return_bb); /* Callback for walk_stmt_load_store_addr_ops. If T is non-SSA automatic variable, check it if it is present in bitmap passed via DATA. */ @@ -433,7 +431,6 @@ consider_split (struct split_point *current, bitmap non_ssa_vars, gphi_iterator bsi; unsigned int i; tree retval; - tree retbnd; bool back_edge = false; if (dump_file && (dump_flags & TDF_DETAILS)) @@ -678,29 +675,6 @@ consider_split (struct split_point *current, bitmap non_ssa_vars, else current->split_part_set_retval = true; - /* See if retbnd used by return bb is computed by header or split part. */ - retbnd = find_retbnd (return_bb); - if (retbnd) - { - bool split_part_set_retbnd - = split_part_set_ssa_name_p (retbnd, current, return_bb); - - /* If we have both return value and bounds then keep their definitions - in a single function. We use SSA names to link returned bounds and - value and therefore do not handle cases when result is passed by - reference (which should not be our case anyway since bounds are - returned for pointers only). */ - if ((DECL_BY_REFERENCE (DECL_RESULT (current_function_decl)) - && current->split_part_set_retval) - || split_part_set_retbnd != current->split_part_set_retval) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, - " Refused: split point splits return value and bounds\n"); - return; - } - } - /* split_function fixes up at most one PHI non-virtual PHI node in return_bb, for the return value. If there are other PHIs, give up. */ if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun)) @@ -830,18 +804,6 @@ find_retval (basic_block return_bb) return NULL; } -/* Given return basic block RETURN_BB, see where return bounds are really - stored. */ -static tree -find_retbnd (basic_block return_bb) -{ - gimple_stmt_iterator bsi; - for (bsi = gsi_last_bb (return_bb); !gsi_end_p (bsi); gsi_prev (&bsi)) - if (gimple_code (gsi_stmt (bsi)) == GIMPLE_RETURN) - return gimple_return_retbnd (gsi_stmt (bsi)); - return NULL; -} - /* Callback for walk_stmt_load_store_addr_ops. If T is non-SSA automatic variable, mark it as used in bitmap passed via DATA. Return true when access to T prevents splitting the function. */ @@ -1228,8 +1190,7 @@ split_function (basic_block return_bb, struct split_point *split_point, gcall *call, *tsan_func_exit_call = NULL; edge e; edge_iterator ei; - tree retval = NULL, real_retval = NULL, retbnd = NULL; - bool with_bounds = chkp_function_instrumented_p (current_function_decl); + tree retval = NULL, real_retval = NULL; gimple *last_stmt = NULL; unsigned int i; tree arg, ddef; @@ -1311,14 +1272,10 @@ split_function (basic_block return_bb, struct split_point *split_point, e = make_single_succ_edge (new_return_bb, EXIT_BLOCK_PTR_FOR_FN (cfun), 0); add_bb_to_loop (new_return_bb, current_loops->tree_root); bitmap_set_bit (split_point->split_bbs, new_return_bb->index); - retbnd = find_retbnd (return_bb); } /* When we pass around the value, use existing return block. */ else - { - bitmap_set_bit (split_point->split_bbs, return_bb->index); - retbnd = find_retbnd (return_bb); - } + bitmap_set_bit (split_point->split_bbs, return_bb->index); /* If RETURN_BB has virtual operand PHIs, they must be removed and the virtual operand marked for renaming as we change the CFG in a way that @@ -1434,11 +1391,6 @@ split_function (basic_block return_bb, struct split_point *split_point, } } - /* If the original function is instrumented then it's - part is also instrumented. */ - if (with_bounds) - chkp_function_mark_instrumented (node->decl); - /* If the original function is declared inline, there is no point in issuing a warning for the non-inlinable part. */ DECL_NO_INLINE_WARNING_P (node->decl) = 1; @@ -1474,7 +1426,6 @@ split_function (basic_block return_bb, struct split_point *split_point, args_to_pass[i] = arg; } call = gimple_build_call_vec (node->decl, args_to_pass); - gimple_call_set_with_bounds (call, with_bounds); gimple_set_block (call, DECL_INITIAL (current_function_decl)); args_to_pass.release (); @@ -1618,21 +1569,6 @@ split_function (basic_block return_bb, struct split_point *split_point, } } } - - /* Replace retbnd with new one. */ - if (retbnd) - { - gimple_stmt_iterator bsi; - for (bsi = gsi_last_bb (return_bb); !gsi_end_p (bsi); - gsi_prev (&bsi)) - if (gimple_code (gsi_stmt (bsi)) == GIMPLE_RETURN) - { - retbnd = copy_ssa_name (retbnd, call); - gimple_return_set_retbnd (gsi_stmt (bsi), retbnd); - update_stmt (gsi_stmt (bsi)); - break; - } - } } if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl))) { @@ -1653,9 +1589,6 @@ split_function (basic_block return_bb, struct split_point *split_point, gsi_insert_after (&gsi, cpy, GSI_NEW_STMT); retval = tem; } - /* Build bndret call to obtain returned bounds. */ - if (retbnd) - chkp_insert_retbnd_call (retbnd, retval, &gsi); gimple_call_set_lhs (call, retval); update_stmt (call); } @@ -1676,10 +1609,6 @@ split_function (basic_block return_bb, struct split_point *split_point, { retval = DECL_RESULT (current_function_decl); - if (chkp_function_instrumented_p (current_function_decl) - && BOUNDED_P (retval)) - retbnd = create_tmp_reg (pointer_bounds_type_node); - /* We use temporary register to hold value when aggregate_value_p is false. Similarly for DECL_BY_REFERENCE we must avoid extra copy. */ @@ -1717,9 +1646,6 @@ split_function (basic_block return_bb, struct split_point *split_point, gsi_insert_after (&gsi, g, GSI_NEW_STMT); } } - /* Build bndret call to obtain returned bounds. */ - if (retbnd) - chkp_insert_retbnd_call (retbnd, retval, &gsi); if (tsan_func_exit_call) gsi_insert_after (&gsi, tsan_func_exit_call, GSI_NEW_STMT); ret = gimple_build_return (retval); diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index a82852b3ce4..907dc9d0e2b 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -245,10 +245,6 @@ cgraph_externally_visible_p (struct cgraph_node *node, if (MAIN_NAME_P (DECL_NAME (node->decl))) return true; - if (node->instrumentation_clone - && MAIN_NAME_P (DECL_NAME (node->orig_decl))) - return true; - return false; } diff --git a/gcc/ipa.c b/gcc/ipa.c index 634c69c2b5c..82fc334ec0b 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -240,13 +240,7 @@ walk_polymorphic_call_targets (hash_set<void *> *reachable_call_targets, if (ipa_fn_summaries) ipa_update_overall_fn_summary (node); else if (edge->call_stmt) - { - edge->redirect_call_stmt_to_callee (); - - /* Call to __builtin_unreachable shouldn't be instrumented. */ - if (!targets.length ()) - gimple_call_set_with_bounds (edge->call_stmt, false); - } + edge->redirect_call_stmt_to_callee (); } } } @@ -462,20 +456,6 @@ symbol_table::remove_unreachable_nodes (FILE *file) if (cnode->global.inlined_to) body_needed_for_clonning.add (cnode->decl); - /* For instrumentation clones we always need original - function node for proper LTO privatization. */ - if (cnode->instrumentation_clone - && cnode->definition) - { - gcc_assert (cnode->instrumented_version || in_lto_p); - if (cnode->instrumented_version) - { - enqueue_node (cnode->instrumented_version, &first, - &reachable); - reachable.add (cnode->instrumented_version); - } - } - /* For non-inline clones, force their origins to the boundary and ensure that body is not removed. */ while (cnode->clone_of) @@ -643,8 +623,7 @@ symbol_table::remove_unreachable_nodes (FILE *file) } /* Keep body if it may be useful for constant folding. */ if ((flag_wpa || flag_incremental_link == INCREMENTAL_LINK_LTO) - || ((init = ctor_for_folding (vnode->decl)) == error_mark_node - && !POINTER_BOUNDS_P (vnode->decl))) + || ((init = ctor_for_folding (vnode->decl)) == error_mark_node)) vnode->remove_initializer (); else DECL_INITIAL (vnode->decl) = init; @@ -669,10 +648,7 @@ symbol_table::remove_unreachable_nodes (FILE *file) && !node->used_from_other_partition) { if (!node->call_for_symbol_and_aliases - (has_addr_references_p, NULL, true) - && (!node->instrumentation_clone - || !node->instrumented_version - || !node->instrumented_version->address_taken)) + (has_addr_references_p, NULL, true)) { if (file) fprintf (file, " %s", node->name ()); @@ -740,8 +716,6 @@ process_references (varpool_node *vnode, process_references (dyn_cast<varpool_node *> (ref->referring), written, address_taken, read, explicit_refs); break; - case IPA_REF_CHKP: - gcc_unreachable (); } } @@ -847,9 +821,8 @@ ipa_discover_readonly_nonaddressable_vars (void) } /* Generate and emit a static constructor or destructor. WHICH must - be one of 'I' (for a constructor), 'D' (for a destructor), 'P' - (for chp static vars constructor) or 'B' (for chkp static bounds - constructor). BODY is a STATEMENT_LIST containing GENERIC + be one of 'I' (for a constructor), 'D' (for a destructor). + BODY is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the initialization priority for this constructor or destructor. @@ -912,20 +885,6 @@ cgraph_build_static_cdtor_1 (char which, tree body, int priority, bool final) DECL_STATIC_CONSTRUCTOR (decl) = 1; decl_init_priority_insert (decl, priority); break; - case 'P': - DECL_STATIC_CONSTRUCTOR (decl) = 1; - DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("chkp ctor"), - NULL, - NULL_TREE); - decl_init_priority_insert (decl, priority); - break; - case 'B': - DECL_STATIC_CONSTRUCTOR (decl) = 1; - DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("bnd_legacy"), - NULL, - NULL_TREE); - decl_init_priority_insert (decl, priority); - break; case 'D': DECL_STATIC_DESTRUCTOR (decl) = 1; decl_fini_priority_insert (decl, priority); @@ -943,9 +902,8 @@ cgraph_build_static_cdtor_1 (char which, tree body, int priority, bool final) } /* Generate and emit a static constructor or destructor. WHICH must - be one of 'I' (for a constructor), 'D' (for a destructor), 'P' - (for chkp static vars constructor) or 'B' (for chkp static bounds - constructor). BODY is a STATEMENT_LIST containing GENERIC + be one of 'I' (for a constructor) or 'D' (for a destructor). + BODY is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the initialization priority for this constructor or destructor. */ diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 8439babc4fe..a57bda9437d 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -37,7 +37,6 @@ along with GCC; see the file COPYING3. If not see #include "pass_manager.h" #include "ipa-utils.h" #include "omp-offload.h" -#include "ipa-chkp.h" #include "stringpool.h" #include "attribs.h" @@ -544,7 +543,6 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, /* When doing incremental link, we will get new resolution info next time we process the file. */ flag_incremental_link ? LDPR_UNKNOWN : node->resolution); - bp_pack_value (&bp, node->instrumentation_clone, 1); bp_pack_value (&bp, node->split_part, 1); streamer_write_bitpack (&bp); streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1); @@ -564,9 +562,6 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, streamer_write_hwi_stream (ob->main_stream, node->get_init_priority ()); if (DECL_STATIC_DESTRUCTOR (node->decl)) streamer_write_hwi_stream (ob->main_stream, node->get_fini_priority ()); - - if (node->instrumentation_clone) - lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->orig_decl); } /* Output the varpool NODE to OB. @@ -775,33 +770,11 @@ output_refs (lto_symtab_encoder_t encoder) { symtab_node *node = lto_symtab_encoder_deref (encoder, i); - /* IPA_REF_ALIAS and IPA_REF_CHKP references are always preserved + /* IPA_REF_ALIAS references are always preserved in the boundary. Alias node can't have other references and can be always handled as if it's not in the boundary. */ if (!node->alias && !lto_symtab_encoder_in_partition_p (encoder, node)) - { - cgraph_node *cnode = dyn_cast <cgraph_node *> (node); - /* Output IPA_REF_CHKP reference. */ - if (cnode - && cnode->instrumented_version - && !cnode->instrumentation_clone) - { - for (int i = 0; node->iterate_reference (i, ref); i++) - if (ref->use == IPA_REF_CHKP) - { - if (lto_symtab_encoder_lookup (encoder, ref->referred) - != LCC_NOT_FOUND) - { - int nref = lto_symtab_encoder_lookup (encoder, node); - streamer_write_gcov_count_stream (ob->main_stream, 1); - streamer_write_uhwi_stream (ob->main_stream, nref); - lto_output_ref (ob, ref, encoder); - } - break; - } - } - continue; - } + continue; count = node->ref_list.nreferences (); if (count) @@ -913,8 +886,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) && (((vnode->ctor_useable_for_folding_p () && (!DECL_VIRTUAL_P (vnode->decl) || !flag_wpa - || flag_ltrans_devirtualize)) - || POINTER_BOUNDS_P (vnode->decl)))) + || flag_ltrans_devirtualize))))) { lto_set_symtab_encoder_encode_initializer (encoder, vnode); create_references (encoder, vnode); @@ -1204,7 +1176,6 @@ input_overwrite_node (struct lto_file_decl_data *file_data, node->parallelized_function = bp_unpack_value (bp, 1); node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution, LDPR_NUM_KNOWN); - node->instrumentation_clone = bp_unpack_value (bp, 1); node->split_part = bp_unpack_value (bp, 1); gcc_assert (flag_ltrans || (!node->in_other_partition @@ -1340,13 +1311,6 @@ input_node (struct lto_file_decl_data *file_data, if (DECL_STATIC_DESTRUCTOR (node->decl)) node->set_fini_priority (streamer_read_hwi (ib)); - if (node->instrumentation_clone) - { - decl_index = streamer_read_uhwi (ib); - fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index); - node->orig_decl = fn_decl; - } - return node; } @@ -1588,35 +1552,6 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, = dyn_cast<cgraph_node *> (nodes[ref]); else cnode->global.inlined_to = NULL; - - /* Compute instrumented_version. */ - if (cnode->instrumentation_clone) - { - gcc_assert (cnode->orig_decl); - - cnode->instrumented_version = cgraph_node::get (cnode->orig_decl); - if (cnode->instrumented_version) - { - /* We may have multiple nodes for a single function which - will be merged later. To have a proper merge we need - to keep instrumentation_version reference between nodes - consistent: each instrumented_version reference should - have proper reverse reference. Thus don't break existing - instrumented_version reference if it already exists. */ - if (cnode->instrumented_version->instrumented_version) - cnode->instrumented_version = NULL; - else - cnode->instrumented_version->instrumented_version = cnode; - } - - /* Restore decl names reference except for wrapper functions. */ - if (!chkp_wrap_function (cnode->orig_decl)) - { - tree name = DECL_ASSEMBLER_NAME (cnode->decl); - IDENTIFIER_TRANSPARENT_ALIAS (name) = 1; - TREE_CHAIN (name) = DECL_ASSEMBLER_NAME (cnode->orig_decl); - } - } } ref = (int) (intptr_t) node->same_comdat_group; diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index f77634aae6a..5cf1dce33c6 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,11 @@ +2018-06-08 Martin Liska <mliska@suse.cz> + + * lto-partition.c (add_references_to_partition): Remove support + for MPX (macros, related functions, fields in cgraph_node, ...). + (add_symbol_to_partition_1): Likewise. + (privatize_symbol_name): Likewise. + * lto-symtab.c (lto_cgraph_replace_node): Likewise. + 2018-06-05 Richard Biener <rguenther@suse.de> * lto.c (cmp_type_location): Expand locations only once. diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index fd796e12a2d..e8207fb7230 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -115,8 +115,7 @@ add_references_to_partition (ltrans_partition part, symtab_node *node) references, too. */ else if (is_a <varpool_node *> (ref->referred) && (dyn_cast <varpool_node *> (ref->referred) - ->ctor_useable_for_folding_p () - || POINTER_BOUNDS_P (ref->referred->decl)) + ->ctor_useable_for_folding_p ()) && !lto_symtab_encoder_in_partition_p (part->encoder, ref->referred)) { if (!part->initializers_visited) @@ -185,11 +184,6 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node) for (e = cnode->callers; e; e = e->next_caller) if (e->caller->thunk.thunk_p && !e->caller->global.inlined_to) add_symbol_to_partition_1 (part, e->caller); - - /* Instrumented version is actually the same function. - Therefore put it into the same partition. */ - if (cnode->instrumented_version) - add_symbol_to_partition_1 (part, cnode->instrumented_version); } add_references_to_partition (part, node); @@ -1003,30 +997,6 @@ privatize_symbol_name (symtab_node *node) if (!privatize_symbol_name_1 (node, node->decl)) return false; - /* We could change name which is a target of transparent alias - chain of instrumented function name. Fix alias chain if so .*/ - if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) - { - tree iname = NULL_TREE; - if (cnode->instrumentation_clone) - { - /* If we want to privatize instrumentation clone - then we also need to privatize original function. */ - if (cnode->instrumented_version) - privatize_symbol_name (cnode->instrumented_version); - else - privatize_symbol_name_1 (cnode, cnode->orig_decl); - iname = DECL_ASSEMBLER_NAME (cnode->decl); - TREE_CHAIN (iname) = DECL_ASSEMBLER_NAME (cnode->orig_decl); - } - else if (cnode->instrumented_version - && cnode->instrumented_version->orig_decl == cnode->decl) - { - iname = DECL_ASSEMBLER_NAME (cnode->instrumented_version->decl); - TREE_CHAIN (iname) = DECL_ASSEMBLER_NAME (cnode->decl); - } - } - return true; } diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c index 3663ab7a9b2..b1df9bb77d1 100644 --- a/gcc/lto/lto-symtab.c +++ b/gcc/lto/lto-symtab.c @@ -89,21 +89,6 @@ lto_cgraph_replace_node (struct cgraph_node *node, } /* Redirect incomming references. */ prevailing_node->clone_referring (node); - - /* Fix instrumentation references. */ - if (node->instrumented_version) - { - gcc_assert (node->instrumentation_clone - == prevailing_node->instrumentation_clone); - node->instrumented_version->instrumented_version = prevailing_node; - if (!prevailing_node->instrumented_version) - prevailing_node->instrumented_version = node->instrumented_version; - /* Need to reset node->instrumented_version to NULL, - otherwise node removal code would reset - node->instrumented_version->instrumented_version. */ - node->instrumented_version = NULL; - } - lto_free_function_in_decl_state_for_node (node); if (node->decl != prevailing_node->decl) diff --git a/gcc/params.def b/gcc/params.def index 6b955a5deec..a3906c26881 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -1238,12 +1238,6 @@ DEFPARAM (PARAM_UNINIT_CONTROL_DEP_ATTEMPTS, "during uninitialized variable analysis.", 1000, 1, 0) -DEFPARAM (PARAM_CHKP_MAX_CTOR_SIZE, - "chkp-max-ctor-size", - "Maximum number of statements to be included into a single static " - "constructor generated by Pointer Bounds Checker.", - 5000, 100, 0) - DEFPARAM (PARAM_FSM_SCALE_PATH_STMTS, "fsm-scale-path-stmts", "Scale factor to apply to the number of statements in a threading path when comparing to the number of (scaled) blocks.", diff --git a/gcc/passes.c b/gcc/passes.c index 2c711f0c0b0..ee42009b620 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -117,8 +117,6 @@ void pass_manager::execute_early_local_passes () { execute_pass_list (cfun, pass_build_ssa_passes_1->sub); - if (flag_check_pointer_bounds) - execute_pass_list (cfun, pass_chkp_instrumentation_passes_1->sub); execute_pass_list (cfun, pass_local_optimization_passes_1->sub); } @@ -432,36 +430,6 @@ public: }; // class pass_build_ssa_passes -const pass_data pass_data_chkp_instrumentation_passes = -{ - SIMPLE_IPA_PASS, /* type */ - "chkp_passes", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ -}; - -class pass_chkp_instrumentation_passes : public simple_ipa_opt_pass -{ -public: - pass_chkp_instrumentation_passes (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_chkp_instrumentation_passes, ctxt) - {} - - /* opt_pass methods: */ - virtual bool gate (function *) - { - /* Don't bother doing anything if the program has errors. */ - return (flag_check_pointer_bounds - && !seen_error () && !in_lto_p); - } - -}; // class pass_chkp_instrumentation_passes - const pass_data pass_data_local_optimization_passes = { SIMPLE_IPA_PASS, /* type */ @@ -500,12 +468,6 @@ make_pass_build_ssa_passes (gcc::context *ctxt) } simple_ipa_opt_pass * -make_pass_chkp_instrumentation_passes (gcc::context *ctxt) -{ - return new pass_chkp_instrumentation_passes (ctxt); -} - -simple_ipa_opt_pass * make_pass_local_optimization_passes (gcc::context *ctxt) { return new pass_local_optimization_passes (ctxt); diff --git a/gcc/passes.def b/gcc/passes.def index 055d354f959..2a8fbc2efbe 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -51,8 +51,6 @@ along with GCC; see the file COPYING3. If not see INSERT_PASSES_AFTER (all_small_ipa_passes) NEXT_PASS (pass_ipa_free_lang_data); NEXT_PASS (pass_ipa_function_and_variable_visibility); - NEXT_PASS (pass_ipa_chkp_versioning); - NEXT_PASS (pass_ipa_chkp_early_produce_thunks); NEXT_PASS (pass_build_ssa_passes); PUSH_INSERT_PASSES_WITHIN (pass_build_ssa_passes) NEXT_PASS (pass_fixup_cfg); @@ -64,13 +62,6 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_rebuild_cgraph_edges); POP_INSERT_PASSES () - NEXT_PASS (pass_chkp_instrumentation_passes); - PUSH_INSERT_PASSES_WITHIN (pass_chkp_instrumentation_passes) - NEXT_PASS (pass_fixup_cfg); - NEXT_PASS (pass_chkp); - NEXT_PASS (pass_rebuild_cgraph_edges); - POP_INSERT_PASSES () - NEXT_PASS (pass_local_optimization_passes); PUSH_INSERT_PASSES_WITHIN (pass_local_optimization_passes) NEXT_PASS (pass_fixup_cfg); @@ -138,7 +129,6 @@ along with GCC; see the file COPYING3. If not see POP_INSERT_PASSES () NEXT_PASS (pass_target_clone); - NEXT_PASS (pass_ipa_chkp_produce_thunks); NEXT_PASS (pass_ipa_auto_profile); NEXT_PASS (pass_ipa_tree_profile); PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) @@ -211,7 +201,6 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_merge_phi); NEXT_PASS (pass_thread_jumps); NEXT_PASS (pass_vrp, true /* warn_array_bounds_p */); - NEXT_PASS (pass_chkp_opt); NEXT_PASS (pass_dce); NEXT_PASS (pass_stdarg); NEXT_PASS (pass_call_cdce); diff --git a/gcc/rtl-chkp.c b/gcc/rtl-chkp.c deleted file mode 100644 index 0149349ce08..00000000000 --- a/gcc/rtl-chkp.c +++ /dev/null @@ -1,302 +0,0 @@ -/* RTL manipulation functions exported by Pointer Bounds Checker. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - Contributed by Ilya Enkovich (ilya.enkovich@intel.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/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "backend.h" -#include "target.h" -#include "rtl.h" -#include "tree.h" -#include "memmodel.h" -#include "emit-rtl.h" -#include "expr.h" -#include "rtl-chkp.h" -#include "tree-chkp.h" - -static hash_map<tree, rtx> *chkp_rtx_bounds_map; - -/* Get bounds rtx associated with NODE via - chkp_set_rtl_bounds call. */ -rtx -chkp_get_rtl_bounds (tree node) -{ - rtx *slot; - - if (!chkp_rtx_bounds_map) - return NULL_RTX; - - slot = chkp_rtx_bounds_map->get (node); - return slot ? *slot : NULL_RTX; -} - -/* Associate bounds rtx VAL with NODE. */ -void -chkp_set_rtl_bounds (tree node, rtx val) -{ - if (!chkp_rtx_bounds_map) - chkp_rtx_bounds_map = new hash_map<tree, rtx>; - - chkp_rtx_bounds_map->put (node, val); -} - -/* Reset all bounds stored via chkp_set_rtl_bounds. */ -void -chkp_reset_rtl_bounds () -{ - if (!chkp_rtx_bounds_map) - return; - - delete chkp_rtx_bounds_map; - chkp_rtx_bounds_map = NULL; -} - -/* Split SLOT identifying slot for function value or - argument into two parts SLOT_VAL and SLOT_BND. - First is the slot for regular value and the other one is - for bounds. */ -void -chkp_split_slot (rtx slot, rtx *slot_val, rtx *slot_bnd) -{ - int i; - int val_num = 0; - int bnd_num = 0; - rtx *val_tmps; - rtx *bnd_tmps; - - *slot_bnd = 0; - - if (!slot - || GET_CODE (slot) != PARALLEL) - { - *slot_val = slot; - return; - } - - val_tmps = XALLOCAVEC (rtx, XVECLEN (slot, 0)); - bnd_tmps = XALLOCAVEC (rtx, XVECLEN (slot, 0)); - - for (i = 0; i < XVECLEN (slot, 0); i++) - { - rtx elem = XVECEXP (slot, 0, i); - rtx reg = GET_CODE (elem) == EXPR_LIST ? XEXP (elem, 0) : elem; - - if (!reg) - continue; - - if (POINTER_BOUNDS_MODE_P (GET_MODE (reg)) || CONST_INT_P (reg)) - bnd_tmps[bnd_num++] = elem; - else - val_tmps[val_num++] = elem; - } - - gcc_assert (val_num); - - if (!bnd_num) - { - *slot_val = slot; - return; - } - - if ((GET_CODE (val_tmps[0]) == EXPR_LIST) || (val_num > 1)) - *slot_val = gen_rtx_PARALLEL (GET_MODE (slot), - gen_rtvec_v (val_num, val_tmps)); - else - *slot_val = val_tmps[0]; - - if ((GET_CODE (bnd_tmps[0]) == EXPR_LIST) || (bnd_num > 1)) - *slot_bnd = gen_rtx_PARALLEL (VOIDmode, - gen_rtvec_v (bnd_num, bnd_tmps)); - else - *slot_bnd = bnd_tmps[0]; -} - -/* Join previously splitted to VAL and BND rtx for function - value or argument and return it. */ -rtx -chkp_join_splitted_slot (rtx val, rtx bnd) -{ - rtx res; - int i, n = 0; - - if (!bnd) - return val; - - if (GET_CODE (val) == PARALLEL) - n += XVECLEN (val, 0); - else - n++; - - if (GET_CODE (bnd) == PARALLEL) - n += XVECLEN (bnd, 0); - else - n++; - - res = gen_rtx_PARALLEL (GET_MODE (val), rtvec_alloc (n)); - - n = 0; - - if (GET_CODE (val) == PARALLEL) - for (i = 0; i < XVECLEN (val, 0); i++) - XVECEXP (res, 0, n++) = XVECEXP (val, 0, i); - else - XVECEXP (res, 0, n++) = val; - - if (GET_CODE (bnd) == PARALLEL) - for (i = 0; i < XVECLEN (bnd, 0); i++) - XVECEXP (res, 0, n++) = XVECEXP (bnd, 0, i); - else - XVECEXP (res, 0, n++) = bnd; - - return res; -} - -/* If PAR is PARALLEL holding registers then transform - it into PARALLEL holding EXPR_LISTs of those regs - and zero constant (similar to how function value - on multiple registers looks like). */ -void -chkp_put_regs_to_expr_list (rtx par) -{ - int n; - - if (GET_CODE (par) != PARALLEL - || GET_CODE (XVECEXP (par, 0, 0)) == EXPR_LIST) - return; - - for (n = 0; n < XVECLEN (par, 0); n++) - XVECEXP (par, 0, n) = gen_rtx_EXPR_LIST (VOIDmode, - XVECEXP (par, 0, n), - const0_rtx); -} - -/* Search rtx PAR describing function return value for an - item related to value at offset OFFS and return it. - Return NULL if item was not found. */ -rtx -chkp_get_value_with_offs (rtx par, rtx offs) -{ - int n; - - gcc_assert (GET_CODE (par) == PARALLEL); - - for (n = 0; n < XVECLEN (par, 0); n++) - { - rtx par_offs = XEXP (XVECEXP (par, 0, n), 1); - if (INTVAL (offs) == INTVAL (par_offs)) - return XEXP (XVECEXP (par, 0, n), 0); - } - - return NULL; -} - -/* Emit instructions to store BOUNDS for pointer VALUE - stored in MEM. - Function is used by expand to pass bounds for args - passed on stack. */ -void -chkp_emit_bounds_store (rtx bounds, rtx value, rtx mem) -{ - gcc_assert (MEM_P (mem)); - - if (REG_P (bounds) || CONST_INT_P (bounds)) - { - rtx ptr; - - if (REG_P (value)) - ptr = value; - else - { - rtx slot = adjust_address (value, Pmode, 0); - ptr = gen_reg_rtx (Pmode); - emit_move_insn (ptr, slot); - } - - if (CONST_INT_P (bounds)) - bounds = targetm.calls.load_bounds_for_arg (value, ptr, bounds); - - targetm.calls.store_bounds_for_arg (ptr, mem, - bounds, NULL); - } - else - { - int i; - - gcc_assert (GET_CODE (bounds) == PARALLEL); - gcc_assert (GET_CODE (value) == PARALLEL || MEM_P (value) || REG_P (value)); - - for (i = 0; i < XVECLEN (bounds, 0); i++) - { - rtx reg = XEXP (XVECEXP (bounds, 0, i), 0); - rtx offs = XEXP (XVECEXP (bounds, 0, i), 1); - rtx slot = adjust_address (mem, Pmode, INTVAL (offs)); - rtx ptr; - - if (GET_CODE (value) == PARALLEL) - ptr = chkp_get_value_with_offs (value, offs); - else if (MEM_P (value)) - { - rtx tmp = adjust_address (value, Pmode, INTVAL (offs)); - ptr = gen_reg_rtx (Pmode); - emit_move_insn (ptr, tmp); - } - else - ptr = gen_rtx_SUBREG (Pmode, value, INTVAL (offs)); - - targetm.calls.store_bounds_for_arg (ptr, slot, reg, NULL); - } - } -} - -/* Emit code to copy bounds for structure VALUE of type TYPE - copied to SLOT. */ -void -chkp_copy_bounds_for_stack_parm (rtx slot, rtx value, tree type) -{ - bitmap have_bound; - bitmap_iterator bi; - unsigned i; - rtx tmp = NULL, bnd; - - gcc_assert (TYPE_SIZE (type)); - gcc_assert (MEM_P (value)); - gcc_assert (MEM_P (slot)); - gcc_assert (RECORD_OR_UNION_TYPE_P (type)); - - bitmap_obstack_initialize (NULL); - have_bound = BITMAP_ALLOC (NULL); - chkp_find_bound_slots (type, have_bound); - - EXECUTE_IF_SET_IN_BITMAP (have_bound, 0, i, bi) - { - rtx ptr = adjust_address (value, Pmode, i * POINTER_SIZE / 8); - rtx to = adjust_address (slot, Pmode, i * POINTER_SIZE / 8); - - if (!tmp) - tmp = gen_reg_rtx (Pmode); - - emit_move_insn (tmp, ptr); - bnd = targetm.calls.load_bounds_for_arg (ptr, tmp, NULL); - targetm.calls.store_bounds_for_arg (tmp, to, bnd, NULL); - } - - BITMAP_FREE (have_bound); - bitmap_obstack_release (NULL); -} diff --git a/gcc/rtl-chkp.h b/gcc/rtl-chkp.h deleted file mode 100644 index ac4f5cf1678..00000000000 --- a/gcc/rtl-chkp.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Declaration of interface functions of Pointer Bounds Checker. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - -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/>. */ - -#ifndef GCC_RTL_CHKP_H -#define GCC_RTL_CHKP_H - -#define DECL_BOUNDS_RTL(NODE) (chkp_get_rtl_bounds (DECL_WRTL_CHECK (NODE))) - -#define SET_DECL_BOUNDS_RTL(NODE, VAL) \ - (chkp_set_rtl_bounds (DECL_WRTL_CHECK (NODE), VAL)) - -extern rtx chkp_get_rtl_bounds (tree node); -extern void chkp_set_rtl_bounds (tree node, rtx val); -extern void chkp_reset_rtl_bounds (); -extern void chkp_split_slot (rtx slot, rtx *slot_val, rtx *slot_bnd); -extern rtx chkp_join_splitted_slot (rtx val, rtx bnd); -extern rtx chkp_get_value_with_offs (rtx par, rtx offs); -extern void chkp_copy_bounds_for_stack_parm (rtx slot, rtx value, tree type); -extern void chkp_emit_bounds_store (rtx bounds, rtx value, rtx mem); -extern void chkp_put_regs_to_expr_list (rtx par); - -#endif /* GCC_RTL_CHKP_H */ diff --git a/gcc/rtl.h b/gcc/rtl.h index 0341ba01614..bd610e28f43 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -321,7 +321,6 @@ struct GTY((desc("0"), tag("0"), 1 in a VALUE is SP_BASED_VALUE_P in cselib.c. 1 in a SUBREG generated by LRA for reload insns. 1 in a REG if this is a static chain register. - 1 in a CALL for calls instrumented by Pointer Bounds Checker. Dumped as "/j" in RTL dumps. */ unsigned int jump : 1; /* In a CODE_LABEL, part of the two-bit alternate entry field. @@ -2515,10 +2514,6 @@ do { \ #define LRA_SUBREG_P(RTX) \ (RTL_FLAG_CHECK1 ("LRA_SUBREG_P", (RTX), SUBREG)->jump) -/* True if call is instrumented by Pointer Bounds Checker. */ -#define CALL_EXPR_WITH_BOUNDS_P(RTX) \ - (RTL_FLAG_CHECK1 ("CALL_EXPR_WITH_BOUNDS_P", (RTX), CALL)->jump) - /* Access various components of an ASM_OPERANDS rtx. */ #define ASM_OPERANDS_TEMPLATE(RTX) XCSTR (RTX, 0, ASM_OPERANDS) diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index dd08165e606..ad970019e01 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2389,11 +2389,6 @@ layout_type (tree type) SET_TYPE_MODE (type, VOIDmode); break; - case POINTER_BOUNDS_TYPE: - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; - case OFFSET_TYPE: TYPE_SIZE (type) = bitsize_int (POINTER_SIZE); TYPE_SIZE_UNIT (type) = size_int (POINTER_SIZE_UNITS); diff --git a/gcc/symtab.c b/gcc/symtab.c index 67e14d76b11..c5464cbe6d7 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -39,7 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "builtins.h" -static const char *ipa_ref_use_name[] = {"read","write","addr","alias","chkp"}; +static const char *ipa_ref_use_name[] = {"read","write","addr","alias"}; const char * const ld_plugin_symbol_resolution_names[]= { diff --git a/gcc/target.def b/gcc/target.def index 2f7bca99ec2..472a593c346 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2369,107 +2369,6 @@ built-in function.", (tree exp, rtx target, rtx subtarget, machine_mode mode, int ignore), default_expand_builtin) -DEFHOOK -(builtin_chkp_function, - "This hook allows target to redefine built-in functions used by\n\ -Pointer Bounds Checker for code instrumentation. Hook should return\n\ -fndecl of function implementing generic builtin whose code is\n\ -passed in @var{fcode}. Currently following built-in functions are\n\ -obtained using this hook:\n\ -@deftypefn {Built-in Function} __bounds_type __chkp_bndmk (const void *@var{lb}, size_t @var{size})\n\ -Function code - BUILT_IN_CHKP_BNDMK. This built-in function is used\n\ -by Pointer Bounds Checker to create bound values. @var{lb} holds low\n\ -bound of the resulting bounds. @var{size} holds size of created bounds.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} void __chkp_bndstx (const void *@var{ptr}, __bounds_type @var{b}, const void **@var{loc})\n\ -Function code - @code{BUILT_IN_CHKP_BNDSTX}. This built-in function is used\n\ -by Pointer Bounds Checker to store bounds @var{b} for pointer @var{ptr}\n\ -when @var{ptr} is stored by address @var{loc}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} __bounds_type __chkp_bndldx (const void **@var{loc}, const void *@var{ptr})\n\ -Function code - @code{BUILT_IN_CHKP_BNDLDX}. This built-in function is used\n\ -by Pointer Bounds Checker to get bounds of pointer @var{ptr} loaded by\n\ -address @var{loc}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} void __chkp_bndcl (const void *@var{ptr}, __bounds_type @var{b})\n\ -Function code - @code{BUILT_IN_CHKP_BNDCL}. This built-in function is used\n\ -by Pointer Bounds Checker to perform check for pointer @var{ptr} against\n\ -lower bound of bounds @var{b}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} void __chkp_bndcu (const void *@var{ptr}, __bounds_type @var{b})\n\ -Function code - @code{BUILT_IN_CHKP_BNDCU}. This built-in function is used\n\ -by Pointer Bounds Checker to perform check for pointer @var{ptr} against\n\ -upper bound of bounds @var{b}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} __bounds_type __chkp_bndret (void *@var{ptr})\n\ -Function code - @code{BUILT_IN_CHKP_BNDRET}. This built-in function is used\n\ -by Pointer Bounds Checker to obtain bounds returned by a call statement.\n\ -@var{ptr} passed to built-in is @code{SSA_NAME} returned by the call.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} __bounds_type __chkp_intersect (__bounds_type @var{b1}, __bounds_type @var{b2})\n\ -Function code - @code{BUILT_IN_CHKP_INTERSECT}. This built-in function\n\ -returns intersection of bounds @var{b1} and @var{b2}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} __bounds_type __chkp_narrow (const void *@var{ptr}, __bounds_type @var{b}, size_t @var{s})\n\ -Function code - @code{BUILT_IN_CHKP_NARROW}. This built-in function\n\ -returns intersection of bounds @var{b} and\n\ -[@var{ptr}, @var{ptr} + @var{s} - @code{1}].\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} size_t __chkp_sizeof (const void *@var{ptr})\n\ -Function code - @code{BUILT_IN_CHKP_SIZEOF}. This built-in function\n\ -returns size of object referenced by @var{ptr}. @var{ptr} is always\n\ -@code{ADDR_EXPR} of @code{VAR_DECL}. This built-in is used by\n\ -Pointer Bounds Checker when bounds of object cannot be computed statically\n\ -(e.g. object has incomplete type).\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} const void *__chkp_extract_lower (__bounds_type @var{b})\n\ -Function code - @code{BUILT_IN_CHKP_EXTRACT_LOWER}. This built-in function\n\ -returns lower bound of bounds @var{b}.\n\ -@end deftypefn\n\ -\n\ -@deftypefn {Built-in Function} const void *__chkp_extract_upper (__bounds_type @var{b})\n\ -Function code - @code{BUILT_IN_CHKP_EXTRACT_UPPER}. This built-in function\n\ -returns upper bound of bounds @var{b}.\n\ -@end deftypefn", - tree, (unsigned fcode), - default_builtin_chkp_function) - -DEFHOOK -(chkp_bound_type, - "Return type to be used for bounds", - tree, (void), - default_chkp_bound_type) - -DEFHOOK -(chkp_bound_mode, - "Return mode to be used for bounds.", - machine_mode, (void), - default_chkp_bound_mode) - -DEFHOOK -(chkp_make_bounds_constant, - "Return constant used to statically initialize constant bounds\n\ -with specified lower bound @var{lb} and upper bounds @var{ub}.", - tree, (HOST_WIDE_INT lb, HOST_WIDE_INT ub), - default_chkp_make_bounds_constant) - -DEFHOOK -(chkp_initialize_bounds, - "Generate a list of statements @var{stmts} to initialize pointer\n\ -bounds variable @var{var} with bounds @var{lb} and @var{ub}. Return\n\ -the number of generated statements.", - int, (tree var, tree lb, tree ub, tree *stmts), - default_chkp_initialize_bounds) - /* Select a replacement for a target-specific builtin. This is done *before* regular type checking, and so allows the target to implement a crude form of function overloading. The result is a @@ -4920,15 +4819,6 @@ aggregate data types, because these are returned in another way. See\n\ rtx, (const_tree ret_type, const_tree fn_decl_or_type, bool outgoing), default_function_value) -/* Return the rtx for bounds of returned pointer. */ -DEFHOOK -(chkp_function_value_bounds, - "Define this to return an RTX representing the place where a function\n\ -returns bounds for returned pointers. Arguments meaning is similar to\n\ -@code{TARGET_FUNCTION_VALUE}.", - rtx, (const_tree ret_type, const_tree fn_decl_or_type, bool outgoing), - default_chkp_function_value_bounds) - /* Return the rtx for the result of a libcall of mode MODE, calling the function FN_NAME. */ DEFHOOK diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 749e24ae178..51b0dcac111 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2222,53 +2222,6 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, return build_va_arg_indirect_ref (addr); } -tree -default_chkp_bound_type (void) -{ - tree res = make_node (POINTER_BOUNDS_TYPE); - TYPE_PRECISION (res) = TYPE_PRECISION (size_type_node) * 2; - TYPE_NAME (res) = get_identifier ("__bounds_type"); - SET_TYPE_MODE (res, targetm.chkp_bound_mode ()); - layout_type (res); - return res; -} - -machine_mode -default_chkp_bound_mode (void) -{ - return VOIDmode; -} - -tree -default_builtin_chkp_function (unsigned int fcode ATTRIBUTE_UNUSED) -{ - return NULL_TREE; -} - -rtx -default_chkp_function_value_bounds (const_tree ret_type ATTRIBUTE_UNUSED, - const_tree fn_decl_or_type ATTRIBUTE_UNUSED, - bool outgoing ATTRIBUTE_UNUSED) -{ - gcc_unreachable (); -} - -tree -default_chkp_make_bounds_constant (HOST_WIDE_INT lb ATTRIBUTE_UNUSED, - HOST_WIDE_INT ub ATTRIBUTE_UNUSED) -{ - return NULL_TREE; -} - -int -default_chkp_initialize_bounds (tree var ATTRIBUTE_UNUSED, - tree lb ATTRIBUTE_UNUSED, - tree ub ATTRIBUTE_UNUSED, - tree *stmts ATTRIBUTE_UNUSED) -{ - return 0; -} - void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE_UNUSED, machine_mode mode ATTRIBUTE_UNUSED, diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 56951556525..b6a8fa544f7 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -266,13 +266,6 @@ extern rtx default_load_bounds_for_arg (rtx, rtx, rtx); extern void default_store_bounds_for_arg (rtx, rtx, rtx, rtx); extern rtx default_load_returned_bounds (rtx); extern void default_store_returned_bounds (rtx,rtx); -extern tree default_chkp_bound_type (void); -extern machine_mode default_chkp_bound_mode (void); -extern tree default_builtin_chkp_function (unsigned int); -extern rtx default_chkp_function_value_bounds (const_tree, const_tree, bool); -extern tree default_chkp_make_bounds_constant (HOST_WIDE_INT lb, HOST_WIDE_INT ub); -extern int default_chkp_initialize_bounds (tree var, tree lb, tree ub, - tree *stmts); extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE_UNUSED, machine_mode mode ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ebd9880ac01..c5510f140f6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,394 @@ +2018-06-08 Martin Liska <mliska@suse.cz> + + * g++.dg/dg.exp: Do not use mpx.exp. + * g++.dg/lto/lto.exp: Likewise. + * g++.dg/lto/pr69729_0.C: Remove. + * g++.dg/opt/pr71529.C: Remove. + * g++.dg/pr63995-1.C: Remove. + * g++.dg/pr68270.C: Remove. + * g++.dg/pr71624.C: Remove. + * g++.dg/pr71633.C: Remove. + * g++.dg/pr79761.C: Remove. + * g++.dg/pr79764.C: Remove. + * g++.dg/pr79769.C: Remove. + * gcc.dg/lto/chkp-privatize-1_0.c: Remove. + * gcc.dg/lto/chkp-privatize-2_0.c: Remove. + * gcc.dg/lto/chkp-privatize_0.c: Remove. + * gcc.dg/lto/chkp-removed-alias_0.c: Remove. + * gcc.dg/lto/chkp-static-bounds_0.c: Remove. + * gcc.dg/lto/chkp-wrap-asm-name_0.c: Remove. + * gcc.dg/lto/lto.exp: Do not use mpx.exp. + * gcc.dg/lto/pr66221_0.c: Remove. + * gcc.target/i386/chkp-always_inline.c: Remove. + * gcc.target/i386/chkp-bndret.c: Remove. + * gcc.target/i386/chkp-builtins-1.c: Remove. + * gcc.target/i386/chkp-builtins-2.c: Remove. + * gcc.target/i386/chkp-builtins-3.c: Remove. + * gcc.target/i386/chkp-builtins-4.c: Remove. + * gcc.target/i386/chkp-const-check-1.c: Remove. + * gcc.target/i386/chkp-const-check-2.c: Remove. + * gcc.target/i386/chkp-hidden-def.c: Remove. + * gcc.target/i386/chkp-label-address.c: Remove. + * gcc.target/i386/chkp-lifetime-1.c: Remove. + * gcc.target/i386/chkp-narrow-bounds.c: Remove. + * gcc.target/i386/chkp-pr69044.c: Remove. + * gcc.target/i386/chkp-remove-bndint-1.c: Remove. + * gcc.target/i386/chkp-remove-bndint-2.c: Remove. + * gcc.target/i386/chkp-strchr.c: Remove. + * gcc.target/i386/chkp-strlen-1.c: Remove. + * gcc.target/i386/chkp-strlen-2.c: Remove. + * gcc.target/i386/chkp-strlen-3.c: Remove. + * gcc.target/i386/chkp-strlen-4.c: Remove. + * gcc.target/i386/chkp-strlen-5.c: Remove. + * gcc.target/i386/chkp-stropt-1.c: Remove. + * gcc.target/i386/chkp-stropt-10.c: Remove. + * gcc.target/i386/chkp-stropt-11.c: Remove. + * gcc.target/i386/chkp-stropt-12.c: Remove. + * gcc.target/i386/chkp-stropt-13.c: Remove. + * gcc.target/i386/chkp-stropt-14.c: Remove. + * gcc.target/i386/chkp-stropt-15.c: Remove. + * gcc.target/i386/chkp-stropt-16.c: Remove. + * gcc.target/i386/chkp-stropt-17.c: Remove. + * gcc.target/i386/chkp-stropt-2.c: Remove. + * gcc.target/i386/chkp-stropt-3.c: Remove. + * gcc.target/i386/chkp-stropt-4.c: Remove. + * gcc.target/i386/chkp-stropt-5.c: Remove. + * gcc.target/i386/chkp-stropt-6.c: Remove. + * gcc.target/i386/chkp-stropt-7.c: Remove. + * gcc.target/i386/chkp-stropt-8.c: Remove. + * gcc.target/i386/chkp-stropt-9.c: Remove. + * gcc.target/i386/i386.exp: Do not use mpx.exp. + * gcc.target/i386/indirect-thunk-11.c: Remove. + * gcc.target/i386/indirect-thunk-12.c: Remove. + * gcc.target/i386/indirect-thunk-attr-12.c: Remove. + * gcc.target/i386/indirect-thunk-attr-13.c: Remove. + * gcc.target/i386/indirect-thunk-bnd-1.c: Remove. + * gcc.target/i386/indirect-thunk-bnd-2.c: Remove. + * gcc.target/i386/indirect-thunk-bnd-3.c: Remove. + * gcc.target/i386/indirect-thunk-bnd-4.c: Remove. + * gcc.target/i386/interrupt-bnd-err-1.c: Remove. + * gcc.target/i386/interrupt-bnd-err-2.c: Remove. + * gcc.target/i386/mpx/alloca-1-lbv.c: Remove. + * gcc.target/i386/mpx/alloca-1-nov.c: Remove. + * gcc.target/i386/mpx/alloca-1-ubv.c: Remove. + * gcc.target/i386/mpx/arg-addr-1-lbv.c: Remove. + * gcc.target/i386/mpx/arg-addr-1-nov.c: Remove. + * gcc.target/i386/mpx/arg-addr-1-ubv.c: Remove. + * gcc.target/i386/mpx/bitfields-1-lbv.c: Remove. + * gcc.target/i386/mpx/bitfields-1-nov.c: Remove. + * gcc.target/i386/mpx/bitfields-1-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-2.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-2.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-2.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-3.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-2.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-2.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-2-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-3.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-4.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-null-ptr-bounds-1-bbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-1.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-3.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-lbv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-nov.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-ubv.c: Remove. + * gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-2.c: Remove. + * gcc.target/i386/mpx/calloc-1-lbv.c: Remove. + * gcc.target/i386/mpx/calloc-1-nov.c: Remove. + * gcc.target/i386/mpx/calloc-1-ubv.c: Remove. + * gcc.target/i386/mpx/chkp-fix-calls-1.c: Remove. + * gcc.target/i386/mpx/chkp-fix-calls-2.c: Remove. + * gcc.target/i386/mpx/chkp-fix-calls-3.c: Remove. + * gcc.target/i386/mpx/chkp-fix-calls-4.c: Remove. + * gcc.target/i386/mpx/chkp-thunk-comdat-1.cc: Remove. + * gcc.target/i386/mpx/chkp-thunk-comdat-2.cc: Remove. + * gcc.target/i386/mpx/chkp-thunk-comdat-3.c: Remove. + * gcc.target/i386/mpx/fastcall-1-lbv.c: Remove. + * gcc.target/i386/mpx/fastcall-1-nov.c: Remove. + * gcc.target/i386/mpx/fastcall-1-ubv.c: Remove. + * gcc.target/i386/mpx/fastcall-2-lbv.c: Remove. + * gcc.target/i386/mpx/fastcall-2-nov.c: Remove. + * gcc.target/i386/mpx/fastcall-2-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-1-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-1-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-1-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-10-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-10-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-10-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-2-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-2-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-2-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-3-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-3-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-3-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-4-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-4-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-4-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-5-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-5-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-5-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-6-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-6-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-6-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-7-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-7-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-7-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-8-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-8-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-8-ubv.c: Remove. + * gcc.target/i386/mpx/field-addr-9-lbv.c: Remove. + * gcc.target/i386/mpx/field-addr-9-nov.c: Remove. + * gcc.target/i386/mpx/field-addr-9-ubv.c: Remove. + * gcc.target/i386/mpx/frame-address-1-nov.c: Remove. + * gcc.target/i386/mpx/hard-reg-1-nov.c: Remove. + * gcc.target/i386/mpx/hard-reg-2-lbv.c: Remove. + * gcc.target/i386/mpx/hard-reg-2-nov.c: Remove. + * gcc.target/i386/mpx/hard-reg-2-ubv.c: Remove. + * gcc.target/i386/mpx/if-stmt-1-lbv.c: Remove. + * gcc.target/i386/mpx/if-stmt-1-nov.c: Remove. + * gcc.target/i386/mpx/if-stmt-1-ubv.c: Remove. + * gcc.target/i386/mpx/if-stmt-2-lbv.c: Remove. + * gcc.target/i386/mpx/if-stmt-2-nov.c: Remove. + * gcc.target/i386/mpx/if-stmt-2-ubv.c: Remove. + * gcc.target/i386/mpx/label-address-1.c: Remove. + * gcc.target/i386/mpx/legacy-1-nov.c: Remove. + * gcc.target/i386/mpx/macro.c: Remove. + * gcc.target/i386/mpx/malloc-1-lbv.c: Remove. + * gcc.target/i386/mpx/malloc-1-nov.c: Remove. + * gcc.target/i386/mpx/malloc-1-ubv.c: Remove. + * gcc.target/i386/mpx/memcpy-1.c: Remove. + * gcc.target/i386/mpx/memmove-1.c: Remove. + * gcc.target/i386/mpx/memmove-2.c: Remove. + * gcc.target/i386/mpx/memmove-zero-length.c: Remove. + * gcc.target/i386/mpx/mpx-check.h: Remove. + * gcc.target/i386/mpx/mpx-os-support.h: Remove. + * gcc.target/i386/mpx/mpx.exp: Remove. + * gcc.target/i386/mpx/nested-function-1-lbv.c: Remove. + * gcc.target/i386/mpx/nested-function-1-nov.c: Remove. + * gcc.target/i386/mpx/nested-function-1-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-1-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-1-nov.c: Remove. + * gcc.target/i386/mpx/pointer-arg-1-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-2-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-2-nov.c: Remove. + * gcc.target/i386/mpx/pointer-arg-2-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-3-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-3-nov.c: Remove. + * gcc.target/i386/mpx/pointer-arg-3-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-4-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-4-nov.c: Remove. + * gcc.target/i386/mpx/pointer-arg-4-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-5-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-arg-5-nov.c: Remove. + * gcc.target/i386/mpx/pointer-arg-5-ubv.c: Remove. + * gcc.target/i386/mpx/pointer-diff-1.c: Remove. + * gcc.target/i386/mpx/pointer-store-1-lbv.c: Remove. + * gcc.target/i386/mpx/pointer-store-1-nov.c: Remove. + * gcc.target/i386/mpx/pointer-store-1-ubv.c: Remove. + * gcc.target/i386/mpx/pr65508.c: Remove. + * gcc.target/i386/mpx/pr65531.cc: Remove. + * gcc.target/i386/mpx/pr66048.cc: Remove. + * gcc.target/i386/mpx/pr66134.c: Remove. + * gcc.target/i386/mpx/pr66566.c: Remove. + * gcc.target/i386/mpx/pr66567.c: Remove. + * gcc.target/i386/mpx/pr66568.c: Remove. + * gcc.target/i386/mpx/pr66569.c: Remove. + * gcc.target/i386/mpx/pr66581.c: Remove. + * gcc.target/i386/mpx/pr68337-1.c: Remove. + * gcc.target/i386/mpx/pr68337-2.c: Remove. + * gcc.target/i386/mpx/pr68416.c: Remove. + * gcc.target/i386/mpx/pr78339.c: Remove. + * gcc.target/i386/mpx/pr79631.c: Remove. + * gcc.target/i386/mpx/pr79633.c: Remove. + * gcc.target/i386/mpx/pr79753.c: Remove. + * gcc.target/i386/mpx/pr79770.c: Remove. + * gcc.target/i386/mpx/pr79987.c: Remove. + * gcc.target/i386/mpx/pr79988.c: Remove. + * gcc.target/i386/mpx/realloc-1-lbv.c: Remove. + * gcc.target/i386/mpx/realloc-1-nov.c: Remove. + * gcc.target/i386/mpx/realloc-1-ubv.c: Remove. + * gcc.target/i386/mpx/realloc-2-lbv.c: Remove. + * gcc.target/i386/mpx/realloc-2-nov.c: Remove. + * gcc.target/i386/mpx/realloc-2-ubv.c: Remove. + * gcc.target/i386/mpx/reference-1-lbv.cpp: Remove. + * gcc.target/i386/mpx/reference-1-nov.cpp: Remove. + * gcc.target/i386/mpx/reference-1-ubv.cpp: Remove. + * gcc.target/i386/mpx/reference-2-lbv.cpp: Remove. + * gcc.target/i386/mpx/reference-2-nov.cpp: Remove. + * gcc.target/i386/mpx/reference-2-ubv.cpp: Remove. + * gcc.target/i386/mpx/reference-3-lbv.cpp: Remove. + * gcc.target/i386/mpx/reference-3-nov.cpp: Remove. + * gcc.target/i386/mpx/reference-3-ubv.cpp: Remove. + * gcc.target/i386/mpx/reference-4-lbv.cpp: Remove. + * gcc.target/i386/mpx/reference-4-nov.cpp: Remove. + * gcc.target/i386/mpx/reference-4-ubv.cpp: Remove. + * gcc.target/i386/mpx/return-pointer-1-lbv.c: Remove. + * gcc.target/i386/mpx/return-pointer-1-nov.c: Remove. + * gcc.target/i386/mpx/return-pointer-1-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-1-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-1-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-1-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-2-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-2-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-2-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-3-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-3-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-3-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-4-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-4-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-4-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-5-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-5-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-5-ubv.c: Remove. + * gcc.target/i386/mpx/return-struct-6-lbv.c: Remove. + * gcc.target/i386/mpx/return-struct-6-nov.c: Remove. + * gcc.target/i386/mpx/return-struct-6-ubv.c: Remove. + * gcc.target/i386/mpx/sincos-1-nov.c: Remove. + * gcc.target/i386/mpx/static-array-1-lbv.c: Remove. + * gcc.target/i386/mpx/static-array-1-nov.c: Remove. + * gcc.target/i386/mpx/static-array-1-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-1-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-1-nov.c: Remove. + * gcc.target/i386/mpx/static-init-1-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-2-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-2-nov.c: Remove. + * gcc.target/i386/mpx/static-init-2-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-3-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-3-nov.c: Remove. + * gcc.target/i386/mpx/static-init-3-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-4-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-4-nov.c: Remove. + * gcc.target/i386/mpx/static-init-4-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-5-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-5-nov.c: Remove. + * gcc.target/i386/mpx/static-init-5-ubv.c: Remove. + * gcc.target/i386/mpx/static-init-6-lbv.c: Remove. + * gcc.target/i386/mpx/static-init-6-nov.c: Remove. + * gcc.target/i386/mpx/static-init-6-ubv.c: Remove. + * gcc.target/i386/mpx/static-string-1-lbv.c: Remove. + * gcc.target/i386/mpx/static-string-1-nov.c: Remove. + * gcc.target/i386/mpx/static-string-1-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-1-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-1-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-1-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-10-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-10-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-10-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-2-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-2-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-2-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-3-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-3-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-3-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-4-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-4-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-4-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-5-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-5-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-5-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-6-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-6-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-6-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-7-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-7-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-7-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-8-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-8-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-8-ubv.c: Remove. + * gcc.target/i386/mpx/struct-arg-9-lbv.c: Remove. + * gcc.target/i386/mpx/struct-arg-9-nov.c: Remove. + * gcc.target/i386/mpx/struct-arg-9-ubv.c: Remove. + * gcc.target/i386/mpx/struct-copy-1-lbv.c: Remove. + * gcc.target/i386/mpx/struct-copy-1-nov.c: Remove. + * gcc.target/i386/mpx/struct-copy-1-ubv.c: Remove. + * gcc.target/i386/mpx/struct-copy-2-lbv.c: Remove. + * gcc.target/i386/mpx/struct-copy-2-nov.c: Remove. + * gcc.target/i386/mpx/struct-copy-2-ubv.c: Remove. + * gcc.target/i386/mpx/thread-local-var-1-lbv.c: Remove. + * gcc.target/i386/mpx/thread-local-var-1-nov.c: Remove. + * gcc.target/i386/mpx/thread-local-var-1-ubv.c: Remove. + * gcc.target/i386/mpx/union-arg-1-lbv.c: Remove. + * gcc.target/i386/mpx/union-arg-1-nov.c: Remove. + * gcc.target/i386/mpx/union-arg-1-ubv.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-1-lbv.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-1-nov.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-1-ubv.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-2-lbv.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-2-nov.c: Remove. + * gcc.target/i386/mpx/va-arg-pack-2-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-1-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-1-nov.c: Remove. + * gcc.target/i386/mpx/vararg-1-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-2-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-2-nov.c: Remove. + * gcc.target/i386/mpx/vararg-2-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-3-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-3-nov.c: Remove. + * gcc.target/i386/mpx/vararg-3-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-4-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-4-nov.c: Remove. + * gcc.target/i386/mpx/vararg-4-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-5-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-5-nov.c: Remove. + * gcc.target/i386/mpx/vararg-5-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-6-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-6-nov.c: Remove. + * gcc.target/i386/mpx/vararg-6-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-7-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-7-nov.c: Remove. + * gcc.target/i386/mpx/vararg-7-ubv.c: Remove. + * gcc.target/i386/mpx/vararg-8-lbv.c: Remove. + * gcc.target/i386/mpx/vararg-8-nov.c: Remove. + * gcc.target/i386/mpx/vararg-8-ubv.c: Remove. + * gcc.target/i386/mpx/vla-1-lbv.c: Remove. + * gcc.target/i386/mpx/vla-1-nov.c: Remove. + * gcc.target/i386/mpx/vla-1-ubv.c: Remove. + * gcc.target/i386/mpx/vla-2-lbv.c: Remove. + * gcc.target/i386/mpx/vla-2-nov.c: Remove. + * gcc.target/i386/mpx/vla-2-ubv.c: Remove. + * gcc.target/i386/mpx/vla-trailing-1-lbv.c: Remove. + * gcc.target/i386/mpx/vla-trailing-1-nov.c: Remove. + * gcc.target/i386/mpx/vla-trailing-1-ubv.c: Remove. + * gcc.target/i386/pr63995-2.c: Remove. + * gcc.target/i386/pr64805.c: Remove. + * gcc.target/i386/pr65044.c: Remove. + * gcc.target/i386/pr65167.c: Remove. + * gcc.target/i386/pr65183.c: Remove. + * gcc.target/i386/pr65184.c: Remove. + * gcc.target/i386/pr65523.c: Remove. + * gcc.target/i386/pr70876.c: Remove. + * gcc.target/i386/pr70877.c: Remove. + * gcc.target/i386/pr71458.c: Remove. + * gcc.target/i386/pr80880.c: Remove. + * gcc.target/i386/ret-thunk-25.c: Remove. + * gcc.target/i386/thunk-retbnd.c: Remove. + * lib/mpx-dg.exp: Remove. + * gcc.target/i386/funcspec-56.inc: Adjust test case. + 2018-06-07 Carl Love <cel@us.ibm.com> * gcc.target/powerpc/builtins-3-p9-runnable.c: Add debug print diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index 7a6096ca522..fce96a63fba 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -18,7 +18,6 @@ # Load support procs. load_lib g++-dg.exp -load_lib mpx-dg.exp # If a testcase doesn't have special options, use these. global DEFAULT_CXXFLAGS diff --git a/gcc/testsuite/g++.dg/lto/lto.exp b/gcc/testsuite/g++.dg/lto/lto.exp index d399c075d56..eeb5e432d09 100644 --- a/gcc/testsuite/g++.dg/lto/lto.exp +++ b/gcc/testsuite/g++.dg/lto/lto.exp @@ -31,7 +31,6 @@ if $tracelevel then { load_lib standard.exp load_lib g++.exp load_lib target-libpath.exp -load_lib mpx-dg.exp # Load the language-independent compabibility support procedures. load_lib lto.exp @@ -43,7 +42,6 @@ if { ![check_effective_target_lto] } { g++_init lto_init no-mathlib -mpx_init # Define an identifier for use with this suite to avoid name conflicts # with other lto tests running at the same time. @@ -59,5 +57,4 @@ foreach src [lsort [find $srcdir/$subdir *_0.\[cC\]]] { lto-execute $src $sid } -mpx_finish lto_finish diff --git a/gcc/testsuite/g++.dg/lto/pr69729_0.C b/gcc/testsuite/g++.dg/lto/pr69729_0.C deleted file mode 100644 index b736406e0cb..00000000000 --- a/gcc/testsuite/g++.dg/lto/pr69729_0.C +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options {{-fcheck-pointer-bounds -mmpx -flto -flto-partition=max}} } */ - -class cl1 -{ - public: - virtual ~cl1 () { }; -}; - -class cl2 -{ - public: - virtual ~cl2 () { }; -}; - -class cl3 : cl1, cl2 -{ -}; - -class cl4 : cl3 -{ - public: - ~cl4 (); -}; - -cl4::~cl4 () -{ -} - -int main (int argc, char **argv) -{ - cl4 c; - return 0; -} diff --git a/gcc/testsuite/g++.dg/opt/pr71529.C b/gcc/testsuite/g++.dg/opt/pr71529.C deleted file mode 100644 index 148527f00c4..00000000000 --- a/gcc/testsuite/g++.dg/opt/pr71529.C +++ /dev/null @@ -1,22 +0,0 @@ -// PR middle-end/71529 -// { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } -// { dg-options "-fcheck-pointer-bounds -mmpx -O2" } - -class c1 -{ - public: - virtual ~c1 (); -}; - -class c2 -{ - public: - virtual ~c2 (); -}; - -class c3 : c1, c2 { }; - -int main (int, char **) -{ - c3 obj; -} diff --git a/gcc/testsuite/g++.dg/pr63995-1.C b/gcc/testsuite/g++.dg/pr63995-1.C deleted file mode 100644 index 41a1c01153b..00000000000 --- a/gcc/testsuite/g++.dg/pr63995-1.C +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-O2 -g -fcheck-pointer-bounds -mmpx" } */ - -int test1 (int i) -{ - extern const int arr[10]; - return arr[i]; -} - -extern const int arr[10]; - -int test2 (int i) -{ - return arr[i]; -} diff --git a/gcc/testsuite/g++.dg/pr68270.C b/gcc/testsuite/g++.dg/pr68270.C deleted file mode 100644 index 441fca3e85f..00000000000 --- a/gcc/testsuite/g++.dg/pr68270.C +++ /dev/null @@ -1,16 +0,0 @@ -/* PR71633 */ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-Werror=chkp -mmpx -fcheck-pointer-bounds -O1 -fchkp-flexible-struct-trailing-arrays" } */ - -struct a -{ - struct - { - int e[1]; - } f; -}; - -int g(a *ptr) -{ - return ptr->f.e[1]; -} diff --git a/gcc/testsuite/g++.dg/pr71624.C b/gcc/testsuite/g++.dg/pr71624.C deleted file mode 100644 index 951534ce875..00000000000 --- a/gcc/testsuite/g++.dg/pr71624.C +++ /dev/null @@ -1,35 +0,0 @@ -/* PR71624 */ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -class c1 -{ -public: - virtual int fn1 () const; - int fn2 (const int *) const; -}; - -class c2 -{ - int fn1 (); - c1 obj; -}; - -int -c1::fn1 () const -{ - return 0; -} - -int -c1::fn2 (const int *) const -{ - return this->fn1 (); -} - -int -c2::fn1 () -{ - return obj.fn2 (0); -} - diff --git a/gcc/testsuite/g++.dg/pr71633.C b/gcc/testsuite/g++.dg/pr71633.C deleted file mode 100644 index 8852695b910..00000000000 --- a/gcc/testsuite/g++.dg/pr71633.C +++ /dev/null @@ -1,29 +0,0 @@ -/* PR71633 */ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -class c1 -{ - virtual void fn1 (); -}; - -class c2 -{ - virtual int *fn2 () const; -}; - -class c3 : c1, c2 -{ - int *fn2 () const; - int *fn3 (int) const; -}; - -int *c3::fn2 () const -{ - return 0; -} - -int *c3::fn3 (int p) const -{ - return fn3 (p); -} diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C deleted file mode 100644 index a97325a1fc4..00000000000 --- a/gcc/testsuite/g++.dg/pr79761.C +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */ - -struct Foo -{ - Foo() : a(1), b(1), c('a') {} - int a; - int b; - char c; -}; - -static Foo copy_foo(Foo) __attribute__((noinline, noclone)); - -static Foo copy_foo(Foo A) -{ - return A; -} - -struct Bar : Foo -{ - Bar(Foo t) : Foo(copy_foo(t)) {} -}; - -Foo F; - -int main (void) -{ - Bar B (F); - - if (B.a != 1 || B.b != 1 || B.c != 'a') - __builtin_abort (); - - return 0; -} diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C deleted file mode 100644 index 293aa337693..00000000000 --- a/gcc/testsuite/g++.dg/pr79764.C +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ )); -struct A { - __m256 ymm; - const float &f() const; -}; - -const float &A::f() const { - return ymm[1]; -} diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C deleted file mode 100644 index c3186877f60..00000000000 --- a/gcc/testsuite/g++.dg/pr79769.C +++ /dev/null @@ -1,4 +0,0 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */ - -void a (_Complex) { a (3); } diff --git a/gcc/testsuite/gcc.dg/lto/chkp-privatize-1_0.c b/gcc/testsuite/gcc.dg/lto/chkp-privatize-1_0.c deleted file mode 100644 index 2054aa15ba0..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-privatize-1_0.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -Ofast -flto -fcheck-pointer-bounds -mmpx } } } */ - -extern int __attribute__((noinline)) f1 (int i); - -static int __attribute__((noinline)) -f2 (int i) -{ - return i + 6; -} - -int -main (int argc, char **argv) -{ - return f1 (argc) + f2 (argc); -} diff --git a/gcc/testsuite/gcc.dg/lto/chkp-privatize-2_0.c b/gcc/testsuite/gcc.dg/lto/chkp-privatize-2_0.c deleted file mode 100644 index be7f601e399..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-privatize-2_0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -Ofast -flto -fcheck-pointer-bounds -mmpx } } } */ - -static int -__attribute__ ((noinline)) -func1 (int i) -{ - return i + 2; -} - -extern int func2 (int i); - -int -main (int argc, char **argv) -{ - return func1 (argc) + func2 (argc) + 1; -} diff --git a/gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c b/gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c deleted file mode 100644 index ad9fdaaee88..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -fPIC -flto -flto-partition=max -fcheck-pointer-bounds -mmpx } } } */ - -static int -__attribute__ ((noinline)) -func1 (int i) -{ - return i + 2; -} - -extern int func2 (int i); - -int -main (int argc, char **argv) -{ - return func1 (argc) + func2 (argc) + 1; -} diff --git a/gcc/testsuite/gcc.dg/lto/chkp-removed-alias_0.c b/gcc/testsuite/gcc.dg/lto/chkp-removed-alias_0.c deleted file mode 100644 index 96d728d5122..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-removed-alias_0.c +++ /dev/null @@ -1,28 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -O2 -flto -flto-partition=max -fcheck-pointer-bounds -mmpx } } } */ - -int test1 (const char *c) -{ - return c[0] * 2; -} - -int test2 (const char *c) -{ - return c[1] * 3; -} - -int test1_alias (const char *c) __attribute__ ((alias ("test1"))); -int test2_alias (const char *c) __attribute__ ((alias ("test2"))); - -struct S -{ - int (*fnptr[2]) (const char *); -} S; - -struct S s = {test1_alias, test2_alias}; - -int main (int argc, const char **argv) -{ - return s.fnptr[argc] (argv[0]); -} diff --git a/gcc/testsuite/gcc.dg/lto/chkp-static-bounds_0.c b/gcc/testsuite/gcc.dg/lto/chkp-static-bounds_0.c deleted file mode 100644 index 596e5510664..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-static-bounds_0.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -flto -flto-partition=max -fcheck-pointer-bounds -mmpx } } } */ - -const char *cc; - -int test1 (const char *c) -{ - c = __builtin___bnd_init_ptr_bounds (c); - cc = c; - return c[0] * 2; -} - -struct S -{ - int (*fnptr) (const char *); -} S; - -struct S s1 = {test1}; -struct S s2 = {test1}; -struct S s3 = {test1}; - -int main (int argc, const char **argv) -{ - return s1.fnptr (argv[0]) + s2.fnptr (argv[1]); -} diff --git a/gcc/testsuite/gcc.dg/lto/chkp-wrap-asm-name_0.c b/gcc/testsuite/gcc.dg/lto/chkp-wrap-asm-name_0.c deleted file mode 100644 index 6611bdb825c..00000000000 --- a/gcc/testsuite/gcc.dg/lto/chkp-wrap-asm-name_0.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -O2 -flto -fcheck-pointer-bounds -mmpx } } } */ - -typedef long unsigned int size_t; - -extern size_t strlen (const char *); -extern __typeof (strlen) strlen __asm__ ("" "__hidden_strlen") __attribute__ ((visibility ("hidden"))); - -size_t -test1 (const char *p) { return strlen (p); } - -size_t -test2 (const char *p) { return __builtin_strlen (p); } - -int -main (int argc, const char **argv) -{ - return test1 (argv[0]) - test2 (argv[0]); -} diff --git a/gcc/testsuite/gcc.dg/lto/lto.exp b/gcc/testsuite/gcc.dg/lto/lto.exp index 033ed7672ad..cb35341d5ef 100644 --- a/gcc/testsuite/gcc.dg/lto/lto.exp +++ b/gcc/testsuite/gcc.dg/lto/lto.exp @@ -30,7 +30,6 @@ if $tracelevel then { # Load procedures from common libraries. load_lib standard.exp load_lib gcc.exp -load_lib mpx-dg.exp # Load the language-independent compabibility support procedures. load_lib lto.exp @@ -42,7 +41,6 @@ if { ![check_effective_target_lto] } { gcc_init lto_init no-mathlib -mpx_init # Define an identifier for use with this suite to avoid name conflicts # with other lto tests running at the same time. diff --git a/gcc/testsuite/gcc.dg/lto/pr66221_0.c b/gcc/testsuite/gcc.dg/lto/pr66221_0.c deleted file mode 100644 index dbb92829be6..00000000000 --- a/gcc/testsuite/gcc.dg/lto/pr66221_0.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-lto-do link } */ -/* { dg-require-effective-target mpx } */ -/* { dg-lto-options { { -O2 -flto -fcheck-pointer-bounds -mmpx } } } */ - -int test1 (const char *); - -int main (int argc, const char **argv) -{ - return test1 (argv[0]); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-always_inline.c b/gcc/testsuite/gcc.target/i386/chkp-always_inline.c deleted file mode 100644 index c10d1310e0e..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-always_inline.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -Wno-attributes" } */ - -static __attribute__((always_inline)) int f1 (int *p) -{ - return *p; -} - -__attribute__((bnd_legacy)) int f2 (int *p) -{ - return f1 (p); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-bndret.c b/gcc/testsuite/gcc.target/i386/chkp-bndret.c deleted file mode 100644 index d84ea70dcda..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-bndret.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump-not "bndret" "chkp" } } */ - -#include "string.h" - -extern int *test1 (int *p) __attribute__((bnd_legacy)); - -int * -test2 (int *p) -{ - return test1 (p); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c deleted file mode 100644 index 99cfa82681c..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-1.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump-not "bnd_init_ptr_bounds" "chkp" } } */ - -void * -chkp_test (void *p) -{ - return __builtin___bnd_init_ptr_bounds (p); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c deleted file mode 100644 index 6da8d0a83ff..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-2.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump-not "bnd_copy_ptr_bounds" "chkp" } } */ - -void * -chkp_test (void *p, void *q) -{ - return __builtin___bnd_copy_ptr_bounds (p, q); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c deleted file mode 100644 index ae30534c6da..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-3.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump-not "bnd_set_ptr_bounds" "chkp" } } */ - -void * -chkp_test (void *p) -{ - return __builtin___bnd_set_ptr_bounds (p, 10); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c b/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c deleted file mode 100644 index d408a490b13..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-builtins-4.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump-not "bnd_null_ptr_bounds" "chkp" } } */ - -void * -chkp_test (void *p) -{ - return __builtin___bnd_null_ptr_bounds (p); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c deleted file mode 100644 index 6e6d067fb50..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-const-check-1.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt" } */ -/* { dg-final { scan-tree-dump-not "bndcl" "chkpopt" } } */ -/* { dg-final { scan-tree-dump-not "bndcu" "chkpopt" } } */ - -int test (int *p) -{ - p = (int *)__builtin___bnd_set_ptr_bounds (p, sizeof (int)); - return *p; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c b/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c deleted file mode 100644 index 839cf788e7c..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-const-check-2.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -Wchkp" } */ - -int test (int *p) -{ - p = (int *)__builtin___bnd_set_ptr_bounds (p, sizeof (int)); - return *(p + 1); /* { dg-warning "memory access check always fail" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c b/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c deleted file mode 100644 index 68f70ff258d..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-alias "" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ -/* { dg-final { scan-assembler-not "test.chkp" } } */ - -int test (int *p); -extern __typeof (test) test __asm__ ("" "__test") __attribute__ ((visibility ("hidden"))); - -int test (int *p) -{ - return *p; -} - -extern __typeof (test) __test1 __asm__("" "test"); -extern __typeof (test) __test1 __attribute__((alias ("" "__test"))); diff --git a/gcc/testsuite/gcc.target/i386/chkp-label-address.c b/gcc/testsuite/gcc.target/i386/chkp-label-address.c deleted file mode 100644 index 23a2f7cd052..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-label-address.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -Wchkp" } */ - -#include <stdio.h> - -static int f1 () /* { dg-warning "function cannot be instrumented" } */ -{ - static int array = &&label_B - &&label_A; - - label_A: - - printf ("%d\n", array); - - label_B: - - return 0; -} - -int f2 (int i) -{ - printf ("%d\n", i); - return f1 (); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c b/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c deleted file mode 100644 index 70b8b38dc28..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-lifetime-1.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt-details" } */ -/* { dg-final { scan-tree-dump "Moving creation of \[^ \]+ down to its use" "chkpopt" } } */ - -extern int arr[]; - -int test (int i) -{ - int res; - if (i >= 0) - res = arr[i]; - else - res = -i; - return res; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-narrow-bounds.c b/gcc/testsuite/gcc.target/i386/chkp-narrow-bounds.c deleted file mode 100644 index ab1b122479a..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-narrow-bounds.c +++ /dev/null @@ -1,11 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkp" } */ -/* { dg-final { scan-tree-dump "bndcl" "chkp" } } */ -/* { dg-final { scan-tree-dump "bndcu" "chkp" } } */ - -int -test (int *p) -{ - int *p1 = __bnd_narrow_ptr_bounds (p - 10, p, sizeof (int) * 20); - return p1[10]; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-pr69044.c b/gcc/testsuite/gcc.target/i386/chkp-pr69044.c deleted file mode 100644 index 16751f51766..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-pr69044.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -int i; -int strncasecmp (char *p1, char *p2, long p3) { return 0; } -int special_command () -{ - if (strncasecmp (0, 0, 0)) - i++; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c deleted file mode 100644 index 7c0f13f8ccf..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-1.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-optimized" } */ -/* { dg-final { scan-tree-dump-not "bndint" "optimized" } } */ - -struct S -{ - int a; - int b; - int c; -}; - -int test (struct S *ps) -{ - int *pi = &ps->b; - return *pi; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c b/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c deleted file mode 100644 index eea0b0afa10..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-remove-bndint-2.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-optimized -Wchkp" } */ -/* { dg-final { scan-tree-dump-not "bndint" "optimized" } } */ - -struct S -{ - int a; - int b; - int c; -}; - -int test (struct S *ps) -{ - int *pi = &ps->b; - return *(pi + 1); /* { dg-warning "memory access check always fail" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strchr.c b/gcc/testsuite/gcc.target/i386/chkp-strchr.c deleted file mode 100644 index 01ee619dfd9..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strchr.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -#include "string.h" - -static char * -test1 (char *str) -{ - return strrchr (str, '_'); -} - -char * -test2 () -{ - return test1 ("test_string"); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c deleted file mode 100644 index 38d53900627..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strlen-1.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */ -/* { dg-final { scan-tree-dump "memcpy.chkp" "strlen" } } */ - -#include "../../gcc.dg/strlenopt.h" - -char *test (char *str1, char *str2) -{ - size_t len = strlen (str2); - strcpy (str1, str2); - return str1 + len; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c deleted file mode 100644 index 789ebc1f2d8..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strlen-2.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target stpcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */ -/* { dg-final { scan-tree-dump-not "strlen" "strlen" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -char *test (char *str1, char *str2) -{ - char *p = stpcpy (str1, str2); - size_t len = strlen (str1); - return p + len; -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c deleted file mode 100644 index 276f4127975..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strlen-3.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */ -/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */ - -#include "../../gcc.dg/strlenopt.h" - -size_t test (char *str1, char *str2) -{ - size_t len = strlen (str2); - memcpy (str1, str2, len + 1); - return len + strlen (str1); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c deleted file mode 100644 index 51ff96028be..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strlen-4.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target mempcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */ -/* { dg-final { scan-tree-dump-times "strlen" 1 "strlen" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -char * test (char *str1, char *str2) -{ - size_t len = strlen (str2); - char *p = (char *)mempcpy (str1, str2, len + 1); - return p + len + strlen (str1); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c b/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c deleted file mode 100644 index bbafecc3063..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-strlen-5.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-strlen" } */ -/* { dg-final { scan-tree-dump-times "strlen" 2 "strlen" } } */ -/* { dg-final { scan-tree-dump "memcpy" "strlen" } } */ - -#include "../../gcc.dg/strlenopt.h" - -size_t test (char *str1, char *str2) -{ - size_t len1 = strlen (str1); - size_t len2 = strlen (str2); - strcat (str1, str2); - return len1 + len2 + strlen (str1); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c deleted file mode 100644 index d6148a87fd1..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-1.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions" } */ -/* { dg-final { scan-tree-dump "memcpy_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c deleted file mode 100644 index 18cff739b01..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-10.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump-not "memset_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (void *buf1, int c, size_t len) -{ - memset (buf1, c, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c deleted file mode 100644 index c53db6a17e4..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-11.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump-not "memmove_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (void *buf1, void *buf2, size_t len) -{ - memmove (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c deleted file mode 100644 index a076d17cd9a..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-12.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target mempcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump-not "mempcpy_nobnd" "chkpopt" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -void test (void *buf1, void *buf2, size_t len) -{ - mempcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c deleted file mode 100644 index 279cae3e5bf..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-13.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memcpy_nobnd_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c deleted file mode 100644 index b810c682569..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-14.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memset_nobnd_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int c, size_t len) -{ - memset (buf1, c, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-15.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-15.c deleted file mode 100644 index a9a79c1e330..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-15.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memmove_nobnd_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memmove (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-16.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-16.c deleted file mode 100644 index 6ce170c9d68..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-16.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target mempcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "mempcpy_nobnd_nochk" "chkpopt" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - mempcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-17.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-17.c deleted file mode 100644 index faf304c3303..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-17.c +++ /dev/null @@ -1,68 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } - { dg-require-effective-target mempcpy } - { dg-options "-O2 -Wrestrict -fcheck-pointer-bounds -mmpx" } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -/* There is no BUILT_IN_ST{P,R}NCPY_CHKP or BUILT_IN_STRNCAT_CHKP - so the test for them below are XFAIL. */ -char *stpncpy (char *__restrict, const char *__restrict, size_t); -char *strncpy (char *__restrict, const char *__restrict, size_t); -char *strncat (char *__restrict, const char *__restrict, size_t); - - -char a[8]; - -void test_memcpy (void) -{ - memcpy (a, a + 1, 3); /* { dg-warning ".memcpy\.chkp. accessing 3 bytes at offsets 0 and 1 overlaps 2 bytes at offset 1" } */ -} - -void test_memmove (void) -{ - memmove (a, a + 1, 3); -} - -void* test_mempcpy (void) -{ - return mempcpy (a, a + 1, 3); /* { dg-warning ".mempcpy\.chkp. accessing 3 bytes at offsets 0 and 1 overlaps 2 bytes at offset 1" } */ -} - -char* test_stpcpy (void) -{ - strcpy (a, "0123456"); - return stpcpy (a, a + 2); /* { dg-warning ".stpcpy\.chkp. accessing 6 bytes at offsets 0 and 2 overlaps 4 bytes at offset 2" } */ -} - -char* test_stpncpy (void) -{ - strcpy (a, "0123456"); - - /* There is no BUILT_IN_STPNCPY_CHKP so this isn't handled. */ - return stpncpy (a, a + 2, sizeof a); /* { dg-warning ".stpcpy\.chkp. accessing 7 bytes at offsets 0 and 2 overlaps 4 bytes at offset 2" "bug 82652" { xfail *-*-* } } */ -} - -void test_strcpy (void) -{ - strcpy (a, "0123456"); - strcpy (a, a + 1); /* { dg-warning ".strcpy\.chkp. accessing 7 bytes at offsets 0 and 1 overlaps 6 bytes at offset 1" } */ -} - -void test_strcat (int n) -{ - strcat (a, a + 3); /* { dg-warning ".strcat\.chkp. accessing 4 or more bytes at offsets 0 and 3 may overlap 1 byte at offset 3" } */ -} - -void test_strncat (int n) -{ - strncat (a, a + 3, sizeof a); /* { dg-warning ".strncat\.chkp. accessing 0 or more bytes at offsets 0 and 3 may overlap 1 byte" "bug 82652" { xfail *-*-* } } */ -} - -void test_strncpy (int n) -{ - strcpy (a, "0123456"); - - /* There is no BUILT_IN_STRNCPY_CHKP so this isn't handled. */ - strncpy (a, a + 2, sizeof a); /* { dg-warning ".strncpy\.chkp. accessing 7 bytes at offsets 0 and 2 overlaps 5 bytes at offset 2" "bug 82652" { xfail *-*-* } } */ -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-2.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-2.c deleted file mode 100644 index 6a0c24ee887..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-2.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions" } */ -/* { dg-final { scan-tree-dump "memset_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int c, size_t len) -{ - memset (buf1, c, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-3.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-3.c deleted file mode 100644 index 310dec77456..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-3.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions" } */ -/* { dg-final { scan-tree-dump "memmove_nochk" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memmove (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-4.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-4.c deleted file mode 100644 index 7a30d17b8e6..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-4.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target mempcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-nochk-string-functions" } */ -/* { dg-final { scan-tree-dump "mempcpy_nochk" "chkpopt" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - mempcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-5.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-5.c deleted file mode 100644 index 39850d62be8..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-5.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memcpy_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-6.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-6.c deleted file mode 100644 index 06dcbfb9a25..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-6.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memset_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int c, size_t len) -{ - memset (buf1, c, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-7.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-7.c deleted file mode 100644 index 40ded068f8e..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-7.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "memmove_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - memmove (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-8.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-8.c deleted file mode 100644 index 7e575bb40bb..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-8.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-require-effective-target mempcpy } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump "mempcpy_nobnd" "chkpopt" } } */ - -#define USE_GNU -#include "../../gcc.dg/strlenopt.h" - -void test (int *buf1, int *buf2, size_t len) -{ - mempcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/chkp-stropt-9.c b/gcc/testsuite/gcc.target/i386/chkp-stropt-9.c deleted file mode 100644 index bf26874e5a8..00000000000 --- a/gcc/testsuite/gcc.target/i386/chkp-stropt-9.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -fdump-tree-chkpopt -fchkp-use-fast-string-functions" } */ -/* { dg-final { scan-tree-dump-not "memcpy_nobnd" "chkpopt" } } */ - -#include "../../gcc.dg/strlenopt.h" - -void test (void *buf1, void *buf2, size_t len) -{ - memcpy (buf1, buf2, len); -} diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc b/gcc/testsuite/gcc.target/i386/funcspec-56.inc index 9c9c347e8cd..437b12fc67d 100644 --- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc +++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc @@ -62,7 +62,6 @@ extern void test_pku (void) __attribute__((__target__("pku"))); extern void test_lwp (void) __attribute__((__target__("lwp"))); extern void test_hle (void) __attribute__((__target__("hle"))); extern void test_fxsr (void) __attribute__((__target__("fxsr"))); -extern void test_mpx (void) __attribute__((__target__("mpx"))); extern void test_clwb (void) __attribute__((__target__("clwb"))); extern void test_cld (void) __attribute__((__target__("cld"))); @@ -130,7 +129,6 @@ extern void test_no_pku (void) __attribute__((__target__("no-pku"))); extern void test_no_lwp (void) __attribute__((__target__("no-lwp"))); extern void test_no_hle (void) __attribute__((__target__("no-hle"))); extern void test_no_fxsr (void) __attribute__((__target__("no-fxsr"))); -extern void test_no_mpx (void) __attribute__((__target__("no-mpx"))); extern void test_no_clwb (void) __attribute__((__target__("no-clwb"))); extern void test_no_cld (void) __attribute__((__target__("no-cld"))); diff --git a/gcc/testsuite/gcc.target/i386/i386.exp b/gcc/testsuite/gcc.target/i386/i386.exp index 6b30de3022f..91fa2a61af2 100644 --- a/gcc/testsuite/gcc.target/i386/i386.exp +++ b/gcc/testsuite/gcc.target/i386/i386.exp @@ -24,7 +24,6 @@ if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { # Load support procs. load_lib gcc-dg.exp load_lib clearcap.exp -load_lib mpx-dg.exp # Return 1 if attribute ms_hook_prologue is supported. proc check_effective_target_ms_hook_prologue { } { diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-11.c deleted file mode 100644 index b6bd51be63a..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-11.c +++ /dev/null @@ -1,7 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mindirect-branch=thunk-extern -fcf-protection -fcheck-pointer-bounds -mmpx" } */ - -void -bar (void) -{ /* { dg-error "'-mindirect-branch=thunk-extern', '-fcf-protection=branch' and '-fcheck-pointer-bounds' are not compatible" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-12.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-12.c deleted file mode 100644 index 2c3848e1fb0..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-12.c +++ /dev/null @@ -1,7 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mindirect-branch=thunk -fcf-protection -fcheck-pointer-bounds -mmpx" } */ - -void -bar (void) -{ -} diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-12.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-12.c deleted file mode 100644 index 5da515690d4..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-12.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mindirect-branch=keep -fcf-protection -fcheck-pointer-bounds -mmpx" } */ - -__attribute__ ((indirect_branch("thunk-extern"))) -void -bar (void) -{ /* { dg-error "'-mindirect-branch=thunk-extern', '-fcf-protection=branch' and '-fcheck-pointer-bounds' are not compatible" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-13.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-13.c deleted file mode 100644 index a671e460098..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-13.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mindirect-branch=keep -fcf-protection -fcheck-pointer-bounds -mmpx" } */ - -__attribute__ ((indirect_branch("thunk-inline"))) -void -bar (void) -{ -} diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c deleted file mode 100644 index 73d16baddc7..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - -void (*dispatch) (char *); -char buf[10]; - -void -foo (void) -{ - dispatch (buf); -} - -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "bnd ret" } } */ -/* { dg-final { scan-assembler {\tpause} } } */ -/* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c deleted file mode 100644 index 856751ac224..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - -void (*dispatch) (char *); -char buf[10]; - -int -foo (void) -{ - dispatch (buf); - return 0; -} - -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_(r|e)ax" } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "bnd ret" } } */ -/* { dg-final { scan-assembler {\tpause} } } */ -/* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c deleted file mode 100644 index 42312f65588..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-3.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - -void bar (char *); -char buf[10]; - -void -foo (void) -{ - bar (buf); -} - -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" } } */ -/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "bnd ret" } } */ -/* { dg-final { scan-assembler {\tpause} } } */ -/* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c deleted file mode 100644 index 8850f2ffca4..00000000000 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-4.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile { target { *-*-linux* && { ! x32 } } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fpic -fno-plt" } */ - -void bar (char *); -char buf[10]; - -int -foo (void) -{ - bar (buf); - return 0; -} - -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar@GOT" } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_(r|e)ax" } } */ -/* { dg-final { scan-assembler-times "bnd call\[ \t\]*\.LIND" 1 } } */ -/* { dg-final { scan-assembler "bnd ret" } } */ -/* { dg-final { scan-assembler {\tpause} } } */ -/* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c deleted file mode 100644 index e07688e7ee2..00000000000 --- a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-1.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -mmpx" } */ - -typedef unsigned int uword_t __attribute__ ((mode (__word__))); - -void -__attribute__((interrupt)) -fn1 (void *frame) -{ /* { dg-message "MPX instructions aren't allowed in interrupt service routine" } */ -} - -void -__attribute__((interrupt)) -fn2 (void *frame, uword_t error) -{ /* { dg-message "MPX instructions aren't allowed in exception service routine" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c b/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c deleted file mode 100644 index 641ca637f8c..00000000000 --- a/gcc/testsuite/gcc.target/i386/interrupt-bnd-err-2.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -mmpx" } */ - -void -__attribute__((no_caller_saved_registers)) -fn (void *frame) -{ /* { dg-message "MPX instructions aren't allowed in function with no_caller_saved_registers attribute" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/alloca-1-lbv.c deleted file mode 100644 index 1c77c192c17..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-lbv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)__builtin_alloca (100 * sizeof(int)); - - rd (buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/alloca-1-nov.c deleted file mode 100644 index 835015fc432..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-nov.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)__builtin_alloca (100 * sizeof(int)); - - rd (buf, 0); - rd (buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/alloca-1-ubv.c deleted file mode 100644 index c57c6c4811f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/alloca-1-ubv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)__builtin_alloca (100 * sizeof(int)); - - rd (buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-lbv.c deleted file mode 100644 index 1fd2036cf06..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int foo (int i, int j) -{ - return rd(&i, j); -} - -int mpx_test (int argc, const char **argv) -{ - foo (1, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-nov.c deleted file mode 100644 index 4e338c76f7c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int foo (int i, int j) -{ - return rd(&i, j); -} - -int mpx_test (int argc, const char **argv) -{ - foo (1, 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-ubv.c deleted file mode 100644 index 65cb46bcd3f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/arg-addr-1-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int foo (int i, int j) -{ - return rd(&i, j); -} - -int mpx_test (int argc, const char **argv) -{ - foo (1, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-lbv.c deleted file mode 100644 index deca6fd6a97..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-lbv.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s { - int a; - int b : 10; - int c : 1; - int e : 10; -} s; - -#define HH (unsigned char)1 - -int foo (struct s *p) -{ - int val = p->b; - printf ("%d\n", val); - return val == HH; -} - -int mpx_test (int argc, const char **argv) -{ - struct s buf[100]; - - foo (buf - 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-nov.c deleted file mode 100644 index 0a7913a256d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-nov.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s { - int a; - int b : 10; - int c : 1; - int e : 10; -} s; - -#define HH (unsigned char)1 - -int foo (struct s *p) -{ - int val = p->b; - printf ("%d\n", val); - return val == HH; -} - -int mpx_test (int argc, const char **argv) -{ - struct s buf[100]; - - foo (buf); - foo (buf + 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-ubv.c deleted file mode 100644 index a20a7897fce..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/bitfields-1-ubv.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s { - int a; - int b : 10; - int c : 1; - int e : 10; -} s; - -#define HH (unsigned char)1 - -int foo (struct s *p) -{ - int val = p->b; - printf ("%d\n", val); - return val == HH; -} - -int mpx_test (int argc, const char **argv) -{ - struct s buf[100]; - - foo (buf + 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-lbv.c deleted file mode 100644 index 140848e0158..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-lbv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_bounds (buf - 1, sizeof (int)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-nov.c deleted file mode 100644 index 055b61d649c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-nov.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_bounds (buf, sizeof (int) * 100); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-ubv.c deleted file mode 100644 index f811694b9ee..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-ubv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_bounds (buf + 100, sizeof (int)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-2.c deleted file mode 100644 index 47e62e7834d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-2.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_bounds (buf - 1, sizeof (int)); - __bnd_chk_ptr_bounds (buf + 100, sizeof (int)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-lbv.c deleted file mode 100644 index 085166fc142..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-lbv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_lbounds (buf - 1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-nov.c deleted file mode 100644 index 3a666d8e300..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-nov.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_lbounds (buf); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-2.c deleted file mode 100644 index 87b80e0b62c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-2.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_lbounds (buf - 1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-nov.c deleted file mode 100644 index 8a73fe367d1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-nov.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_ubounds (buf + 99); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-ubv.c deleted file mode 100644 index eb22dd1936a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-ubv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_ubounds (buf + 100); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-2.c deleted file mode 100644 index 503bd53a60b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-2.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - __bnd_chk_ptr_ubounds (buf + 100); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-1.c deleted file mode 100644 index 0949f6acd87..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_copy_ptr_bounds (buf + 10, buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-lbv.c deleted file mode 100644 index a7317e71785..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-lbv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - int *p1 = __bnd_copy_ptr_bounds (buf, p); - p1[9] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-nov.c deleted file mode 100644 index 6b6423e3c6d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-nov.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - int *p1 = __bnd_copy_ptr_bounds (buf, p); - p1[10] = argc; - p1[19] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-ubv.c deleted file mode 100644 index 2893d9be1f9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-ubv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - int *p1 = __bnd_copy_ptr_bounds (buf, p); - p1[20] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-3.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-3.c deleted file mode 100644 index 4d0137579eb..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-3.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_copy_ptr_bounds (buf + 10, buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-1.c deleted file mode 100644 index 2a7f46ff2d6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -char buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf == __bnd_get_ptr_lbound (buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-2.c deleted file mode 100644 index 70b49e312b6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-2.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -char buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert ((void *)0 == __bnd_get_ptr_lbound (buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-1.c deleted file mode 100644 index a9111f35d7d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -char buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 99 == __bnd_get_ptr_ubound (buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-2.c deleted file mode 100644 index cf0aca14a6b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-2.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -char buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert ((void *)-1 == __bnd_get_ptr_ubound (buf)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-1.c deleted file mode 100644 index ee259cc9fb6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_init_ptr_bounds (buf + 10)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-2-nov.c deleted file mode 100644 index da44e7a9642..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-2-nov.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p = __bnd_init_ptr_bounds (p); - p[-1] = argc; - p[10] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-3.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-3.c deleted file mode 100644 index 8c1527025f6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-3.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_init_ptr_bounds (buf + 10)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-1.c deleted file mode 100644 index 4ac49abd70a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_narrow_ptr_bounds (buf + 10, buf, 4)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-lbv.c deleted file mode 100644 index 21a8f927f47..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-lbv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20); - p[9] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-nov.c deleted file mode 100644 index 8182d029e07..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-nov.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20); - p[10] = argc; - p[19] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-ubv.c deleted file mode 100644 index 6ff90cee593..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-ubv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20); - p[20] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-lbv.c deleted file mode 100644 index 69b4a51b490..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-lbv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100); - p[-1] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-nov.c deleted file mode 100644 index 0c13b123d8f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-nov.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100); - p[0] = argc; - p[89] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-ubv.c deleted file mode 100644 index 445e3375834..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-ubv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100); - p[90] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-4.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-4.c deleted file mode 100644 index 144855cfabd..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-4.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf - 10 == __bnd_narrow_ptr_bounds (buf - 10, buf, 4)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-null-ptr-bounds-1-bbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-null-ptr-bounds-1-bbv.c deleted file mode 100644 index 5497ef1d2da..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-null-ptr-bounds-1-bbv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_null_ptr_bounds (buf + 10); - p[0] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-1.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-1.c deleted file mode 100644 index 8abb2576654..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-1.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_set_ptr_bounds (buf + 10, 4)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-lbv.c deleted file mode 100644 index bbc578abd2c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-lbv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p[-1] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-nov.c deleted file mode 100644 index 39df101ad50..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-nov.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p[0] = argc; - p[9] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-ubv.c deleted file mode 100644 index c2d27e71065..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-ubv.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p[10] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-3.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-3.c deleted file mode 100644 index 811cdb4e116..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-3.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - assert (buf + 10 == __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-lbv.c deleted file mode 100644 index af6c8dbe59c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-lbv.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p; - -int mpx_test (int argc, const char **argv) -{ - int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p = buf; - __bnd_store_ptr_bounds ((void **)&p, p1 - 10); - p[9] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-nov.c deleted file mode 100644 index 9e9ea305ae8..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-nov.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int *p; - -int mpx_test (int argc, const char **argv) -{ - int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p = buf; - __bnd_store_ptr_bounds ((void **)&p, p1 - 10); - p[10] = argc; - p[19] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-ubv.c deleted file mode 100644 index 62aca8c131b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-ubv.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p; - -int mpx_test (int argc, const char **argv) -{ - int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p = buf; - __bnd_store_ptr_bounds ((void **)&p, p1 - 10); - p[20] = argc; - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-2.c b/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-2.c deleted file mode 100644 index a2ca7900915..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-2.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fno-check-pointer-bounds" } */ - - -#include "mpx-check.h" - -int buf[100]; -int *p; - -int mpx_test (int argc, const char **argv) -{ - int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10); - p = buf; - __bnd_store_ptr_bounds ((void **)&p, p1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c deleted file mode 100644 index 0ba5d73229d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)calloc (100, sizeof(int)); - - rd (buf, -1); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c deleted file mode 100644 index cb755e57391..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)calloc (100, sizeof(int)); - - rd (buf, 0); - rd (buf, 99); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c deleted file mode 100644 index a932a8c7b47..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/calloc-1-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)calloc (100, sizeof(int)); - - rd (buf, 100); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-1.c b/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-1.c deleted file mode 100644 index cb4d22984b6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-1.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -#include "math.h" - -double -test1 (double x, double y, double (*fn)(double, double)) -{ - return fn (x, y); -} - -double -test2 (double x, double y) -{ - return test1 (x, y, copysign); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-2.c b/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-2.c deleted file mode 100644 index 951e7dece19..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-2.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O3 -fcheck-pointer-bounds -mmpx -fno-inline" } */ - -#include "math.h" - -double -test1 (double x, double y, double (*fn)(double, double)) -{ - return fn (x, y); -} - -double -test2 (double x, double y) -{ - return test1 (x, y, copysign); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-3.c b/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-3.c deleted file mode 100644 index 439f631a3b9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fexceptions -fcheck-pointer-bounds -mmpx" } */ - -extern int f2 (const char*, int, ...); -extern long int f3 (int *); -extern void err (void) __attribute__((__error__("error"))); - -extern __inline __attribute__ ((__always_inline__)) int -f1 (int i, ...) -{ - if (__builtin_constant_p (i)) - { - if (i) - err (); - return f2 ("", i); - } - - return f2 ("", i); -} - -int -test () -{ - int i; - - if (f1 (0)) - if (f3 (&i)) - i = 0; - - return i; -} - - diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-4.c b/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-4.c deleted file mode 100644 index 1b7d7032ecb..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-fix-calls-4.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-Os -fcheck-pointer-bounds -mmpx" } */ - -typedef void (func) (int *); - -static inline void -bar (func f) -{ - int i; - f (&i); -} - -void -foo () -{ - bar (0); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-1.cc b/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-1.cc deleted file mode 100644 index 26d3c48a621..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-1.cc +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -namespace -{ - template <int dim> - int __attribute__((noinline)) - f1 () - { - return dim; - } -} - -int -test () -{ - return f1<3> (); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-2.cc b/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-2.cc deleted file mode 100644 index 2b1abe9b67d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-2.cc +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -class c1 -{ -public: - virtual int test1 (const char *); -}; - -class c2 -{ -public: - int test2 (const char *); -}; - -int -c1::test1 (const char *) -{ - return 0; -} - -int -c2::test2 (const char *) -{ - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-3.c b/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-3.c deleted file mode 100644 index dd0057e2981..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/chkp-thunk-comdat-3.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O -fvisibility=hidden" } */ - -int val; - -static int __attribute__((noinline)) -test1 () -{ - return val; -} - -static int __attribute__((bnd_legacy,noinline)) -test2 () -{ - return test1 (); -} - -int -test3 (void) -{ - return test2 (); -} - diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-lbv.c deleted file mode 100644 index 6f9ba88fed5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-nov.c deleted file mode 100644 index 6a2896e0125..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf, 0); - rd (buf1, buf, 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-ubv.c deleted file mode 100644 index b5edc438f27..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-1-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf, 10); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-lbv.c deleted file mode 100644 index cbe7343e018..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p2[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf, buf1, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-nov.c deleted file mode 100644 index 83773d0d90c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p2[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf, buf1, 0); - rd (buf, buf1, 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-ubv.c deleted file mode 100644 index 1a614fa3610..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/fastcall-2-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-require-effective-target ia32 } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -__attribute__((fastcall)) int rd (int *p1, int *p2, int i) -{ - int res = p2[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - rd (buf, buf1, 10); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-lbv.c deleted file mode 100644 index 46a58123bf4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-nov.c deleted file mode 100644 index b8500ff333d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-nov.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, 0); - foo(&s.a, 101); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-ubv.c deleted file mode 100644 index 990adee3bb2..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-1-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, 102); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-lbv.c deleted file mode 100644 index cd8d59afd22..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int arr[100]; -} S; - -struct S sa[10]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (&sa[argc].arr[0], -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-nov.c deleted file mode 100644 index 90f79a0eaed..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-nov.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#include "mpx-check.h" - -struct S { - int arr[100]; -} S; - -struct S sa[10]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (&sa[argc].arr[0], 0); - rd (&sa[argc].arr[0], 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-ubv.c deleted file mode 100644 index b6a9ad07071..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-10-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int arr[100]; -} S; - -struct S sa[10]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (&sa[argc].arr[0], 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-lbv.c deleted file mode 100644 index fdf39672315..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-lbv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-nov.c deleted file mode 100644 index 2a685036ca0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-nov.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */ - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-ubv.c deleted file mode 100644 index b07b09ff808..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-2-ubv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *i, int k) -{ - printf ("%d\n", i[k]); - return i[k]; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo(&s.a, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-lbv.c deleted file mode 100644 index ea919d80fbc..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S s; - -int mpx_test (int argc, const char **argv) -{ - foo (&s.b[0], -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-nov.c deleted file mode 100644 index 12f42c4d289..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-nov.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S s; - -int mpx_test (int argc, const char **argv) -{ - foo (&s.b[0], 0); - foo (&s.b[0], 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-ubv.c deleted file mode 100644 index 55a8af3a0ce..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-3-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S s; - -int mpx_test (int argc, const char **argv) -{ - foo (&s.b[0], 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-lbv.c deleted file mode 100644 index 23cf71ed6df..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-lbv.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.a[0].a, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-nov.c deleted file mode 100644 index 791753244f3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-nov.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.a[9].c, 0); - foo (&s1.a[0].a, 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-ubv.c deleted file mode 100644 index 0d4ac020cf3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-4-ubv.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.a[9].c, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-lbv.c deleted file mode 100644 index c00d42f3213..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-lbv.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.b.b[0], -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-nov.c deleted file mode 100644 index b69895e1d20..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-nov.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.b.b[0], 0); - foo (&s1.b.b[0], 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-ubv.c deleted file mode 100644 index d00f41eb86e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-5-ubv.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&s1.b.b[0], 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-lbv.c deleted file mode 100644 index 91b64bf462d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-lbv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; -struct S1 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[0].a), -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-nov.c deleted file mode 100644 index f837f57a421..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-nov.c +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; -struct S1 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[0].a), 0); - foo (&(s2->a[9].a), 101); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-ubv.c deleted file mode 100644 index 97ef911406e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-6-ubv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -struct S1 { - int x; - struct S a[10]; - struct S b; -} S1; - -int foo (int *p, int i) -{ - printf ("%d\n", p[i]); - return p[i]; -} - -struct S1 s1; -struct S1 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[9].a), 102); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-lbv.c deleted file mode 100644 index 176971168e5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-lbv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[-1].a), 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-nov.c deleted file mode 100644 index 19c09b8271e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-nov.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[0].a), 0); - foo (&(s2->a[9].c), 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-ubv.c deleted file mode 100644 index c9e8ae2442c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-7-ubv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[10].a), 0); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-lbv.c deleted file mode 100644 index cac6784175b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-lbv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s1.a[argc].b[-1].a[0]), 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-nov.c deleted file mode 100644 index e7243a989f9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-nov.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s1.a[argc].b[0].a[0]), 0); - foo (&(s1.a[argc].b[0].a[0]), 9); - foo (&(s1.a[argc].b[9].a[0]), 0); - foo (&(s1.a[argc].b[9].a[0]), 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-ubv.c deleted file mode 100644 index d2792e1bba4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-8-ubv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s1.a[argc].b[10].a[0]), 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-lbv.c deleted file mode 100644 index 127d0966330..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-lbv.c +++ /dev/null @@ -1,44 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int first; - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[argc].b[5].a[0]), -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-nov.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-nov.c deleted file mode 100644 index 7f98b0188a3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-nov.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#include "mpx-check.h" - -struct S { - int first; - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[argc].b[5].a[0]), 0); - foo (&(s2->a[argc].b[5].a[0]), 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-ubv.c deleted file mode 100644 index a65b8f0d17f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/field-addr-9-ubv.c +++ /dev/null @@ -1,44 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int first; - int a[10]; - int b; -} S; - -struct S1 { - int a; - struct S b[10]; - int c; -} S1; - -struct S2 { - int x; - struct S1 a[10]; - struct S1 b; -} S2; - -int foo (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -struct S2 s1; -struct S2 *s2 = &s1; - -int mpx_test (int argc, const char **argv) -{ - foo (&(s2->a[argc].b[5].a[0]), 10); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/frame-address-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/frame-address-1-nov.c deleted file mode 100644 index 87cc2dd1cfc..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/frame-address-1-nov.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int mpx_test (int argc, const char **argv) -{ - void **fa = (void **)__builtin_frame_address (0); - printf ("%p\n", *fa); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/hard-reg-1-nov.c deleted file mode 100644 index 8cf72e55543..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ -#ifdef __x86_64__ - register int *frame __asm__("rsp"); -#else - register int *frame __asm__("esp"); -#endif - rd (frame, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-lbv.c deleted file mode 100644 index 38fe59f8be9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-lbv.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do run { target sse2_runtime } } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -msse2" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -typedef int v16 __attribute__((vector_size(16))); - -int foo(int i) { - register v16 u asm("xmm0"); - return u[i]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo (-1)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-nov.c deleted file mode 100644 index 1db83f5b547..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-nov.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run { target sse2_runtime } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -msse2" } */ - -#include "mpx-check.h" - -typedef int v16 __attribute__((vector_size(16))); - -int foo (int i) { - register v16 u asm ("xmm0"); - return u[i]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo (3)); - printf ("%d\n", foo (0)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-ubv.c deleted file mode 100644 index 66607805ca4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/hard-reg-2-ubv.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do run { target sse2_runtime } } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -msse2" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -typedef int v16 __attribute__((vector_size(16))); - -int foo (int i) { - register v16 u asm ("xmm0"); - return u[i]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo (5)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-lbv.c deleted file mode 100644 index 29fa443697f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-lbv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 < p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-nov.c deleted file mode 100644 index 576ea8487e3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-nov.c +++ /dev/null @@ -1,28 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 < p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, 0); - rd (buf, p, 9); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-ubv.c deleted file mode 100644 index 021a3aed267..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-1-ubv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 < p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, 10); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-lbv.c deleted file mode 100644 index 5d7fe6299a5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-lbv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 > p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-nov.c deleted file mode 100644 index 327c108f789..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-nov.c +++ /dev/null @@ -1,28 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 > p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, 0); - rd (buf, p, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-ubv.c deleted file mode 100644 index 3047f7b5104..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/if-stmt-2-ubv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p1, int *p2, int i) -{ - int res; - - if (p1 > p2) - p1 = p2; - - res = p1[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 40); - rd (buf, p, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/label-address-1.c b/gcc/testsuite/gcc.target/i386/mpx/label-address-1.c deleted file mode 100644 index f4cd360b1d4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/label-address-1.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -void *p; -int mpx_test (int argc, const char **argv) -{ - p = &&label; - - label: - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/legacy-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/legacy-1-nov.c deleted file mode 100644 index b51ac7f0271..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/legacy-1-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -__attribute__((bnd_legacy)) -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p = __bnd_set_ptr_bounds (buf + 1, 10); - - rd (p, -1); - rd (p, 10); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/macro.c b/gcc/testsuite/gcc.target/i386/mpx/macro.c deleted file mode 100644 index 00d467bd19d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/macro.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -#ifndef __MPX__ -#error -mmpx is required -#endif - -#ifndef __CHKP__ -#error -fcheck-pointer-bounds is required -#endif - -int mpx_test (int argc, const char **argv) -{ - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c deleted file mode 100644 index aa2aed983cf..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - - rd (buf, -1); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c deleted file mode 100644 index 56f26e964d8..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - - rd (buf, 0); - rd (buf, 99); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c deleted file mode 100644 index 6f48ec26923..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/malloc-1-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - - rd (buf, 100); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/memcpy-1.c b/gcc/testsuite/gcc.target/i386/mpx/memcpy-1.c deleted file mode 100644 index 6ecbdc1a322..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/memcpy-1.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* Fix for PR78631 */ - -#define SHOULDFAIL - -#include <stdio.h> -#include <string.h> -#include "mpx-check.h" - -char s[10]; -char d[10]; -__attribute__((noinline)) - -char* foo(char* dst, char* src, size_t size) { - return memcpy(dst, src, size); -} -int mpx_test(int argc, const char **argv) { - char* r = foo(d, s, 11); - printf("r = %p\n", r); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/memmove-1.c b/gcc/testsuite/gcc.target/i386/mpx/memmove-1.c deleted file mode 100644 index 0efd0303075..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/memmove-1.c +++ /dev/null @@ -1,117 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include <stdint.h> -#include <string.h> -#include "mpx-check.h" - -#ifdef __i386__ -/* i386 directory size is 4MB. */ -#define MPX_NUM_L2_BITS 10 -#define MPX_NUM_IGN_BITS 2 -#else /* __i386__ */ -/* x86_64 directory size is 2GB. */ -#define MPX_NUM_L2_BITS 17 -#define MPX_NUM_IGN_BITS 3 -#endif /* !__i386__ */ - - -/* bt_num_of_elems is the number of elements in bounds table. */ -unsigned long bt_num_of_elems = (1UL << MPX_NUM_L2_BITS); -/* Function to test MPX wrapper of memmove function. - src_bigger_dst determines which address is bigger, can be 0 or 1. - src_bt_index and dst_bt index are bt_indexes - from the beginning of the page. - bd_index_end is the bd index of the last element of src if we define - bd index of the first element as 0. - src_bt index_end is bt index of the last element of src. - pointers inside determines if array being copied includes pointers - src_align and dst_align are alignments of src and dst. - Arrays may contain unaligned pointers. */ -int -test (int src_bigger_dst, int src_bt_index, int dst_bt_index, - int bd_index_end, int src_bt_index_end, int pointers_inside, - int src_align, int dst_align) -{ - const int n = - src_bt_index_end - src_bt_index + bd_index_end * bt_num_of_elems; - if (n < 0) - { - return 0; - } - const int num_of_pointers = (bd_index_end + 2) * bt_num_of_elems; - void **arr = 0; - posix_memalign ((void **) (&arr), - 1UL << (MPX_NUM_L2_BITS + MPX_NUM_IGN_BITS), - num_of_pointers * sizeof (void *)); - void **src = arr, **dst = arr; - if ((src_bigger_dst) && (src_bt_index < dst_bt_index)) - src_bt_index += bt_num_of_elems; - if (!(src_bigger_dst) && (src_bt_index > dst_bt_index)) - dst_bt_index += bt_num_of_elems; - src += src_bt_index; - dst += dst_bt_index; - char *realign = (char *) src; - realign += src_align; - src = (void **) realign; - realign = (char *) dst; - realign += src_align; - dst = (void **) realign; - if (pointers_inside) - { - for (int i = 0; i < n; i++) - src[i] = __bnd_set_ptr_bounds (arr + i, i * sizeof (void *) + 1); - } - memmove (dst, src, n * sizeof (void *)); - if (pointers_inside) - { - for (int i = 0; i < n; i++) - { - if (dst[i] != arr + i) - abort (); - if (__bnd_get_ptr_lbound (dst[i]) != arr + i) - abort (); - if (__bnd_get_ptr_ubound (dst[i]) != arr + 2 * i) - abort (); - } - } - free (arr); - return 0; -} - -/* Call testall to test common cases of memmove for MPX. */ -void -testall () -{ - int align[3]; - align[0] = 0; - align[1] = 1; - align[2] = 7; - for (int pointers_inside = 0; pointers_inside < 2; pointers_inside++) - for (int src_bigger_dst = 0; src_bigger_dst < 2; src_bigger_dst++) - for (int src_align = 0; src_align < 3; src_align ++) - for (int dst_align = 0; dst_align < 3; dst_align ++) - for (int pages = 0; pages < 4; pages++) - { - test (src_bigger_dst, 1, 2, pages, 1, pointers_inside, - align[src_align], align[dst_align]); - test (src_bigger_dst, 1, 2, pages, 2, pointers_inside, - align[src_align], align[dst_align]); - test (src_bigger_dst, 2, 1, pages, 12, pointers_inside, - align[src_align], align[dst_align]); - test (src_bigger_dst, 2, 1, pages, 1, pointers_inside, - align[src_align], align[dst_align]); - test (src_bigger_dst, 2, 3, pages, 12, pointers_inside, - align[src_align], align[dst_align]); - test (src_bigger_dst, 1, bt_num_of_elems - 2, pages, 2, - pointers_inside, align[src_align], align[dst_align]); - } -}; - -int -mpx_test (int argc, const char **argv) -{ - testall (); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/memmove-2.c b/gcc/testsuite/gcc.target/i386/mpx/memmove-2.c deleted file mode 100644 index e1d78fa47c6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/memmove-2.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include <stdint.h> -#include <string.h> -#include "mpx-check.h" - -#ifdef __i386__ -/* i386 directory size is 4MB. */ -#define MPX_NUM_L2_BITS 10 -#define MPX_NUM_IGN_BITS 2 -#else /* __i386__ */ -/* x86_64 directory size is 2GB. */ -#define MPX_NUM_L2_BITS 17 -#define MPX_NUM_IGN_BITS 3 -#endif /* !__i386__ */ - - -/* bt_num_of_elems is the number of elements in bounds table. */ -unsigned long bt_num_of_elems = (1UL << MPX_NUM_L2_BITS); - -/* Function to test MPX wrapper of memmove function. - Check case with no BT allocated for data. */ - -int -mpx_test (int argc, const char **argv) -{ - void **arr = 0; - posix_memalign ((void **) (&arr), - 1UL << (MPX_NUM_L2_BITS + MPX_NUM_IGN_BITS), - 2 * bt_num_of_elems * sizeof (void *)); - void **src = arr, **dst = arr, **ptr = arr; - src += 10; - dst += 1; - ptr += bt_num_of_elems + 100; - ptr[0] = __bnd_set_ptr_bounds (arr + 1, sizeof (void *) + 1); - memmove (dst, src, 5 * sizeof (void *)); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/memmove-zero-length.c b/gcc/testsuite/gcc.target/i386/mpx/memmove-zero-length.c deleted file mode 100644 index 78bfdebff03..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/memmove-zero-length.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "string.h" - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - - memmove (buf, NULL, 0); - memmove (NULL, buf, 0); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h deleted file mode 100644 index e622934fe32..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h +++ /dev/null @@ -1,48 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> -#include "cpuid.h" -#include "mpx-os-support.h" - -static int -__attribute__ ((noinline)) -mpx_test (int, const char **); - -#ifdef SHOULDFAIL -#define NORUNRES 1 -#else -#define NORUNRES 0 -#endif - -#define DEBUG - -static int -check_osxsave (void) -{ - unsigned int eax, ebx, ecx, edx; - - __cpuid (1, eax, ebx, ecx, edx); - return (ecx & bit_OSXSAVE) != 0; -} - -int -main (int argc, const char **argv) -{ - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) - return NORUNRES; - - /* Run MPX test only if host has MPX support. */ - if (check_osxsave () && (ebx & bit_MPX) && mpx_os_support ()) - mpx_test (argc, argv); - else - { -#ifdef DEBUG - printf ("SKIPPED\n"); -#endif - return NORUNRES; - } - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h deleted file mode 100644 index 8c9294d33a5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Check if the OS supports executing MPX instructions. */ - -#define XCR_XFEATURE_ENABLED_MASK 0x0 - -#define XSTATE_BNDREGS 0x8 - -static int -mpx_os_support (void) -{ - unsigned int eax, edx; - unsigned int ecx = XCR_XFEATURE_ENABLED_MASK; - - __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx)); - - return (eax & XSTATE_BNDREGS) != 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx.exp b/gcc/testsuite/gcc.target/i386/mpx/mpx.exp deleted file mode 100644 index 62d44697eab..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx.exp +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2014-2018 Free Software Foundation, Inc. -# -# 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/>. - -# Exit immediately if this isn't a x86 target. -if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { - return -} - -# Load support procs. -load_lib gcc-dg.exp -load_lib mpx-dg.exp - -# Initialize. -dg-init -mpx_init - -if [check_effective_target_mpx] { - # Run all tests. - gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c*]] "" "" -} - -# All done. -mpx_finish -dg-finish diff --git a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-lbv.c deleted file mode 100644 index 0e9d657fcbd..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-lbv.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int mpx_test (int argc, const char **argv) -{ - int a[100]; - - void rd (int i) - { - printf ("%d\n", a[i]); - } - - rd (-1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-nov.c deleted file mode 100644 index dd985466328..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-nov.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int mpx_test (int argc, const char **argv) -{ - int a[100]; - - void rd (int i) - { - printf ("%d\n", a[i]); - } - - rd (0); - rd (99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-ubv.c deleted file mode 100644 index b5cf6cc29b3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/nested-function-1-ubv.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int mpx_test (int argc, const char **argv) -{ - int a[100]; - - void rd (int i) - { - printf ("%d\n", a[i]); - } - - rd (100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-lbv.c deleted file mode 100644 index 58692efb0e3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-nov.c deleted file mode 100644 index 01279be8d3b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, 0); - rd (buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-ubv.c deleted file mode 100644 index c377c57eb6b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-1-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-lbv.c deleted file mode 100644 index ebe76cb8263..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-nov.c deleted file mode 100644 index 8b9fce2e297..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, buf, 0); - rd (0, 0, 0, 0, 0, buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-ubv.c deleted file mode 100644 index 525140e2d79..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-2-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-lbv.c deleted file mode 100644 index d6571be44b5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-lbv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int t6, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, 0, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-nov.c deleted file mode 100644 index e42ecba4e2a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-nov.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int t6, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, 0, buf, 0); - rd (0, 0, 0, 0, 0, 0, buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-ubv.c deleted file mode 100644 index 8da6252a03a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-3-ubv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int t1, int t2, int t3, int t4, int t5, int t6, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (0, 0, 0, 0, 0, 0, buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-lbv.c deleted file mode 100644 index 5a6842512db..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-nov.c deleted file mode 100644 index bb2bc46a6f3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf, 0); - rd (buf1, buf1, buf1, buf1, buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-ubv.c deleted file mode 100644 index cf3a5c48f1b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-4-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-lbv.c deleted file mode 100644 index 7c3bd867204..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf1, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-nov.c deleted file mode 100644 index 27e4a7130b0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf1, buf, 0); - rd (buf1, buf1, buf1, buf1, buf1, buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-ubv.c deleted file mode 100644 index 68e2654b91a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-arg-5-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int *t1, int *t2, int *t3, int *t4, int *t5, int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf1, buf1, buf1, buf1, buf1, buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c deleted file mode 100644 index 657991979f6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */ - -char * -foo (char *p, char *q) -{ - return (char *) (p - q); /* { dg-bogus "pointer bounds were lost due to unexpected expression" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-lbv.c deleted file mode 100644 index bde8c76e4b7..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-lbv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int *buf1[100]; -int buf2[100]; - -void wr (int i) -{ - buf1[i] = buf2; -} - -int rd(int i, int j) -{ - int res = buf1[i][j]; - printf("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - wr(10); - rd(10, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-nov.c deleted file mode 100644 index 269e3af17f0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-nov.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int *buf1[100]; -int buf2[100]; - -void wr (int i) -{ - buf1[i] = buf2; -} - -int rd(int i, int j) -{ - int res = buf1[i][j]; - printf("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - wr(10); - rd(10, 0); - rd(10, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-ubv.c deleted file mode 100644 index 4c8d45e003f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pointer-store-1-ubv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int *buf1[100]; -int buf2[100]; - -void wr (int i) -{ - buf1[i] = buf2; -} - -int rd(int i, int j) -{ - int res = buf1[i][j]; - printf("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - wr(10); - rd(10, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr65508.c b/gcc/testsuite/gcc.target/i386/mpx/pr65508.c deleted file mode 100644 index 9060287cac5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr65508.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -void -bar (int N) -{ - int a[N]; - void foo (int a[N]) - { - } - foo (a); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr65531.cc b/gcc/testsuite/gcc.target/i386/mpx/pr65531.cc deleted file mode 100644 index 049569c50b1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr65531.cc +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -#pragma interface - -struct S -{ - ~S () - { - } -}; - -S s; diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc b/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc deleted file mode 100644 index b29cd03ed0f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -march=corei7-avx" } */ - -struct c1 -{ - c1 (const c1 &other) : p (other.p) { }; - int *p; -}; - -struct c2 : public c1 { }; - -c1 -test (c2 a) -{ - return a; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66134.c b/gcc/testsuite/gcc.target/i386/mpx/pr66134.c deleted file mode 100644 index 3889674ed5f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66134.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -fno-tree-ccp" } */ - -extern int vfork (void) __attribute__ ((__nothrow__ , __leaf__)); -void test1 (void); -void test2 (void); -void test3 (int *); - -void test (int *p) -{ - test1 (); - p++; - test2 (); - p++; - vfork (); - test3 (p); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66566.c b/gcc/testsuite/gcc.target/i386/mpx/pr66566.c deleted file mode 100644 index a405c20ac0e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66566.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */ - -union jsval_layout -{ - void *asPtr; -}; -union jsval_layout a; -union jsval_layout b; -union jsval_layout __inline__ fn1() { return b; } - -void fn2() { a = fn1(); } diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66567.c b/gcc/testsuite/gcc.target/i386/mpx/pr66567.c deleted file mode 100644 index 5a7e2f29e80..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66567.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -void (*b) (); - -void fn1 (const int *p1) -{ - static void *a = &&conv_1234_123C; - conv_1234_123C: - ; -} - -void fn2 () -{ - b = fn1; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66568.c b/gcc/testsuite/gcc.target/i386/mpx/pr66568.c deleted file mode 100644 index 2653ebc0fa0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66568.c +++ /dev/null @@ -1,11 +0,0 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target fpic } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -O2 -fPIC" } */ - -extern void exit (int); -int a, b, c; -void *set_test () { - if (b) - a ? exit (0) : exit (1); - b = c; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66569.c b/gcc/testsuite/gcc.target/i386/mpx/pr66569.c deleted file mode 100644 index ba2023c6846..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66569.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -struct s1 { - int *p; - int i; -}; - -struct s2 { - struct s1 s; - int i; -}; - -int test (struct s2 s, ...) { } diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66581.c b/gcc/testsuite/gcc.target/i386/mpx/pr66581.c deleted file mode 100644 index 015faaeae50..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr66581.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -void *a; -int b; - -void -fn1 (void) -{ - void *c = &&l_nop; -l_nop: - for (; b;) - ; - int *d = c; - c = fn1; - *d = 1; - goto *a; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr68337-1.c b/gcc/testsuite/gcc.target/i386/mpx/pr68337-1.c deleted file mode 100644 index 3f8d79d4282..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr68337-1.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -#include "mpx-check.h" - -#define N 2 - -extern void abort (); - -static int -mpx_test (int argc, const char **argv) -{ - char ** src = (char **)malloc (sizeof (char *) * N); - char ** dst = (char **)malloc (sizeof (char *) * N); - int i; - - for (i = 0; i < N; i++) - src[i] = __bnd_set_ptr_bounds (argv[0] + i, i + 1); - - __builtin_memcpy(dst, src, sizeof (char *) * N); - - for (i = 0; i < N; i++) - { - char *p = dst[i]; - if (p != argv[0] + i - || __bnd_get_ptr_lbound (p) != p - || __bnd_get_ptr_ubound (p) != p + i) - abort (); - } - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr68337-2.c b/gcc/testsuite/gcc.target/i386/mpx/pr68337-2.c deleted file mode 100644 index 8845cca79be..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr68337-2.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ -/* { dg-final { scan-assembler-not "memcpy" } } */ - -void -test (void *dst, void *src) -{ - __builtin_memcpy (dst, src, sizeof (char *) / 2); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr68416.c b/gcc/testsuite/gcc.target/i386/mpx/pr68416.c deleted file mode 100644 index 10587edf251..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr68416.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */ -/* { dg-final { scan-assembler-not "bndmov" } } */ - -int -foo(int **arr, int i) -{ - return (*arr)[i]; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr78339.c b/gcc/testsuite/gcc.target/i386/mpx/pr78339.c deleted file mode 100644 index 3dd04240e8c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr78339.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -Wsuggest-attribute=noreturn" } */ - -extern _Noreturn void exit (int); -int main (void) { exit (1); } diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79631.c b/gcc/testsuite/gcc.target/i386/mpx/pr79631.c deleted file mode 100644 index 075d46b835f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79631.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -typedef struct { int _mp_size; } mpz_t[1]; -int a, b; -void fn1() -{ - mpz_t c[1][b]; - for (;;) { - int d = 0 >= 0 ? 0 == 0 ? c[0][0]->_mp_size ? -1 : 0 : 0 : 0, - e = 0 >= 0 ? 0 == 0 ? c[1][1]->_mp_size ? -1 : 0 : 0 : 0; - if (d != e) - a++; - } -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79633.c b/gcc/testsuite/gcc.target/i386/mpx/pr79633.c deleted file mode 100644 index 2a60ee82971..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79633.c +++ /dev/null @@ -1,11 +0,0 @@ -/* PR target/79633 */ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -w -O2" } */ - -extern void *memcpy (); - -void -foo () -{ - memcpy (); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79753.c b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c deleted file mode 100644 index 9b7bc52e1ed..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79753.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ - -int -foo (void) -{ - return 0; -} - -void -bar (int **p) -{ - *p = (int *) (__UINTPTR_TYPE__) foo (); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79770.c b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c deleted file mode 100644 index 0890fcc7bf1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79770.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile { target lp64 } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms -Wno-psabi" } */ - -typedef unsigned U __attribute__ ((vector_size (64))); -typedef unsigned __int128 V __attribute__ ((vector_size (64))); - -static inline V -bar (U u, U x, V v) -{ - v = (V)(U) { 0, ~0 }; - v[x[0]] <<= u[-63]; - return v; -} - -V -foo (U u) -{ - return bar (u, (U) {}, (V) {}); -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79987.c b/gcc/testsuite/gcc.target/i386/mpx/pr79987.c deleted file mode 100644 index b3ebda95694..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79987.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -extern void foo; -void *bar = &foo; /* { dg-warning "taking address of expression of type .void." } */ diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79988.c b/gcc/testsuite/gcc.target/i386/mpx/pr79988.c deleted file mode 100644 index a6e43eba562..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/pr79988.c +++ /dev/null @@ -1,6 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -void foo(unsigned char * __seg_gs *pointer_gs) { - pointer_gs[5] = 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c deleted file mode 100644 index 961196f71c0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 200 * sizeof(int)); - - rd (buf, -1); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c deleted file mode 100644 index f4b3dd86081..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 200 * sizeof(int)); - - rd (buf, 0); - rd (buf, 199); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c deleted file mode 100644 index 8a14baa7a94..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-1-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 200 * sizeof(int)); - - rd (buf, 200); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c deleted file mode 100644 index 919f62a490e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 10 * sizeof(int)); - - rd (buf, -1); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c deleted file mode 100644 index 569cd241cc9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 10 * sizeof(int)); - - rd (buf, 0); - rd (buf, 9); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c deleted file mode 100644 index 36eb90c1abf..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/realloc-2-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *buf = (int *)malloc (100 * sizeof(int)); - buf = (int *)realloc (buf, 10 * sizeof(int)); - - rd (buf, 10); - - free (buf); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-1-lbv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-1-lbv.cpp deleted file mode 100644 index ec5f546c081..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-1-lbv.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-1-nov.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-1-nov.cpp deleted file mode 100644 index 98f1622349a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-1-nov.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, 0); - rd (p, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-1-ubv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-1-ubv.cpp deleted file mode 100644 index d2135e7270f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-1-ubv.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-2-lbv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-2-lbv.cpp deleted file mode 100644 index 907cb06616c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-2-lbv.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *&p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-2-nov.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-2-nov.cpp deleted file mode 100644 index cdd927c891e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-2-nov.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *&p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, 0); - rd (p, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-2-ubv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-2-ubv.cpp deleted file mode 100644 index 2f75375d251..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-2-ubv.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int __attribute((nothrow)) -rd (int *&p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -void set_p (int *&ref) -{ - ref = buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - set_p (p); - rd (p, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-3-lbv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-3-lbv.cpp deleted file mode 100644 index 1330359797d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-3-lbv.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-3-nov.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-3-nov.cpp deleted file mode 100644 index 9a5519318a4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-3-nov.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, 0); - rd (buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-3-ubv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-3-ubv.cpp deleted file mode 100644 index 0a874fabb09..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-3-ubv.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int buf1[10]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-4-lbv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-4-lbv.cpp deleted file mode 100644 index 2442c6a4a9a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-4-lbv.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int (&get_buf ()) [100] -{ - return buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (get_buf (), -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-4-nov.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-4-nov.cpp deleted file mode 100644 index 9646cc0645d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-4-nov.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int (&get_buf ()) [100] -{ - return buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (get_buf (), 0); - rd (get_buf (), 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/reference-4-ubv.cpp b/gcc/testsuite/gcc.target/i386/mpx/reference-4-ubv.cpp deleted file mode 100644 index da3382357ab..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/reference-4-ubv.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int rd (int (&p)[100], int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int (&get_buf ()) [100] -{ - return buf; -} - -int mpx_test (int argc, const char **argv) -{ - int *p; - - rd (get_buf (), 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-lbv.c deleted file mode 100644 index 9a209b8d304..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-lbv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int *_buf1[100]; -int _buf2[100]; - -int **get_buf1 () -{ - return _buf1; -} - -int *get_buf2 () -{ - return _buf2; -} - -void wr (int i, int **buf1, int *buf2) -{ - buf1[i] = buf2; -} - -int rd (int i, int j, int **buf) -{ - int res = buf[i][j]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int **buf1 = get_buf1 (); - int *buf2 = get_buf2 (); - wr(10, buf1, buf2); - rd(10, -1, buf1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-nov.c deleted file mode 100644 index 62d05013909..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-nov.c +++ /dev/null @@ -1,41 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int *_buf1[100]; -int _buf2[100]; - -int **get_buf1 () -{ - return _buf1; -} - -int *get_buf2 () -{ - return _buf2; -} - -void wr (int i, int **buf1, int *buf2) -{ - buf1[i] = buf2; -} - -int rd (int i, int j, int **buf) -{ - int res = buf[i][j]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int **buf1 = get_buf1 (); - int *buf2 = get_buf2 (); - wr(10, buf1, buf2); - rd(10, 0, buf1); - rd(10, 99, buf1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-ubv.c deleted file mode 100644 index 4658aef1714..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-ubv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int *_buf1[100]; -int _buf2[100]; - -int **get_buf1 () -{ - return _buf1; -} - -int *get_buf2 () -{ - return _buf2; -} - -void wr (int i, int **buf1, int *buf2) -{ - buf1[i] = buf2; -} - -int rd (int i, int j, int **buf) -{ - int res = buf[i][j]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - int **buf1 = get_buf1 (); - int *buf2 = get_buf2 (); - wr(10, buf1, buf2); - rd(10, 100, buf1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-lbv.c deleted file mode 100644 index ef29427fff3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-nov.c deleted file mode 100644 index 12e1edd6c4c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-ubv.c deleted file mode 100644 index dda908b2203..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-1-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-lbv.c deleted file mode 100644 index bf370669d1c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-lbv.c +++ /dev/null @@ -1,41 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int *p1; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-nov.c deleted file mode 100644 index 577e3ab5dc1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int *p1; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-ubv.c deleted file mode 100644 index c5a7ad002af..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-2-ubv.c +++ /dev/null @@ -1,41 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int *p1; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-lbv.c deleted file mode 100644 index 1802ca837cf..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-lbv.c +++ /dev/null @@ -1,41 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p1; - int *p; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-nov.c deleted file mode 100644 index 2e5214a8278..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p1; - int *p; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-ubv.c deleted file mode 100644 index 83b81da8390..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-ubv.c +++ /dev/null @@ -1,41 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p1; - int *p; -} s1; - -int buf[100]; -int buf1[10]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - s.p1 = buf1; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-lbv.c deleted file mode 100644 index 7937514d67c..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-lbv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-nov.c deleted file mode 100644 index 352b5723266..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-nov.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-ubv.c deleted file mode 100644 index 14ba0bddb26..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-4-ubv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-lbv.c deleted file mode 100644 index 2bd871a8562..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-lbv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-nov.c deleted file mode 100644 index 978b4930675..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-nov.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-ubv.c deleted file mode 100644 index 633e15dbe67..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-5-ubv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-lbv.c deleted file mode 100644 index 9e2cf2cc26a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-lbv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; - int i3; - int i4; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-nov.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-nov.c deleted file mode 100644 index f2d60f470f3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-nov.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; - int i3; - int i4; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-ubv.c deleted file mode 100644 index 637051238b6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/return-struct-6-ubv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; - int i3; - int i4; -} s1; - -int buf[100]; - -struct s1 __attribute__((noinline)) get () -{ - struct s1 s; - s.p = buf; - return s; -} - -int __attribute__((noinline)) rd (struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = get (); - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/sincos-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/sincos-1-nov.c deleted file mode 100644 index da5f301a19a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/sincos-1-nov.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ -/* { dg-additional-options "-lm" } */ - - -#include "mpx-check.h" -#include "math.h" - -int mpx_test (int argc, const char **argv) -{ - double d1, d2; - d1 = sin(argc); - d2 = cos(argc); - - printf ("%f %f\n", d1, d2); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-array-1-lbv.c deleted file mode 100644 index cc1cf8ddd83..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-lbv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - printf("%d\n", buf[-1]); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-array-1-nov.c deleted file mode 100644 index 13d30c55ae5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-nov.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - printf("%d\n", buf[0]); - printf("%d\n", buf[99]); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-array-1-ubv.c deleted file mode 100644 index e3cac3cfa5d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-array-1-ubv.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - printf("%d\n", buf[100]); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-1-lbv.c deleted file mode 100644 index 7c0367e01e7..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-lbv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-1-nov.c deleted file mode 100644 index 0c91615239a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-nov.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[0]); - printf ("%d\n", p[99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-1-ubv.c deleted file mode 100644 index a19d92708d6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-1-ubv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-2-lbv.c deleted file mode 100644 index 1ad3be8ff63..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-lbv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s { - int a; - int *p; -} s; - -int buf[100]; - -struct s s1 = {0, buf}; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", s1.p[-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-2-nov.c deleted file mode 100644 index 6ef755f8971..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-nov.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s { - int a; - int *p; -} s; - -int buf[100]; - -struct s s1 = {0, buf}; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", s1.p[0]); - printf ("%d\n", s1.p[99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-2-ubv.c deleted file mode 100644 index 3681ebe03ea..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-2-ubv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s { - int a; - int *p; -} s; - -int buf[100]; - -struct s s1 = {0, buf}; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", s1.p[100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-3-lbv.c deleted file mode 100644 index 3aa21ca3619..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-lbv.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int foo (int i) -{ - static int **pp = &p; - - return (*pp)[i]; -} - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", foo (-1)); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-3-nov.c deleted file mode 100644 index 7bdc5af0911..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-nov.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int foo (int i) -{ - static int **pp = &p; - - return (*pp)[i]; -} - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", foo (0)); - printf ("%d\n", foo (99)); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-3-ubv.c deleted file mode 100644 index fb8411aa4cb..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-3-ubv.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p = buf; - -int foo (int i) -{ - static int **pp = &p; - - return (*pp)[i]; -} - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", foo (100)); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-4-lbv.c deleted file mode 100644 index 896838ec0ab..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-lbv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p[1] = { buf }; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[0][-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-4-nov.c deleted file mode 100644 index 3bdb5ec5162..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-nov.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf[100]; -int *p[1] = { buf }; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[0][0]); - printf ("%d\n", p[0][99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-4-ubv.c deleted file mode 100644 index 47bca2fc07f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-4-ubv.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf[100]; -int *p[1] = { buf }; - -int mpx_test (int argc, const char *argv[]) -{ - printf ("%d\n", p[0][100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-5-lbv.c deleted file mode 100644 index bd47a4a73aa..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-lbv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", s.b[0].p[0][-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-5-nov.c deleted file mode 100644 index 87fe35d4742..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-nov.c +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", s.b[0].p[0][0]); - printf ("%d\n", s.b[0].p[0][99]); - printf ("%d\n", s.b[0].p[1][0]); - printf ("%d\n", s.b[0].p[1][199]); - printf ("%d\n", s.b[1].p[0][0]); - printf ("%d\n", s.b[1].p[0][199]); - printf ("%d\n", s.b[1].p[1][0]); - printf ("%d\n", s.b[1].p[1][99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-5-ubv.c deleted file mode 100644 index 7f136253b0e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-5-ubv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", s.b[0].p[0][100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-6-lbv.c deleted file mode 100644 index 9b90cee6a14..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-lbv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -int mpx_test (int argc, const char **argv) -{ - struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - - printf ("%d\n", s.b[0].p[0][-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-6-nov.c deleted file mode 100644 index a125024ecc3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-nov.c +++ /dev/null @@ -1,28 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -int mpx_test (int argc, const char **argv) -{ - struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - - printf ("%d\n", s.b[0].p[0][0]); - printf ("%d\n", s.b[0].p[0][99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-init-6-ubv.c deleted file mode 100644 index a60c4e0befc..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-init-6-ubv.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -int mpx_test (int argc, const char **argv) -{ - struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - - printf ("%d\n", s.b[0].p[0][100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/static-string-1-lbv.c deleted file mode 100644 index e2443804f74..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -char *str="dddd"; - -int foo1 (char** ptr) -{ - *ptr=str; -} - -int foo (char *ptr) -{ - char *tmp = 0; - foo1 (&ptr); - tmp = ptr; - return tmp[-1]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo ("ddddd")); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/static-string-1-nov.c deleted file mode 100644 index d513638688f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-nov.c +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -char *str="dddd"; - -int foo1 (char** ptr) -{ - *ptr=str; -} - -int foo (char *ptr) -{ - char *tmp = 0; - foo1 (&ptr); - tmp = ptr; - return tmp[0] + tmp[4]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo ("ddddd")); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/static-string-1-ubv.c deleted file mode 100644 index e0f3634c324..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/static-string-1-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -char *str="dddd"; - -int foo1 (char** ptr) -{ - *ptr=str; -} - -int foo (char *ptr) -{ - char *tmp = 0; - foo1 (&ptr); - tmp = ptr; - return tmp[5]; -} - -int mpx_test (int argc, const char **argv) -{ - printf ("%d\n", foo ("ddddd")); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-lbv.c deleted file mode 100644 index a9e1890b18e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-lbv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-nov.c deleted file mode 100644 index b1cfeacafbb..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-nov.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (s); - - s.i1 = 50; - s.i2 = 49; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-ubv.c deleted file mode 100644 index c4ca68d682a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-1-ubv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 51; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-lbv.c deleted file mode 100644 index 8375aa1b820..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-lbv.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, int *p6, struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - - rd (buf1, buf1, buf1, buf1, buf1, buf1, s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-nov.c deleted file mode 100644 index b246448346d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-nov.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, int *p6, struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - - rd (buf1, buf1, buf1, buf1, buf1, buf1, s, 0); - rd (buf1, buf1, buf1, buf1, buf1, buf1, s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-ubv.c deleted file mode 100644 index b3b13f86672..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-10-ubv.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, int *p6, struct s1 s, int i) -{ - int res = s.p[i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - - rd (buf1, buf1, buf1, buf1, buf1, buf1, s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-lbv.c deleted file mode 100644 index d796ced340d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-lbv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-nov.c deleted file mode 100644 index 6a1a087b23f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-nov.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (s); - - s.i1 = 50; - s.i2 = 49; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-ubv.c deleted file mode 100644 index b285cbc8320..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-2-ubv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int i1; - int i2; - int *p; -} s1; - -int rd (struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 51; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-lbv.c deleted file mode 100644 index 34d4ab18581..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-nov.c deleted file mode 100644 index 8e238ef657e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (buf1, s); - - s.i1 = 50; - s.i2 = 49; - - rd (buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-ubv.c deleted file mode 100644 index bd947e5859d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-3-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 50; - - rd (buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-lbv.c deleted file mode 100644 index c0666d389a1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-nov.c deleted file mode 100644 index 17366c55ca7..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (buf1, buf1, s); - - s.i1 = 50; - s.i2 = 49; - - rd (buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-ubv.c deleted file mode 100644 index f2f8281dc36..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-4-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 50; - - rd (buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-lbv.c deleted file mode 100644 index 357bb6ac746..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-nov.c deleted file mode 100644 index a4acd38939e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (buf1, buf1, buf1, s); - - s.i1 = 50; - s.i2 = 49; - - rd (buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-ubv.c deleted file mode 100644 index c94ae1c24aa..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-5-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 50; - - rd (buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-lbv.c deleted file mode 100644 index ceee8d0c69d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-nov.c deleted file mode 100644 index 913f5a28dc2..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (buf1, buf1, buf1, buf1, s); - - s.i1 = 50; - s.i2 = 49; - - rd (buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-ubv.c deleted file mode 100644 index f92476a7854..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-6-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 50; - - rd (buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-lbv.c deleted file mode 100644 index b0ecc176cd5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -51; - - rd (buf1, buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-nov.c deleted file mode 100644 index ec63dc7ef47..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-nov.c +++ /dev/null @@ -1,39 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = -50; - - rd (buf1, buf1, buf1, buf1, buf1, s); - - s.i1 = 50; - s.i2 = 49; - - rd (buf1, buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-ubv.c deleted file mode 100644 index c9e682252c1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-7-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - int *p; - int i1; - int i2; -} s1; - -int rd (int *p1, int *p2, int *p3, int *p4, int *p5, struct s1 s) -{ - int res = s.p[s.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.p = buf; - s.i1 = 50; - s.i2 = 50; - - rd (buf1, buf1, buf1, buf1, buf1, s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-lbv.c deleted file mode 100644 index 58d03e783d8..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-lbv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[0][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-nov.c deleted file mode 100644 index d9072ec49c9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-nov.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[0][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-ubv.c deleted file mode 100644 index fdcfc9ffb39..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-8-ubv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[0][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-lbv.c deleted file mode 100644 index acce18334ad..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-lbv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[1][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-nov.c deleted file mode 100644 index 03ce6687f62..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-nov.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[1][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, 0); - rd (s, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-ubv.c deleted file mode 100644 index 449b2c5dd58..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-arg-9-ubv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 { - int *p[2]; -} s1; - -int rd (struct s1 s, int i) -{ - int res = s.p[1][i]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[100]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s = { {buf, buf1} }; - - rd (s, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-lbv.c deleted file mode 100644 index 3f1ac74d9a7..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-lbv.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char *argv[]) -{ - struct s2 ss = s; - - printf ("%d\n", ss.b[0].p[0][-1]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-nov.c deleted file mode 100644 index 5a709bc8546..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char *argv[]) -{ - struct s2 ss = s; - - printf("%d\n", ss.b[0].p[0][0]); - printf("%d\n", ss.b[0].p[0][99]); - printf("%d\n", ss.b[0].p[1][0]); - printf("%d\n", ss.b[0].p[1][199]); - printf("%d\n", ss.b[1].p[0][0]); - printf("%d\n", ss.b[1].p[0][199]); - printf("%d\n", ss.b[1].p[1][0]); - printf("%d\n", ss.b[1].p[1][99]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-ubv.c deleted file mode 100644 index b0fe8f46143..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-1-ubv.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -int buf1[100]; -int buf2[200]; - -struct s1 { - int a; - int *p[2]; -} s1; - -struct s2 { - int a; - struct s1 b[2]; -} s2; - -struct s2 s = { 1, { {1, { buf1, buf2 }}, {2, { buf2, buf1} } } }; - -int mpx_test (int argc, const char *argv[]) -{ - struct s2 ss = s; - - printf ("%d\n", ss.b[0].p[0][100]); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-lbv.c deleted file mode 100644 index 0cb6440a1d6..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-lbv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (void *p, int k) -{ - struct S *s = (struct S*)p; - int res = s->b[k]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo (&s.a, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-nov.c deleted file mode 100644 index 01f5b679faf..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-nov.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (void *p, int k) -{ - struct S *s = (struct S*)p; - int res = s->b[k]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo (&s.a, 0); - foo (&s.a, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-ubv.c deleted file mode 100644 index c500bb4b77b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/struct-copy-2-ubv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S { - int a; - int b[100]; - int c; -} S; - -int foo (void *p, int k) -{ - struct S *s = (struct S*)p; - int res = s->b[k]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S s; - - foo (&s.a, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-lbv.c deleted file mode 100644 index 3275fe03db8..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-lbv.c +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-lpthread" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "pthread.h" - -__thread int prebuf[100]; -__thread int buf[100]; -__thread int postbuf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf("%d\n", res); - return res; -} - -void *thred_func (void *ptr) -{ - rd (buf, -1); -} - -int mpx_test (int argc, const char **argv) -{ - pthread_t thread; - pthread_create (&thread, NULL, thred_func, 0); - pthread_join (thread, NULL); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-nov.c deleted file mode 100644 index 2e0483b1c29..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-nov.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-lpthread" } */ - - -#include "mpx-check.h" -#include "pthread.h" - -__thread int prebuf[100]; -__thread int buf[100]; -__thread int postbuf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf("%d\n", res); - return res; -} - -void *thred_func (void *ptr) -{ - rd (buf, 0); - rd (buf, 99); -} - -int mpx_test (int argc, const char **argv) -{ - pthread_t thread; - pthread_create (&thread, NULL, thred_func, 0); - pthread_join (thread, NULL); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-ubv.c deleted file mode 100644 index 86116e87e4d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/thread-local-var-1-ubv.c +++ /dev/null @@ -1,34 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-lpthread" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "pthread.h" - -__thread int prebuf[100]; -__thread int buf[100]; -__thread int postbuf[100]; - -int rd (int *p, int i) -{ - int res = p[i]; - printf("%d\n", res); - return res; -} - -void *thred_func (void *ptr) -{ - rd (buf, 100); -} - -int mpx_test (int argc, const char **argv) -{ - pthread_t thread; - pthread_create (&thread, NULL, thred_func, 0); - pthread_join (thread, NULL); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-lbv.c deleted file mode 100644 index c2559829bfd..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-lbv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - union { - int i1; - int i3; - } v; - int i2; - union { - int *p; - int p2; - } u; -} s1; - -int rd (struct s1 s) -{ - int res = s.u.p[s.v.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.u.p = buf; - s.v.i1 = 50; - s.i2 = -51; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-nov.c deleted file mode 100644 index f96689f479a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-nov.c +++ /dev/null @@ -1,45 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct s1 -{ - union { - int i1; - int i3; - } v; - int i2; - union { - int *p; - int p2; - } u; -} s1; - -int rd (struct s1 s) -{ - int res = s.u.p[s.v.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.u.p = buf; - s.v.i1 = 50; - s.i2 = -50; - - rd (s); - - s.v.i1 = 50; - s.i2 = 49; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-ubv.c deleted file mode 100644 index 6d65e5a73fe..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-ubv.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct s1 -{ - union { - int i1; - int i3; - } v; - int i2; - union { - int *p; - int p2; - } u; -} s1; - -int rd (struct s1 s) -{ - int res = s.u.p[s.v.i1 + s.i2]; - printf ("%d\n", res); - return res; -} - -int buf[100]; -int buf1[10]; - -int mpx_test (int argc, const char **argv) -{ - struct s1 s; - s.u.p = buf; - s.v.i1 = 50; - s.i2 = 50; - - rd (s); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c deleted file mode 100644 index bbbb256ae30..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int i; - int res; - - va_start(argp, p1); - i = va_arg(argp, int); - - res = p1[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, -11); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c deleted file mode 100644 index 4beda02b951..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int i; - int res; - - va_start(argp, p1); - i = va_arg(argp, int); - - res = p1[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, 89); - foo1 (buf, -9); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c deleted file mode 100644 index 4b763842755..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c +++ /dev/null @@ -1,42 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int i; - int res; - - va_start(argp, p1); - i = va_arg(argp, int); - - res = p1[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, 90); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c deleted file mode 100644 index dab1dc86792..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c +++ /dev/null @@ -1,45 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start(argp, p1); - p = va_arg(argp, int *); - i = va_arg(argp, int); - - res = p[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int buf1[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, buf1, -11); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c deleted file mode 100644 index 6bf4721f75a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c +++ /dev/null @@ -1,43 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start(argp, p1); - p = va_arg(argp, int *); - i = va_arg(argp, int); - - res = p[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int buf1[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, buf1, 89); - foo1 (buf, buf1, -9); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c deleted file mode 100644 index 4af59758fb0..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c +++ /dev/null @@ -1,45 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -/* { dg-additional-options "-Wno-attributes" } */ - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int -foo2 (int i1, int *p1, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start(argp, p1); - p = va_arg(argp, int *); - i = va_arg(argp, int); - - res = p[i + i1]; - printf("%d\n", res); - - return res; -} - -static __attribute__((always_inline)) int -foo1 (int *p1, ...) -{ - return foo2 (10, p1, __builtin_va_arg_pack ()); -} - -int prebuf[100]; -int buf[100]; -int buf1[100]; -int postbuf[100]; - -int mpx_test (int argc, const char **argv) -{ - foo1 (buf, buf1, 90); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-1-lbv.c deleted file mode 100644 index 89faa9281e8..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 0, buf, -1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-1-nov.c deleted file mode 100644 index e1e12a6d70b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-nov.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 0, buf, 0); - rd (buf1, 0, buf, 99); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-1-ubv.c deleted file mode 100644 index 14206a0f5a9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-1-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 0, buf, 100); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-2-lbv.c deleted file mode 100644 index 8af925f45a3..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 1, buf1, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-2-nov.c deleted file mode 100644 index 5c2f422dc3f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 1, buf1, buf, 0, buf1); - rd (buf1, 1, buf1, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-2-ubv.c deleted file mode 100644 index b4463712e2b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-2-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 1, buf1, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-3-lbv.c deleted file mode 100644 index b1f9f240622..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, buf1, buf1, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-3-nov.c deleted file mode 100644 index 93f9eb810b4..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, buf1, buf1, buf, 0, buf1); - rd (buf1, 2, buf1, buf1, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-3-ubv.c deleted file mode 100644 index dddf3563599..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-3-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, buf1, buf1, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-4-lbv.c deleted file mode 100644 index 274ccc2469e..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 3, buf1, buf1, buf1, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-4-nov.c deleted file mode 100644 index 5412d113223..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 3, buf1, buf1, buf1, buf, 0, buf1); - rd (buf1, 3, buf1, buf1, buf1, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-4-ubv.c deleted file mode 100644 index e8f06e36a3a..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-4-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 3, buf1, buf1, buf1, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-5-lbv.c deleted file mode 100644 index 1dae013f0ec..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 4, buf1, buf1, buf1, buf1, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-5-nov.c deleted file mode 100644 index bd15e0fde6f..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 4, buf1, buf1, buf1, buf1, buf, 0, buf1); - rd (buf1, 4, buf1, buf1, buf1, buf1, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-5-ubv.c deleted file mode 100644 index de3721dfdd5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-5-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int -rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 4, buf1, buf1, buf1, buf1, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-6-lbv.c deleted file mode 100644 index 822d32a7b7b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-lbv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pp, ...) -{ - va_list argp; - int *p; - int i; - int res; - int n = 4; - - va_start (argp, pp); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf1, buf1, buf1, buf1, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-6-nov.c deleted file mode 100644 index c5c4b125725..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-nov.c +++ /dev/null @@ -1,36 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pp, ...) -{ - va_list argp; - int *p; - int i; - int res; - int n = 4; - - va_start (argp, pp); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf1, buf1, buf1, buf1, buf, 0, buf1); - rd (buf1, buf1, buf1, buf1, buf1, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-6-ubv.c deleted file mode 100644 index 635a48fc16d..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-6-ubv.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pp, ...) -{ - va_list argp; - int *p; - int i; - int res; - int n = 4; - - va_start (argp, pp); - for (; n > 0; n--) - va_arg (argp, int *); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, buf1, buf1, buf1, buf1, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-7-lbv.c deleted file mode 100644 index 1121577f912..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-lbv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, double); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, 10.0d, 10.0d, buf, -1, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-7-nov.c deleted file mode 100644 index 525a93d9d87..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-nov.c +++ /dev/null @@ -1,35 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, double); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, 10.0d, 10.0d, buf, 0, buf1); - rd (buf1, 2, 10.0d, 10.0d, buf, 99, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-7-ubv.c deleted file mode 100644 index 0e8d21e9940..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-7-ubv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include "stdarg.h" - -int buf[100]; -int buf1[10]; - -int rd (int *pppp, int n, ...) -{ - va_list argp; - int *p; - int i; - int res; - - va_start (argp, n); - for (; n > 0; n--) - va_arg (argp, double); - p = va_arg (argp, int *); - i = va_arg (argp, int); - - res = p[i]; - printf ("%d\n", res); - - return res; -} - -int mpx_test (int argc, const char **argv) -{ - rd (buf1, 2, 10.0d, 10.0d, buf, 100, buf1); - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-8-lbv.c deleted file mode 100644 index bb58ac594b9..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-lbv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int buf[100]; -int buf1[10]; - -void vararg (int *p, va_list al) -{ - int i; - int res; - - p = va_arg (al, int *); - i = va_arg (al, int); - - res = p[i]; - printf ("%d\n", res); -} - -void foo (int *p, ...) -{ - va_list args; - - va_start (args, p); - vararg (p, args); - va_end (args); -} - -int mpx_test (int argc, const char **argv) -{ - foo (buf1, buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-8-nov.c deleted file mode 100644 index 59596f27166..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-nov.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" -#include <stdarg.h> - -int buf[100]; -int buf1[10]; - -void vararg (int *p, va_list al) -{ - int i; - int res; - - p = va_arg (al, int *); - i = va_arg (al, int); - - res = p[i]; - printf ("%d\n", res); -} - -void foo (int *p, ...) -{ - va_list args; - - va_start (args, p); - vararg (p, args); - va_end (args); -} - -int mpx_test (int argc, const char **argv) -{ - foo (buf1, buf, 0); - foo (buf1, buf, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vararg-8-ubv.c deleted file mode 100644 index c03bcef08ec..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vararg-8-ubv.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" -#include <stdarg.h> - -int buf[100]; -int buf1[10]; - -void vararg (int *p, va_list al) -{ - int i; - int res; - - p = va_arg (al, int *); - i = va_arg (al, int); - - res = p[i]; - printf ("%d\n", res); -} - -void foo (int *p, ...) -{ - va_list args; - - va_start (args, p); - vararg (p, args); - va_end (args); -} - -int mpx_test (int argc, const char **argv) -{ - foo (buf1, buf, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-1-lbv.c deleted file mode 100644 index 1994df9d0a1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-1-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S -{ - int a; - int p[0]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, -2); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vla-1-nov.c deleted file mode 100644 index 1a828495833..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-1-nov.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct S -{ - int a; - int p[0]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, 0); - rd (s->p, 99); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-1-ubv.c deleted file mode 100644 index b0f6d456e35..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-1-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S -{ - int a; - int p[0]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, 100); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-2-lbv.c deleted file mode 100644 index 128f13980af..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-2-lbv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct Foo { - int buf[10] __attribute__((bnd_variable_size)); -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) { - struct Foo *foo = (struct Foo *) alloca (20 * sizeof(int)); - - rd (foo->buf, -1); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vla-2-nov.c deleted file mode 100644 index 2469b7da2b1..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-2-nov.c +++ /dev/null @@ -1,25 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#include "mpx-check.h" - -struct Foo { - int buf[10] __attribute__((bnd_variable_size)); -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) { - struct Foo *foo = (struct Foo *) alloca (20 * sizeof(int)); - - rd (foo->buf, 0); - rd (foo->buf, 19); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-2-ubv.c deleted file mode 100644 index 63a6b279215..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-2-ubv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct Foo { - int buf[10] __attribute__((bnd_variable_size)); -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) { - struct Foo *foo = (struct Foo *) alloca (20 * sizeof(int)); - - rd (foo->buf, 20); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-lbv.c deleted file mode 100644 index 9739920c705..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-lbv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fchkp-flexible-struct-trailing-arrays" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S -{ - int a; - int p[10]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, -2); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-nov.c deleted file mode 100644 index f5c8f95cda5..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-nov.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fchkp-flexible-struct-trailing-arrays" } */ - - -#include "mpx-check.h" - -struct S -{ - int a; - int p[10]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, 0); - rd (s->p, 99); - s->p[0]; - s->p[99]; - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-ubv.c deleted file mode 100644 index 8385a5a631b..00000000000 --- a/gcc/testsuite/gcc.target/i386/mpx/vla-trailing-1-ubv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* { dg-do run } */ -/* { dg-shouldfail "bounds violation" } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fchkp-flexible-struct-trailing-arrays" } */ - - -#define SHOULDFAIL - -#include "mpx-check.h" - -struct S -{ - int a; - int p[10]; -}; - -int rd (int *p, int i) -{ - int res = p[i]; - printf ("%d\n", res); - return res; -} - -int mpx_test (int argc, const char **argv) -{ - struct S *s = (struct S *)alloca (sizeof(struct S) + sizeof (int)*100); - rd (s->p, 110); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/pr63995-2.c b/gcc/testsuite/gcc.target/i386/pr63995-2.c deleted file mode 100644 index 89b429e7f55..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr63995-2.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -g -fcheck-pointer-bounds -mmpx -fcompare-debug" } */ - -struct ts -{ - int field; -}; - -extern void test1 (); -extern void test2 (struct ts *); - -static void -init (struct ts *c) -{ - c->field = -1; -} - -struct ts -test3 (const struct ts *other) -{ - struct ts r; - if (other->field != 0) - test1 (); - init (&r); - test2 (&r); - return r; -} diff --git a/gcc/testsuite/gcc.target/i386/pr64805.c b/gcc/testsuite/gcc.target/i386/pr64805.c deleted file mode 100644 index 3c8d6668dfa..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr64805.c +++ /dev/null @@ -1,21 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -#include <stdio.h> - -static inline void __attribute ((always_inline)) functionA(void) -{ - return; -} - -static inline void __attribute ((always_inline)) functionB(void) -{ - functionA(); -} - -int test(void) -{ - functionB(); - - return 0; -} diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c deleted file mode 100644 index d5cfecd15a9..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr65044.c +++ /dev/null @@ -1,11 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */ -/* { dg-error ".-fcheck-pointer-bounds. is not supported with Address Sanitizer" "" { target *-*-* } 0 } */ - -extern int x[]; - -void -foo () -{ - x[0] = 0; -} diff --git a/gcc/testsuite/gcc.target/i386/pr65167.c b/gcc/testsuite/gcc.target/i386/pr65167.c deleted file mode 100644 index 64cc7aef520..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr65167.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O -fschedule-insns -fcheck-pointer-bounds -mmpx" } */ - -void bar(int *a, int *b, int *c, int *d, int *e, int *f); - -int foo (int *a, int *b, int *c, int *d, int *e, int *f) -{ - bar (a, b, c, d, e, f); - return *f; -} diff --git a/gcc/testsuite/gcc.target/i386/pr65183.c b/gcc/testsuite/gcc.target/i386/pr65183.c deleted file mode 100644 index 4d62267fc0d..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr65183.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O -fcheck-pointer-bounds -fchkp-use-nochk-string-functions -mmpx" } */ - -extern void bar(void *); -extern void baz(void); - -static int lc[32]; - -void foobar(void *c) -{ - bar(&c); - __builtin_memcpy (lc, c, lc[0]); -} - -void foo () -{ - baz (); - foobar(0); -} diff --git a/gcc/testsuite/gcc.target/i386/pr65184.c b/gcc/testsuite/gcc.target/i386/pr65184.c deleted file mode 100644 index e12b8a922f1..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr65184.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mabi=ms -fcheck-pointer-bounds -mmpx" } */ - -void -foo (int *a) -{ - if (a[0] != a[1] * 2333) - __builtin_abort (); -} - -void -bar (int *a) -{ - if (a[0] != a[1] * 2333) - __builtin_abort (); -} diff --git a/gcc/testsuite/gcc.target/i386/pr65523.c b/gcc/testsuite/gcc.target/i386/pr65523.c deleted file mode 100644 index 20e715237fc..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr65523.c +++ /dev/null @@ -1,11 +0,0 @@ -/* PR target/65523 */ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -void *memmove (); - -void * -bar () -{ - return memmove (); -} diff --git a/gcc/testsuite/gcc.target/i386/pr70876.c b/gcc/testsuite/gcc.target/i386/pr70876.c deleted file mode 100644 index c9bab690b33..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr70876.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -Wno-implicit-function-declaration" } */ - -void f (char *s1, char *s2) -{ - int z = 5; - - struct { char a[z]; } x; - - s1[0] = s2[0]; - - foo (x, x); -} diff --git a/gcc/testsuite/gcc.target/i386/pr70877.c b/gcc/testsuite/gcc.target/i386/pr70877.c deleted file mode 100644 index 4269e84daff..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr70877.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ - -int foo(int); - -typedef struct { - double d; - int a; -} str_t; - -void bar(double d, int i, str_t s) -{ - d = ((double (*) (int)) foo) (i); /* { dg-warning "function called through a non-compatible type" } */ -} diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c deleted file mode 100644 index d36b61cbe02..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr71458.c +++ /dev/null @@ -1,7 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */ -/* { dg-error "'-fcheck-pointer-bounds' is not supported with '-fsanitize=bounds'" "" { target *-*-* } 0 } */ - -enum {} a[0]; -void fn1(int); -void fn2() { fn1(a[-1]); } diff --git a/gcc/testsuite/gcc.target/i386/pr80880.c b/gcc/testsuite/gcc.target/i386/pr80880.c deleted file mode 100644 index 674a587dd26..00000000000 --- a/gcc/testsuite/gcc.target/i386/pr80880.c +++ /dev/null @@ -1,10 +0,0 @@ -/* PR target/65523 */ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O -fcheck-pointer-bounds -mmpx" } */ - -int *fn1() -{ - int *r = fn1(); - if (r == (void *)0) - return r; -} diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c deleted file mode 100644 index f73553c9a9f..00000000000 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c +++ /dev/null @@ -1,15 +0,0 @@ -/* PR target/r84530 */ -/* { dg-do compile { target ia32 } } */ -/* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ - -struct s { _Complex unsigned short x; }; -struct s gs = { 100 + 200i }; -struct s __attribute__((noinline)) foo (void) { return gs; } - -/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_bnd_ecx" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler {\tpause} } } */ -/* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/thunk-retbnd.c b/gcc/testsuite/gcc.target/i386/thunk-retbnd.c deleted file mode 100644 index dcce6baf104..00000000000 --- a/gcc/testsuite/gcc.target/i386/thunk-retbnd.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -fdump-tree-optimized" } */ -/* { dg-final { scan-tree-dump-times "return &glob," 2 "optimized" } } */ - -int glob; - -int * -test1 (void) -{ - return &glob; -} - -int * -test2 (void) -{ - return test1 (); -} diff --git a/gcc/testsuite/lib/mpx-dg.exp b/gcc/testsuite/lib/mpx-dg.exp deleted file mode 100644 index 2fda79540cf..00000000000 --- a/gcc/testsuite/lib/mpx-dg.exp +++ /dev/null @@ -1,146 +0,0 @@ -# Copyright (C) 2014-2018 Free Software Foundation, Inc. - -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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/>. - -# Return 1 if compilation with "-fcheck-pointer-bounds -mmpx" is -# error-free for trivial code, 0 otherwise. - -proc check_effective_target_mpx {} { - return [check_no_compiler_messages mpx executable { - int *foo (int *arg) { return arg; } - int main (void) - { - int *p = (int *)__builtin_malloc (sizeof (int)); - int res = foo (p) == 0; - __builtin_free (p); - return res; - } - } "-fcheck-pointer-bounds -mmpx"] -} - -# -# mpx_link_flags -- compute library path and flags to find libmpx. -# - -proc mpx_link_flags { paths } { - global srcdir - global ld_library_path - global shlib_ext - global mpx_saved_library_path - - set gccpath ${paths} - set flags "" - - set shlib_ext [get_shlib_extension] - set mpx_saved_library_path $ld_library_path - - if { $gccpath != "" } { - if { [file exists "${gccpath}/libmpx/mpxrt/.libs/libmpx.a"] - || [file exists "${gccpath}/libmpx/mpxrt/.libs/libmpx.${shlib_ext}"] } { - append flags " -B${gccpath}/libmpx/ " - append flags " -B${gccpath}/libmpx/mpxrt " - append flags " -L${gccpath}/libmpx/mpxrt/.libs " - append ld_library_path ":${gccpath}/libmpx/mpxrt/.libs" - } - - if { [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.a"] - || [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.${shlib_ext}"] } { - append flags " -B${gccpath}/libmpx/ " - append flags " -B${gccpath}/libmpx/mpxwrap " - append flags " -L${gccpath}/libmpx/mpxwrap/.libs " - append ld_library_path ":${gccpath}/libmpx/mpxwrap/.libs" - } - } else { - global tool_root_dir - - set libmpx [lookfor_file ${tool_root_dir} libmpx] - if { $libmpx != "" } { - append flags "-L${libmpx} " - append ld_library_path ":${libmpx}" - } - - set libmpxwrappers [lookfor_file ${tool_root_dir} libmpxwrappers] - if { $libmpxwrappers != "" } { - append flags "-L${libmpxwrappers} " - append ld_library_path ":${libmpxwrappers}" - } - } - - set_ld_library_path_env_vars - - return "$flags" -} - -# -# mpx_init -- called at the start of each subdir of tests -# - -proc mpx_init { args } { - global TEST_ALWAYS_FLAGS - global ALWAYS_CXXFLAGS - global TOOL_OPTIONS - global mpx_saved_TEST_ALWAYS_FLAGS - global mpx_saved_ALWAYS_CXXFLAGS - - setenv CHKP_RT_MODE "stop" - - set link_flags "" - if ![is_remote host] { - if [info exists TOOL_OPTIONS] { - set link_flags "[mpx_link_flags [get_multilibs ${TOOL_OPTIONS}]]" - } else { - set link_flags "[mpx_link_flags [get_multilibs]]" - } - } - - if [info exists TEST_ALWAYS_FLAGS] { - set mpx_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS - } - if [info exists ALWAYS_CXXFLAGS] { - set mpx_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS - set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] - } else { - if [info exists TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS "$link_flags $TEST_ALWAYS_FLAGS" - } else { - set TEST_ALWAYS_FLAGS "$link_flags" - } - } -} - -# -# mpx_finish -- called at the end of each subdir of tests -# - -proc mpx_finish { args } { - global TEST_ALWAYS_FLAGS - global mpx_saved_TEST_ALWAYS_FLAGS - global mpx_saved_ALWAYS_CXXFLAGS - global mpx_saved_library_path - global ld_library_path - - if [info exists mpx_saved_ALWAYS_CXXFLAGS ] { - set ALWAYS_CXXFLAGS $mpx_saved_ALWAYS_CXXFLAGS - } else { - if [info exists mpx_saved_TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS $mpx_saved_TEST_ALWAYS_FLAGS - } else { - unset TEST_ALWAYS_FLAGS - } - } - set ld_library_path $mpx_saved_library_path - set_ld_library_path_env_vars - clear_effective_target_cache -} diff --git a/gcc/toplev.c b/gcc/toplev.c index 8f812c2a475..d1080968833 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -77,7 +77,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-vrp.h" #include "ipa-prop.h" #include "gcse.h" -#include "tree-chkp.h" #include "omp-offload.h" #include "hsa-common.h" #include "edit-context.h" @@ -505,9 +504,6 @@ compile_file (void) if (flag_sanitize & SANITIZE_THREAD) tsan_finish_file (); - if (flag_check_pointer_bounds) - chkp_finish_file (); - omp_finish_file (); hsa_output_brig (); @@ -1315,49 +1311,6 @@ process_options (void) } } - if (flag_check_pointer_bounds) - { - if (targetm.chkp_bound_mode () == VOIDmode) - { - error_at (UNKNOWN_LOCATION, - "%<-fcheck-pointer-bounds%> is not supported for this " - "target"); - flag_check_pointer_bounds = 0; - } - - if (flag_sanitize & SANITIZE_BOUNDS_STRICT) - { - error_at (UNKNOWN_LOCATION, - "%<-fcheck-pointer-bounds%> is not supported with " - "%<-fsanitize=bounds-strict%>"); - flag_check_pointer_bounds = 0; - } - else if (flag_sanitize & SANITIZE_BOUNDS) - { - error_at (UNKNOWN_LOCATION, - "%<-fcheck-pointer-bounds%> is not supported with " - "%<-fsanitize=bounds%>"); - flag_check_pointer_bounds = 0; - } - - if (flag_sanitize & SANITIZE_ADDRESS) - { - error_at (UNKNOWN_LOCATION, - "%<-fcheck-pointer-bounds%> is not supported with " - "Address Sanitizer"); - flag_check_pointer_bounds = 0; - } - - if (flag_sanitize & SANITIZE_THREAD) - { - error_at (UNKNOWN_LOCATION, - "%<-fcheck-pointer-bounds%> is not supported with " - "Thread Sanitizer"); - - flag_check_pointer_bounds = 0; - } - } - /* One region RA really helps to decrease the code size. */ if (flag_ira_region == IRA_REGION_AUTODETECT) flag_ira_region diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c deleted file mode 100644 index 5a005a6a7b6..00000000000 --- a/gcc/tree-chkp-opt.c +++ /dev/null @@ -1,1355 +0,0 @@ -/* Pointer Bounds Checker optimization pass. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - Contributed by Ilya Enkovich (ilya.enkovich@intel.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/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "backend.h" -#include "target.h" -#include "rtl.h" -#include "tree.h" -#include "gimple.h" -#include "tree-pass.h" -#include "ssa.h" -#include "gimple-pretty-print.h" -#include "diagnostic.h" -#include "fold-const.h" -#include "tree-cfg.h" -#include "tree-ssa-loop-niter.h" -#include "gimple-iterator.h" -#include "tree-chkp.h" -#include "ipa-chkp.h" - -enum check_type -{ - CHECK_LOWER_BOUND, - CHECK_UPPER_BOUND -}; - -struct pol_item -{ - tree cst; - tree var; -}; - -struct address_t -{ - vec<struct pol_item> pol; -}; - -/* Structure to hold check informtation. */ -struct check_info -{ - /* Type of the check. */ - check_type type; - /* Address used for the check. */ - address_t addr; - /* Bounds used for the check. */ - tree bounds; - /* Check statement. Can be NULL for removed checks. */ - gimple *stmt; -}; - -/* Structure to hold checks information for BB. */ -struct bb_checks -{ - vec<struct check_info, va_heap, vl_ptr> checks; -}; - -static void chkp_collect_value (tree ssa_name, address_t &res); - -#define chkp_bndmk_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDMK)) -#define chkp_intersect_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_INTERSECT)) -#define chkp_checkl_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDCL)) -#define chkp_checku_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDCU)) - -static vec<struct bb_checks, va_heap, vl_ptr> check_infos; - -/* Comparator for pol_item structures I1 and I2 to be used - to find items with equal var. Also used for polynomial - sorting. */ -static int -chkp_pol_item_compare (const void *i1, const void *i2) -{ - const struct pol_item *p1 = (const struct pol_item *)i1; - const struct pol_item *p2 = (const struct pol_item *)i2; - - if (p1->var == p2->var) - return 0; - else if (p1->var > p2->var) - return 1; - else - return -1; -} - -/* Find polynomial item in ADDR with var equal to VAR - and return its index. Return -1 if item was not - found. */ -static int -chkp_pol_find (address_t &addr, tree var) -{ - int left = 0; - int right = addr.pol.length () - 1; - int n; - - while (right >= left) - { - n = (left + right) / 2; - - if (addr.pol[n].var == var - || (var && addr.pol[n].var - && TREE_CODE (var) == ADDR_EXPR - && TREE_CODE (addr.pol[n].var) == ADDR_EXPR - && TREE_OPERAND (var, 0) == TREE_OPERAND (addr.pol[n].var, 0))) - return n; - else if (addr.pol[n].var > var) - right = n - 1; - else - left = n + 1; - } - - return -1; -} - -/* Return constant CST extended to size type. */ -static tree -chkp_extend_const (tree cst) -{ - if (TYPE_PRECISION (TREE_TYPE (cst)) < TYPE_PRECISION (size_type_node)) - return build_int_cst_type (size_type_node, tree_to_shwi (cst)); - - return cst; -} - -/* Add polynomial item CST * VAR to ADDR. */ -static void -chkp_add_addr_item (address_t &addr, tree cst, tree var) -{ - int n = chkp_pol_find (addr, var); - - cst = chkp_extend_const (cst); - - if (n < 0) - { - struct pol_item item; - item.cst = cst; - item.var = var; - - addr.pol.safe_push (item); - addr.pol.qsort (&chkp_pol_item_compare); - } - else - { - addr.pol[n].cst = fold_build2 (PLUS_EXPR, TREE_TYPE (addr.pol[n].cst), - addr.pol[n].cst, cst); - if (TREE_CODE (addr.pol[n].cst) == INTEGER_CST - && integer_zerop (addr.pol[n].cst)) - addr.pol.ordered_remove (n); - } -} - -/* Subtract polynomial item CST * VAR from ADDR. */ -static void -chkp_sub_addr_item (address_t &addr, tree cst, tree var) -{ - int n = chkp_pol_find (addr, var); - - cst = chkp_extend_const (cst); - - if (n < 0) - { - struct pol_item item; - item.cst = fold_build2 (MINUS_EXPR, TREE_TYPE (cst), - integer_zero_node, cst); - item.var = var; - - addr.pol.safe_push (item); - addr.pol.qsort (&chkp_pol_item_compare); - } - else - { - addr.pol[n].cst = fold_build2 (MINUS_EXPR, TREE_TYPE (addr.pol[n].cst), - addr.pol[n].cst, cst); - if (TREE_CODE (addr.pol[n].cst) == INTEGER_CST - && integer_zerop (addr.pol[n].cst)) - addr.pol.ordered_remove (n); - } -} - -/* Add address DELTA to ADDR. */ -static void -chkp_add_addr_addr (address_t &addr, address_t &delta) -{ - unsigned int i; - for (i = 0; i < delta.pol.length (); i++) - chkp_add_addr_item (addr, delta.pol[i].cst, delta.pol[i].var); -} - -/* Subtract address DELTA from ADDR. */ -static void -chkp_sub_addr_addr (address_t &addr, address_t &delta) -{ - unsigned int i; - for (i = 0; i < delta.pol.length (); i++) - chkp_sub_addr_item (addr, delta.pol[i].cst, delta.pol[i].var); -} - -/* Mutiply address ADDR by integer constant MULT. */ -static void -chkp_mult_addr (address_t &addr, tree mult) -{ - unsigned int i; - for (i = 0; i < addr.pol.length (); i++) - addr.pol[i].cst = fold_build2 (MULT_EXPR, TREE_TYPE (addr.pol[i].cst), - addr.pol[i].cst, mult); -} - -/* Return 1 if we may prove ADDR has a constant value with - determined sign, which is put into *SIGN. Otherwise - return 0. */ -static bool -chkp_is_constant_addr (const address_t &addr, int *sign) -{ - *sign = 0; - - if (addr.pol.length () == 0) - return true; - else if (addr.pol.length () > 1) - return false; - else if (addr.pol[0].var) - return false; - else if (TREE_CODE (addr.pol[0].cst) != INTEGER_CST) - return false; - else if (integer_zerop (addr.pol[0].cst)) - *sign = 0; - else if (tree_int_cst_sign_bit (addr.pol[0].cst)) - *sign = -1; - else - *sign = 1; - - return true; -} - -/* Dump ADDR into dump_file. */ -static void -chkp_print_addr (const address_t &addr) -{ - unsigned int n = 0; - for (n = 0; n < addr.pol.length (); n++) - { - if (n > 0) - fprintf (dump_file, " + "); - - if (addr.pol[n].var == NULL_TREE) - print_generic_expr (dump_file, addr.pol[n].cst); - else - { - if (TREE_CODE (addr.pol[n].cst) != INTEGER_CST - || !integer_onep (addr.pol[n].cst)) - { - print_generic_expr (dump_file, addr.pol[n].cst); - fprintf (dump_file, " * "); - } - print_generic_expr (dump_file, addr.pol[n].var); - } - } -} - -/* Compute value of PTR and put it into address RES. - PTR has to be ADDR_EXPR. */ -static void -chkp_collect_addr_value (tree ptr, address_t &res) -{ - tree obj = TREE_OPERAND (ptr, 0); - address_t addr; - - switch (TREE_CODE (obj)) - { - case INDIRECT_REF: - chkp_collect_value (TREE_OPERAND (obj, 0), res); - break; - - case MEM_REF: - chkp_collect_value (TREE_OPERAND (obj, 0), res); - addr.pol.create (0); - chkp_collect_value (TREE_OPERAND (obj, 1), addr); - chkp_add_addr_addr (res, addr); - addr.pol.release (); - break; - - case ARRAY_REF: - chkp_collect_value (build_fold_addr_expr (TREE_OPERAND (obj, 0)), res); - addr.pol.create (0); - chkp_collect_value (TREE_OPERAND (obj, 1), addr); - chkp_mult_addr (addr, array_ref_element_size (obj)); - chkp_add_addr_addr (res, addr); - addr.pol.release (); - break; - - case COMPONENT_REF: - { - tree str = TREE_OPERAND (obj, 0); - tree field = TREE_OPERAND (obj, 1); - chkp_collect_value (build_fold_addr_expr (str), res); - addr.pol.create (0); - chkp_collect_value (component_ref_field_offset (obj), addr); - chkp_add_addr_addr (res, addr); - addr.pol.release (); - if (DECL_FIELD_BIT_OFFSET (field)) - { - addr.pol.create (0); - chkp_collect_value (fold_build2 (TRUNC_DIV_EXPR, size_type_node, - DECL_FIELD_BIT_OFFSET (field), - size_int (BITS_PER_UNIT)), - addr); - chkp_add_addr_addr (res, addr); - addr.pol.release (); - } - } - break; - - default: - chkp_add_addr_item (res, integer_one_node, ptr); - break; - } -} - -/* Compute value of PTR and put it into address RES. */ -static void -chkp_collect_value (tree ptr, address_t &res) -{ - gimple *def_stmt; - enum gimple_code code; - enum tree_code rhs_code; - address_t addr; - tree rhs1; - - if (TREE_CODE (ptr) == INTEGER_CST) - { - chkp_add_addr_item (res, ptr, NULL); - return; - } - else if (TREE_CODE (ptr) == ADDR_EXPR) - { - chkp_collect_addr_value (ptr, res); - return; - } - else if (TREE_CODE (ptr) != SSA_NAME) - { - chkp_add_addr_item (res, integer_one_node, ptr); - return; - } - - /* Now we handle the case when polynomial is computed - for SSA NAME. */ - def_stmt = SSA_NAME_DEF_STMT (ptr); - code = gimple_code (def_stmt); - - /* Currently we do not walk through statements other - than assignment. */ - if (code != GIMPLE_ASSIGN) - { - chkp_add_addr_item (res, integer_one_node, ptr); - return; - } - - rhs_code = gimple_assign_rhs_code (def_stmt); - rhs1 = gimple_assign_rhs1 (def_stmt); - - switch (rhs_code) - { - case SSA_NAME: - case INTEGER_CST: - case ADDR_EXPR: - chkp_collect_value (rhs1, res); - break; - - case PLUS_EXPR: - case POINTER_PLUS_EXPR: - chkp_collect_value (rhs1, res); - addr.pol.create (0); - chkp_collect_value (gimple_assign_rhs2 (def_stmt), addr); - chkp_add_addr_addr (res, addr); - addr.pol.release (); - break; - - case MINUS_EXPR: - chkp_collect_value (rhs1, res); - addr.pol.create (0); - chkp_collect_value (gimple_assign_rhs2 (def_stmt), addr); - chkp_sub_addr_addr (res, addr); - addr.pol.release (); - break; - - case MULT_EXPR: - if (TREE_CODE (rhs1) == SSA_NAME - && TREE_CODE (gimple_assign_rhs2 (def_stmt)) == INTEGER_CST) - { - chkp_collect_value (rhs1, res); - chkp_mult_addr (res, gimple_assign_rhs2 (def_stmt)); - } - else if (TREE_CODE (gimple_assign_rhs2 (def_stmt)) == SSA_NAME - && TREE_CODE (rhs1) == INTEGER_CST) - { - chkp_collect_value (gimple_assign_rhs2 (def_stmt), res); - chkp_mult_addr (res, rhs1); - } - else - chkp_add_addr_item (res, integer_one_node, ptr); - break; - - default: - chkp_add_addr_item (res, integer_one_node, ptr); - break; - } -} - -/* Fill check_info structure *CI with information about - check STMT. */ -static void -chkp_fill_check_info (gimple *stmt, struct check_info *ci) -{ - ci->addr.pol.create (0); - ci->bounds = gimple_call_arg (stmt, 1); - chkp_collect_value (gimple_call_arg (stmt, 0), ci->addr); - ci->type = (gimple_call_fndecl (stmt) == chkp_checkl_fndecl - ? CHECK_LOWER_BOUND - : CHECK_UPPER_BOUND); - ci->stmt = stmt; -} - -/* Release structures holding check information - for current function. */ -static void -chkp_release_check_info (void) -{ - unsigned int n, m; - - if (check_infos.exists ()) - { - for (n = 0; n < check_infos.length (); n++) - { - for (m = 0; m < check_infos[n].checks.length (); m++) - if (check_infos[n].checks[m].addr.pol.exists ()) - check_infos[n].checks[m].addr.pol.release (); - check_infos[n].checks.release (); - } - check_infos.release (); - } -} - -/* Create structures to hold check information - for current function. */ -static void -chkp_init_check_info (void) -{ - struct bb_checks empty_bbc; - int n; - - empty_bbc.checks = vNULL; - - chkp_release_check_info (); - - check_infos.create (last_basic_block_for_fn (cfun)); - for (n = 0; n < last_basic_block_for_fn (cfun); n++) - { - check_infos.safe_push (empty_bbc); - check_infos.last ().checks.create (0); - } -} - -/* Find all checks in current function and store info about them - in check_infos. */ -static void -chkp_gather_checks_info (void) -{ - basic_block bb; - gimple_stmt_iterator i; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Gathering information about checks...\n"); - - chkp_init_check_info (); - - FOR_EACH_BB_FN (bb, cfun) - { - struct bb_checks *bbc = &check_infos[bb->index]; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Searching checks in BB%d...\n", bb->index); - - for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) - { - gimple *stmt = gsi_stmt (i); - - if (gimple_code (stmt) != GIMPLE_CALL) - continue; - - if (gimple_call_fndecl (stmt) == chkp_checkl_fndecl - || gimple_call_fndecl (stmt) == chkp_checku_fndecl) - { - struct check_info ci; - - chkp_fill_check_info (stmt, &ci); - bbc->checks.safe_push (ci); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Adding check information:\n"); - fprintf (dump_file, " bounds: "); - print_generic_expr (dump_file, ci.bounds); - fprintf (dump_file, "\n address: "); - chkp_print_addr (ci.addr); - fprintf (dump_file, "\n check: "); - print_gimple_stmt (dump_file, stmt, 0); - } - } - } - } -} - -/* Return 1 if check CI against BOUNDS always pass, - -1 if check CI against BOUNDS always fails and - 0 if we cannot compute check result. */ -static int -chkp_get_check_result (struct check_info *ci, tree bounds) -{ - gimple *bnd_def; - address_t bound_val; - int sign, res = 0; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Trying to compute result of the check\n"); - fprintf (dump_file, " check: "); - print_gimple_stmt (dump_file, ci->stmt, 0); - fprintf (dump_file, " address: "); - chkp_print_addr (ci->addr); - fprintf (dump_file, "\n bounds: "); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, "\n"); - } - - if (TREE_CODE (bounds) != SSA_NAME) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: bounds tree code is not ssa_name\n"); - return 0; - } - - bnd_def = SSA_NAME_DEF_STMT (bounds); - /* Currently we handle cases when bounds are result of bndmk - or loaded static bounds var. */ - if (gimple_code (bnd_def) == GIMPLE_CALL - && gimple_call_fndecl (bnd_def) == chkp_bndmk_fndecl) - { - bound_val.pol.create (0); - chkp_collect_value (gimple_call_arg (bnd_def, 0), bound_val); - if (ci->type == CHECK_UPPER_BOUND) - { - address_t size_val; - size_val.pol.create (0); - chkp_collect_value (gimple_call_arg (bnd_def, 1), size_val); - chkp_add_addr_addr (bound_val, size_val); - size_val.pol.release (); - chkp_add_addr_item (bound_val, integer_minus_one_node, NULL); - } - } - else if (gimple_code (bnd_def) == GIMPLE_ASSIGN - && gimple_assign_rhs1 (bnd_def) == chkp_get_zero_bounds_var ()) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: always pass with zero bounds\n"); - return 1; - } - else if (gimple_code (bnd_def) == GIMPLE_ASSIGN - && gimple_assign_rhs1 (bnd_def) == chkp_get_none_bounds_var ()) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: always fails with none bounds\n"); - return -1; - } - else if (gimple_code (bnd_def) == GIMPLE_ASSIGN - && TREE_CODE (gimple_assign_rhs1 (bnd_def)) == VAR_DECL) - { - tree bnd_var = gimple_assign_rhs1 (bnd_def); - tree var; - tree size; - - if (!DECL_INITIAL (bnd_var) - || DECL_INITIAL (bnd_var) == error_mark_node) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: cannot compute bounds\n"); - return 0; - } - - gcc_assert (TREE_CODE (DECL_INITIAL (bnd_var)) == ADDR_EXPR); - var = TREE_OPERAND (DECL_INITIAL (bnd_var), 0); - - bound_val.pol.create (0); - chkp_collect_value (DECL_INITIAL (bnd_var), bound_val); - if (ci->type == CHECK_UPPER_BOUND) - { - if (VAR_P (var)) - { - if (DECL_SIZE (var) - && !chkp_variable_size_type (TREE_TYPE (var))) - size = DECL_SIZE_UNIT (var); - else - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: cannot compute bounds\n"); - return 0; - } - } - else - { - gcc_assert (TREE_CODE (var) == STRING_CST); - size = build_int_cst (size_type_node, - TREE_STRING_LENGTH (var)); - } - - address_t size_val; - size_val.pol.create (0); - chkp_collect_value (size, size_val); - chkp_add_addr_addr (bound_val, size_val); - size_val.pol.release (); - chkp_add_addr_item (bound_val, integer_minus_one_node, NULL); - } - } - else - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: cannot compute bounds\n"); - return 0; - } - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, " bound value: "); - chkp_print_addr (bound_val); - fprintf (dump_file, "\n"); - } - - chkp_sub_addr_addr (bound_val, ci->addr); - - if (!chkp_is_constant_addr (bound_val, &sign)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: cannot compute result\n"); - - res = 0; - } - else if (sign == 0 - || (ci->type == CHECK_UPPER_BOUND && sign > 0) - || (ci->type == CHECK_LOWER_BOUND && sign < 0)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: always pass\n"); - - res = 1; - } - else - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " result: always fail\n"); - - res = -1; - } - - bound_val.pol.release (); - - return res; -} - -/* Try to compare bounds value and address value - used in the check CI. If we can prove that check - always pass then remove it. */ -static void -chkp_remove_check_if_pass (struct check_info *ci) -{ - int result = 0; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Trying to remove check: "); - print_gimple_stmt (dump_file, ci->stmt, 0); - } - - result = chkp_get_check_result (ci, ci->bounds); - - if (result == 1) - { - gimple_stmt_iterator i = gsi_for_stmt (ci->stmt); - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " action: delete check (always pass)\n"); - - gsi_remove (&i, true); - unlink_stmt_vdef (ci->stmt); - release_defs (ci->stmt); - ci->stmt = NULL; - } - else if (result == -1) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " action: keep check (always fail)\n"); - warning_at (gimple_location (ci->stmt), OPT_Wchkp, - "memory access check always fail"); - } - else if (result == 0) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " action: keep check (cannot compute result)\n"); - } -} - -/* For bounds used in CI check if bounds are produced by - intersection and we may use outer bounds instead. If - transformation is possible then fix check statement and - recompute its info. */ -static void -chkp_use_outer_bounds_if_possible (struct check_info *ci) -{ - gimple *bnd_def; - tree bnd1, bnd2, bnd_res = NULL; - int check_res1, check_res2; - - if (TREE_CODE (ci->bounds) != SSA_NAME) - return; - - bnd_def = SSA_NAME_DEF_STMT (ci->bounds); - if (gimple_code (bnd_def) != GIMPLE_CALL - || gimple_call_fndecl (bnd_def) != chkp_intersect_fndecl) - return; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Check if bounds intersection is redundant: \n"); - fprintf (dump_file, " check: "); - print_gimple_stmt (dump_file, ci->stmt, 0); - fprintf (dump_file, " intersection: "); - print_gimple_stmt (dump_file, bnd_def, 0); - fprintf (dump_file, "\n"); - } - - bnd1 = gimple_call_arg (bnd_def, 0); - bnd2 = gimple_call_arg (bnd_def, 1); - - check_res1 = chkp_get_check_result (ci, bnd1); - check_res2 = chkp_get_check_result (ci, bnd2); - if (check_res1 == 1) - bnd_res = bnd2; - else if (check_res1 == -1) - bnd_res = bnd1; - else if (check_res2 == 1) - bnd_res = bnd1; - else if (check_res2 == -1) - bnd_res = bnd2; - - if (bnd_res) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, " action: use "); - print_generic_expr (dump_file, bnd2); - fprintf (dump_file, " instead of "); - print_generic_expr (dump_file, ci->bounds); - fprintf (dump_file, "\n"); - } - - ci->bounds = bnd_res; - gimple_call_set_arg (ci->stmt, 1, bnd_res); - update_stmt (ci->stmt); - chkp_fill_check_info (ci->stmt, ci); - } -} - -/* Try to find checks whose bounds were produced by intersection - which does not affect check result. In such check outer bounds - are used instead. It allows to remove excess intersections - and helps to compare checks. */ -static void -chkp_remove_excess_intersections (void) -{ - basic_block bb; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Searching for redundant bounds intersections...\n"); - - FOR_EACH_BB_FN (bb, cfun) - { - struct bb_checks *bbc = &check_infos[bb->index]; - unsigned int no; - - /* Iterate through all found checks in BB. */ - for (no = 0; no < bbc->checks.length (); no++) - if (bbc->checks[no].stmt) - chkp_use_outer_bounds_if_possible (&bbc->checks[no]); - } -} - -/* Try to remove all checks which are known to alwyas pass. */ -static void -chkp_remove_constant_checks (void) -{ - basic_block bb; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Searching for redundant checks...\n"); - - FOR_EACH_BB_FN (bb, cfun) - { - struct bb_checks *bbc = &check_infos[bb->index]; - unsigned int no; - - /* Iterate through all found checks in BB. */ - for (no = 0; no < bbc->checks.length (); no++) - if (bbc->checks[no].stmt) - chkp_remove_check_if_pass (&bbc->checks[no]); - } -} - -/* Return fast version of string function FNCODE. */ -static tree -chkp_get_nobnd_fndecl (enum built_in_function fncode) -{ - /* Check if we are allowed to use fast string functions. */ - if (!flag_chkp_use_fast_string_functions) - return NULL_TREE; - - tree fndecl = NULL_TREE; - - switch (fncode) - { - case BUILT_IN_MEMCPY_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOBND); - break; - - case BUILT_IN_MEMPCPY_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOBND); - break; - - case BUILT_IN_MEMMOVE_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOBND); - break; - - case BUILT_IN_MEMSET_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOBND); - break; - - case BUILT_IN_CHKP_MEMCPY_NOCHK_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMPCPY_NOCHK_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMMOVE_NOCHK_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMSET_NOCHK_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOBND_NOCHK); - break; - - default: - break; - } - - if (fndecl) - fndecl = chkp_maybe_clone_builtin_fndecl (fndecl); - - return fndecl; -} - - -/* Return no-check version of string function FNCODE. */ -static tree -chkp_get_nochk_fndecl (enum built_in_function fncode) -{ - /* Check if we are allowed to use fast string functions. */ - if (!flag_chkp_use_nochk_string_functions) - return NULL_TREE; - - tree fndecl = NULL_TREE; - - switch (fncode) - { - case BUILT_IN_MEMCPY_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOCHK); - break; - - case BUILT_IN_MEMPCPY_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOCHK); - break; - - case BUILT_IN_MEMMOVE_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOCHK); - break; - - case BUILT_IN_MEMSET_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOCHK); - break; - - case BUILT_IN_CHKP_MEMCPY_NOBND_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMPCPY_NOBND_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMMOVE_NOBND_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMMOVE_NOBND_NOCHK); - break; - - case BUILT_IN_CHKP_MEMSET_NOBND_CHKP: - fndecl = builtin_decl_implicit (BUILT_IN_CHKP_MEMSET_NOBND_NOCHK); - break; - - default: - break; - } - - if (fndecl) - fndecl = chkp_maybe_clone_builtin_fndecl (fndecl); - - return fndecl; -} - -/* Find memcpy, mempcpy, memmove and memset calls, perform - checks before call and then call no_chk version of - functions. We do it on O2 to enable inlining of these - functions during expand. - - Also try to find memcpy, mempcpy, memmove and memset calls - which are known to not write pointers to memory and use - faster function versions for them. */ -static void -chkp_optimize_string_function_calls (void) -{ - basic_block bb; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Searching for replaceable string function calls...\n"); - - FOR_EACH_BB_FN (bb, cfun) - { - gimple_stmt_iterator i; - - for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) - { - gimple *stmt = gsi_stmt (i); - tree fndecl; - - if (!is_gimple_call (stmt) - || !gimple_call_with_bounds_p (stmt) - || !gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) - continue; - - fndecl = gimple_call_fndecl (stmt); - if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMCPY_CHKP - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMPCPY_CHKP - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMMOVE_CHKP - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMSET_CHKP) - { - tree dst = gimple_call_arg (stmt, 0); - tree dst_bnd = gimple_call_arg (stmt, 1); - bool is_memset = DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MEMSET_CHKP; - tree size = gimple_call_arg (stmt, is_memset ? 3 : 4); - tree fndecl_nochk; - gimple_stmt_iterator j; - basic_block check_bb; - address_t size_val; - int sign; - bool known; - - /* We may replace call with corresponding __chkp_*_nobnd - call in case destination pointer base type is not - void or pointer. */ - if (POINTER_TYPE_P (TREE_TYPE (dst)) - && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (dst))) - && !chkp_type_has_pointer (TREE_TYPE (TREE_TYPE (dst)))) - { - tree fndecl_nobnd - = chkp_get_nobnd_fndecl (DECL_FUNCTION_CODE (fndecl)); - - if (fndecl_nobnd) - fndecl = fndecl_nobnd; - } - - fndecl_nochk = chkp_get_nochk_fndecl (DECL_FUNCTION_CODE (fndecl)); - - if (fndecl_nochk) - fndecl = fndecl_nochk; - - if (fndecl != gimple_call_fndecl (stmt)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Replacing call: "); - print_gimple_stmt (dump_file, stmt, 0, - TDF_VOPS|TDF_MEMSYMS); - } - - gimple_call_set_fndecl (stmt, fndecl); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "With a new call: "); - print_gimple_stmt (dump_file, stmt, 0, - TDF_VOPS|TDF_MEMSYMS); - } - } - - /* If there is no nochk version of function then - do nothing. Otherwise insert checks before - the call. */ - if (!fndecl_nochk) - continue; - - /* If size passed to call is known and > 0 - then we may insert checks unconditionally. */ - size_val.pol.create (0); - chkp_collect_value (size, size_val); - known = chkp_is_constant_addr (size_val, &sign); - size_val.pol.release (); - - /* If we are not sure size is not zero then we have - to perform runtime check for size and perform - checks only when size is not zero. */ - if (!known) - { - gimple *check = gimple_build_cond (NE_EXPR, - size, - size_zero_node, - NULL_TREE, - NULL_TREE); - - /* Split block before string function call. */ - gsi_prev (&i); - check_bb = insert_cond_bb (bb, gsi_stmt (i), check, - profile_probability::likely ()); - - /* Set position for checks. */ - j = gsi_last_bb (check_bb); - - /* The block was splitted and therefore we - need to set iterator to its end. */ - i = gsi_last_bb (bb); - } - /* If size is known to be zero then no checks - should be performed. */ - else if (!sign) - continue; - else - j = i; - - size = size_binop (MINUS_EXPR, size, size_one_node); - if (!is_memset) - { - tree src = gimple_call_arg (stmt, 2); - tree src_bnd = gimple_call_arg (stmt, 3); - - chkp_check_mem_access (src, fold_build_pointer_plus (src, size), - src_bnd, j, gimple_location (stmt), - integer_zero_node); - } - - chkp_check_mem_access (dst, fold_build_pointer_plus (dst, size), - dst_bnd, j, gimple_location (stmt), - integer_one_node); - - } - } - } -} - -/* Intrumentation pass inserts most of bounds creation code - in the header of the function. We want to move bounds - creation closer to bounds usage to reduce bounds lifetime. - We also try to avoid bounds creation code on paths where - bounds are not used. */ -static void -chkp_reduce_bounds_lifetime (void) -{ - basic_block bb = FALLTHRU_EDGE (ENTRY_BLOCK_PTR_FOR_FN (cfun))->dest; - gimple_stmt_iterator i; - - for (i = gsi_start_bb (bb); !gsi_end_p (i); ) - { - gimple *dom_use, *use_stmt, *stmt = gsi_stmt (i); - basic_block dom_bb; - ssa_op_iter iter; - imm_use_iterator use_iter; - use_operand_p use_p; - tree op; - bool want_move = false; - bool deps = false; - - if (gimple_code (stmt) == GIMPLE_CALL - && gimple_call_fndecl (stmt) == chkp_bndmk_fndecl) - want_move = true; - - if (gimple_code (stmt) == GIMPLE_ASSIGN - && POINTER_BOUNDS_P (gimple_assign_lhs (stmt)) - && gimple_assign_rhs_code (stmt) == VAR_DECL) - want_move = true; - - if (!want_move) - { - gsi_next (&i); - continue; - } - - /* Check we do not increase other values lifetime. */ - FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_USE) - { - op = USE_FROM_PTR (use_p); - - if (TREE_CODE (op) == SSA_NAME - && gimple_code (SSA_NAME_DEF_STMT (op)) != GIMPLE_NOP) - { - deps = true; - break; - } - } - - if (deps) - { - gsi_next (&i); - continue; - } - - /* Check all usages of bounds. */ - if (gimple_code (stmt) == GIMPLE_CALL) - op = gimple_call_lhs (stmt); - else - { - gcc_assert (gimple_code (stmt) == GIMPLE_ASSIGN); - op = gimple_assign_lhs (stmt); - } - - dom_use = NULL; - dom_bb = NULL; - - FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op) - { - if (is_gimple_debug (use_stmt)) - continue; - - if (dom_bb && - dominated_by_p (CDI_DOMINATORS, - dom_bb, gimple_bb (use_stmt))) - { - dom_use = use_stmt; - dom_bb = NULL; - } - else if (dom_bb) - dom_bb = nearest_common_dominator (CDI_DOMINATORS, dom_bb, - gimple_bb (use_stmt)); - else if (!dom_use) - dom_use = use_stmt; - else if (stmt_dominates_stmt_p (use_stmt, dom_use)) - dom_use = use_stmt; - else if (!stmt_dominates_stmt_p (dom_use, use_stmt) - /* If dom_use and use_stmt are PHI nodes in one BB - then it is OK to keep any of them as dom_use. - stmt_dominates_stmt_p returns 0 for such - combination, so check it here manually. */ - && (gimple_code (dom_use) != GIMPLE_PHI - || gimple_code (use_stmt) != GIMPLE_PHI - || gimple_bb (use_stmt) != gimple_bb (dom_use)) - ) - { - dom_bb = nearest_common_dominator (CDI_DOMINATORS, - gimple_bb (use_stmt), - gimple_bb (dom_use)); - dom_use = NULL; - } - } - - /* In case there is a single use, just move bounds - creation to the use. */ - if (dom_use || dom_bb) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Moving creation of "); - print_generic_expr (dump_file, op); - fprintf (dump_file, " down to its use.\n"); - } - - if (dom_use && gimple_code (dom_use) == GIMPLE_PHI) - { - dom_bb = get_immediate_dominator (CDI_DOMINATORS, - gimple_bb (dom_use)); - dom_use = NULL; - } - - if (dom_bb == bb - || (dom_use && gimple_bb (dom_use) == bb)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Cannot move statement bacause there is no " - "suitable dominator block other than entry block.\n"); - - gsi_next (&i); - } - else - { - if (dom_bb) - { - gimple_stmt_iterator last = gsi_last_bb (dom_bb); - if (!gsi_end_p (last) && stmt_ends_bb_p (gsi_stmt (last))) - gsi_move_before (&i, &last); - else - gsi_move_after (&i, &last); - } - else - { - gimple_stmt_iterator gsi = gsi_for_stmt (dom_use); - gsi_move_before (&i, &gsi); - } - - gimple_set_vdef (stmt, NULL_TREE); - gimple_set_vuse (stmt, NULL_TREE); - update_stmt (stmt); - } - } - else - gsi_next (&i); - } -} - -/* Initilize checker optimization pass. */ -static void -chkp_opt_init (void) -{ - check_infos.create (0); - - calculate_dominance_info (CDI_DOMINATORS); - calculate_dominance_info (CDI_POST_DOMINATORS); - - /* With LTO constant bounds vars may be not initialized by now. - Get constant bounds vars to handle their assignments during - optimizations. */ - chkp_get_zero_bounds_var (); - chkp_get_none_bounds_var (); -} - -/* Finalise checker optimization pass. */ -static void -chkp_opt_fini (void) -{ - chkp_fix_cfg (); - - free_dominance_info (CDI_POST_DOMINATORS); -} - -/* Checker optimization pass function. */ -static unsigned int -chkp_opt_execute (void) -{ - chkp_opt_init(); - - /* This optimization may introduce new checks - and thus we put it before checks search. */ - chkp_optimize_string_function_calls (); - - chkp_gather_checks_info (); - - chkp_remove_excess_intersections (); - - chkp_remove_constant_checks (); - - chkp_reduce_bounds_lifetime (); - - chkp_release_check_info (); - - chkp_opt_fini (); - - return 0; -} - -/* Pass gate. */ -static bool -chkp_opt_gate (void) -{ - return chkp_function_instrumented_p (cfun->decl) - && (flag_chkp_optimize > 0 - || (flag_chkp_optimize == -1 && optimize > 0)); -} - -namespace { - -const pass_data pass_data_chkp_opt = -{ - GIMPLE_PASS, /* type */ - "chkpopt", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - PROP_ssa | PROP_cfg, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - TODO_verify_il - | TODO_update_ssa /* todo_flags_finish */ -}; - -class pass_chkp_opt : public gimple_opt_pass -{ -public: - pass_chkp_opt (gcc::context *ctxt) - : gimple_opt_pass (pass_data_chkp_opt, ctxt) - {} - - /* opt_pass methods: */ - virtual opt_pass * clone () - { - return new pass_chkp_opt (m_ctxt); - } - - virtual bool gate (function *) - { - return chkp_opt_gate (); - } - - virtual unsigned int execute (function *) - { - return chkp_opt_execute (); - } - -}; // class pass_chkp_opt - -} // anon namespace - -gimple_opt_pass * -make_pass_chkp_opt (gcc::context *ctxt) -{ - return new pass_chkp_opt (ctxt); -} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c deleted file mode 100644 index d10e6c40423..00000000000 --- a/gcc/tree-chkp.c +++ /dev/null @@ -1,4678 +0,0 @@ -/* Pointer Bounds Checker insrumentation pass. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - Contributed by Ilya Enkovich (ilya.enkovich@intel.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/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "backend.h" -#include "target.h" -#include "rtl.h" -#include "tree.h" -#include "gimple.h" -#include "cfghooks.h" -#include "tree-pass.h" -#include "ssa.h" -#include "cgraph.h" -#include "diagnostic.h" -#include "fold-const.h" -#include "stor-layout.h" -#include "varasm.h" -#include "tree-iterator.h" -#include "tree-cfg.h" -#include "langhooks.h" -#include "tree-ssa-address.h" -#include "tree-ssa-loop-niter.h" -#include "gimple-pretty-print.h" -#include "gimple-iterator.h" -#include "gimplify.h" -#include "gimplify-me.h" -#include "print-tree.h" -#include "calls.h" -#include "expr.h" -#include "tree-ssa-propagate.h" -#include "tree-chkp.h" -#include "gimple-walk.h" -#include "tree-dfa.h" -#include "ipa-chkp.h" -#include "params.h" -#include "stringpool.h" -#include "attribs.h" - -/* Pointer Bounds Checker instruments code with memory checks to find - out-of-bounds memory accesses. Checks are performed by computing - bounds for each pointer and then comparing address of accessed - memory before pointer dereferencing. - - 1. Function clones. - - See ipa-chkp.c. - - 2. Instrumentation. - - There are few things to instrument: - - a) Memory accesses - add checker calls to check address of accessed memory - against bounds of dereferenced pointer. Obviously safe memory - accesses like static variable access does not have to be instrumented - with checks. - - Example: - - val_2 = *p_1; - - with 4 bytes access is transformed into: - - __builtin___chkp_bndcl (__bound_tmp.1_3, p_1); - D.1_4 = p_1 + 3; - __builtin___chkp_bndcu (__bound_tmp.1_3, D.1_4); - val_2 = *p_1; - - where __bound_tmp.1_3 are bounds computed for pointer p_1, - __builtin___chkp_bndcl is a lower bound check and - __builtin___chkp_bndcu is an upper bound check. - - b) Pointer stores. - - When pointer is stored in memory we need to store its bounds. To - achieve compatibility of instrumented code with regular codes - we have to keep data layout and store bounds in special bound tables - via special checker call. Implementation of bounds table may vary for - different platforms. It has to associate pointer value and its - location (it is required because we may have two equal pointers - with different bounds stored in different places) with bounds. - Another checker builtin allows to get bounds for specified pointer - loaded from specified location. - - Example: - - buf1[i_1] = &buf2; - - is transformed into: - - buf1[i_1] = &buf2; - D.1_2 = &buf1[i_1]; - __builtin___chkp_bndstx (D.1_2, &buf2, __bound_tmp.1_2); - - where __bound_tmp.1_2 are bounds of &buf2. - - c) Static initialization. - - The special case of pointer store is static pointer initialization. - Bounds initialization is performed in a few steps: - - register all static initializations in front-end using - chkp_register_var_initializer - - when file compilation finishes we create functions with special - attribute 'chkp ctor' and put explicit initialization code - (assignments) for all statically initialized pointers. - - when checker constructor is compiled checker pass adds required - bounds initialization for all statically initialized pointers - - since we do not actually need excess pointers initialization - in checker constructor we remove such assignments from them - - d) Calls. - - For each call in the code we add additional arguments to pass - bounds for pointer arguments. We determine type of call arguments - using arguments list from function declaration; if function - declaration is not available we use function type; otherwise - (e.g. for unnamed arguments) we use type of passed value. Function - declaration/type is replaced with the instrumented one. - - Example: - - val_1 = foo (&buf1, &buf2, &buf1, 0); - - is translated into: - - val_1 = foo.chkp (&buf1, __bound_tmp.1_2, &buf2, __bound_tmp.1_3, - &buf1, __bound_tmp.1_2, 0); - - e) Returns. - - If function returns a pointer value we have to return bounds also. - A new operand was added for return statement to hold returned bounds. - - Example: - - return &_buf1; - - is transformed into - - return &_buf1, __bound_tmp.1_1; - - 3. Bounds computation. - - Compiler is fully responsible for computing bounds to be used for each - memory access. The first step for bounds computation is to find the - origin of pointer dereferenced for memory access. Basing on pointer - origin we define a way to compute its bounds. There are just few - possible cases: - - a) Pointer is returned by call. - - In this case we use corresponding checker builtin method to obtain returned - bounds. - - Example: - - buf_1 = malloc (size_2); - foo (buf_1); - - is translated into: - - buf_1 = malloc (size_2); - __bound_tmp.1_3 = __builtin___chkp_bndret (buf_1); - foo (buf_1, __bound_tmp.1_3); - - b) Pointer is an address of an object. - - In this case compiler tries to compute objects size and create corresponding - bounds. If object has incomplete type then special checker builtin is used to - obtain its size at runtime. - - Example: - - foo () - { - <unnamed type> __bound_tmp.3; - static int buf[100]; - - <bb 3>: - __bound_tmp.3_2 = __builtin___chkp_bndmk (&buf, 400); - - <bb 2>: - return &buf, __bound_tmp.3_2; - } - - Example: - - Address of an object 'extern int buf[]' with incomplete type is - returned. - - foo () - { - <unnamed type> __bound_tmp.4; - long unsigned int __size_tmp.3; - - <bb 3>: - __size_tmp.3_4 = __builtin_ia32_sizeof (buf); - __bound_tmp.4_3 = __builtin_ia32_bndmk (&buf, __size_tmp.3_4); - - <bb 2>: - return &buf, __bound_tmp.4_3; - } - - c) Pointer is the result of object narrowing. - - It happens when we use pointer to an object to compute pointer to a part - of an object. E.g. we take pointer to a field of a structure. In this - case we perform bounds intersection using bounds of original object and - bounds of object's part (which are computed basing on its type). - - There may be some debatable questions about when narrowing should occur - and when it should not. To avoid false bound violations in correct - programs we do not perform narrowing when address of an array element is - obtained (it has address of the whole array) and when address of the first - structure field is obtained (because it is guaranteed to be equal to - address of the whole structure and it is legal to cast it back to structure). - - Default narrowing behavior may be changed using compiler flags. - - Example: - - In this example address of the second structure field is returned. - - foo (struct A * p, __bounds_type __bounds_of_p) - { - <unnamed type> __bound_tmp.3; - int * _2; - int * _5; - - <bb 2>: - _5 = &p_1(D)->second_field; - __bound_tmp.3_6 = __builtin___chkp_bndmk (_5, 4); - __bound_tmp.3_8 = __builtin___chkp_intersect (__bound_tmp.3_6, - __bounds_of_p_3(D)); - _2 = &p_1(D)->second_field; - return _2, __bound_tmp.3_8; - } - - Example: - - In this example address of the first field of array element is returned. - - foo (struct A * p, __bounds_type __bounds_of_p, int i) - { - long unsigned int _3; - long unsigned int _4; - struct A * _6; - int * _7; - - <bb 2>: - _3 = (long unsigned int) i_1(D); - _4 = _3 * 8; - _6 = p_5(D) + _4; - _7 = &_6->first_field; - return _7, __bounds_of_p_2(D); - } - - - d) Pointer is the result of pointer arithmetic or type cast. - - In this case bounds of the base pointer are used. In case of binary - operation producing a pointer we are analyzing data flow further - looking for operand's bounds. One operand is considered as a base - if it has some valid bounds. If we fall into a case when none of - operands (or both of them) has valid bounds, a default bounds value - is used. - - Trying to find out bounds for binary operations we may fall into - cyclic dependencies for pointers. To avoid infinite recursion all - walked phi nodes instantly obtain corresponding bounds but created - bounds are marked as incomplete. It helps us to stop DF walk during - bounds search. - - When we reach pointer source, some args of incomplete bounds phi obtain - valid bounds and those values are propagated further through phi nodes. - If no valid bounds were found for phi node then we mark its result as - invalid bounds. Process stops when all incomplete bounds become either - valid or invalid and we are able to choose a pointer base. - - e) Pointer is loaded from the memory. - - In this case we just need to load bounds from the bounds table. - - Example: - - foo () - { - <unnamed type> __bound_tmp.3; - static int * buf; - int * _2; - - <bb 2>: - _2 = buf; - __bound_tmp.3_4 = __builtin___chkp_bndldx (&buf, _2); - return _2, __bound_tmp.3_4; - } - -*/ - -typedef void (*assign_handler)(tree, tree, void *); - -static tree chkp_get_zero_bounds (); -static tree chkp_find_bounds (tree ptr, gimple_stmt_iterator *iter); -static tree chkp_find_bounds_loaded (tree ptr, tree ptr_src, - gimple_stmt_iterator *iter); -static void chkp_parse_array_and_component_ref (tree node, tree *ptr, - tree *elt, bool *safe, - bool *bitfield, - tree *bounds, - gimple_stmt_iterator *iter, - bool innermost_bounds); -static void chkp_parse_bit_field_ref (tree node, location_t loc, - tree *offset, tree *size); -static tree -chkp_make_addressed_object_bounds (tree obj, gimple_stmt_iterator *iter); - -#define chkp_bndldx_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDLDX)) -#define chkp_bndstx_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDSTX)) -#define chkp_checkl_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDCL)) -#define chkp_checku_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDCU)) -#define chkp_bndmk_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDMK)) -#define chkp_ret_bnd_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDRET)) -#define chkp_intersect_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_INTERSECT)) -#define chkp_narrow_bounds_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_NARROW)) -#define chkp_sizeof_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_SIZEOF)) -#define chkp_extract_lower_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_EXTRACT_LOWER)) -#define chkp_extract_upper_fndecl \ - (targetm.builtin_chkp_function (BUILT_IN_CHKP_EXTRACT_UPPER)) - -static GTY (()) tree chkp_uintptr_type; - -static GTY (()) tree chkp_zero_bounds_var; -static GTY (()) tree chkp_none_bounds_var; - -static GTY (()) basic_block entry_block; -static GTY (()) tree zero_bounds; -static GTY (()) tree none_bounds; -static GTY (()) tree incomplete_bounds; -static GTY (()) tree tmp_var; -static GTY (()) tree size_tmp_var; -static GTY (()) bitmap chkp_abnormal_copies; - -struct hash_set<tree> *chkp_invalid_bounds; -struct hash_set<tree> *chkp_completed_bounds_set; -struct hash_map<tree, tree> *chkp_reg_bounds; -struct hash_map<tree, tree> *chkp_bound_vars; -struct hash_map<tree, tree> *chkp_reg_addr_bounds; -struct hash_map<tree, tree> *chkp_incomplete_bounds_map; -struct hash_map<tree, tree> *chkp_bounds_map; -struct hash_map<tree, tree> *chkp_static_var_bounds; - -static bool in_chkp_pass; - -#define CHKP_BOUND_TMP_NAME "__bound_tmp" -#define CHKP_SIZE_TMP_NAME "__size_tmp" -#define CHKP_BOUNDS_OF_SYMBOL_PREFIX "__chkp_bounds_of_" -#define CHKP_STRING_BOUNDS_PREFIX "__chkp_string_bounds_" -#define CHKP_VAR_BOUNDS_PREFIX "__chkp_var_bounds_" -#define CHKP_ZERO_BOUNDS_VAR_NAME "__chkp_zero_bounds" -#define CHKP_NONE_BOUNDS_VAR_NAME "__chkp_none_bounds" - -/* Static checker constructors may become very large and their - compilation with optimization may take too much time. - Therefore we put a limit to number of statements in one - constructor. Tests with 100 000 statically initialized - pointers showed following compilation times on Sandy Bridge - server (used -O2): - limit 100 => ~18 sec. - limit 300 => ~22 sec. - limit 1000 => ~30 sec. - limit 3000 => ~49 sec. - limit 5000 => ~55 sec. - limit 10000 => ~76 sec. - limit 100000 => ~532 sec. */ -#define MAX_STMTS_IN_STATIC_CHKP_CTOR (PARAM_VALUE (PARAM_CHKP_MAX_CTOR_SIZE)) - -struct chkp_ctor_stmt_list -{ - tree stmts; - int avail; -}; - -/* Return 1 if function FNDECL is instrumented by Pointer - Bounds Checker. */ -bool -chkp_function_instrumented_p (tree fndecl) -{ - return fndecl - && lookup_attribute ("chkp instrumented", DECL_ATTRIBUTES (fndecl)); -} - -/* Mark function FNDECL as instrumented. */ -void -chkp_function_mark_instrumented (tree fndecl) -{ - if (chkp_function_instrumented_p (fndecl)) - return; - - DECL_ATTRIBUTES (fndecl) - = tree_cons (get_identifier ("chkp instrumented"), NULL, - DECL_ATTRIBUTES (fndecl)); -} - -/* Return true when STMT is builtin call to instrumentation function - corresponding to CODE. */ - -bool -chkp_gimple_call_builtin_p (gimple *call, - enum built_in_function code) -{ - tree fndecl; - /* We are skipping the check for address-spaces, that's - why we don't use gimple_call_builtin_p directly here. */ - if (is_gimple_call (call) - && (fndecl = gimple_call_fndecl (call)) != NULL - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD - && (fndecl = targetm.builtin_chkp_function (code)) - && (DECL_FUNCTION_CODE (gimple_call_fndecl (call)) - == DECL_FUNCTION_CODE (fndecl))) - return true; - return false; -} - -/* Emit code to build zero bounds and return RTL holding - the result. */ -rtx -chkp_expand_zero_bounds () -{ - tree zero_bnd; - - if (flag_chkp_use_static_const_bounds) - zero_bnd = chkp_get_zero_bounds_var (); - else - zero_bnd = chkp_build_make_bounds_call (integer_zero_node, - integer_zero_node); - return expand_normal (zero_bnd); -} - -/* Emit code to store zero bounds for PTR located at MEM. */ -void -chkp_expand_bounds_reset_for_mem (tree mem, tree ptr) -{ - tree zero_bnd, bnd, addr, bndstx; - - if (flag_chkp_use_static_const_bounds) - zero_bnd = chkp_get_zero_bounds_var (); - else - zero_bnd = chkp_build_make_bounds_call (integer_zero_node, - integer_zero_node); - bnd = make_tree (pointer_bounds_type_node, - assign_temp (pointer_bounds_type_node, 0, 1)); - addr = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (mem)), mem); - bndstx = chkp_build_bndstx_call (addr, ptr, bnd); - - expand_assignment (bnd, zero_bnd, false); - expand_normal (bndstx); -} - -/* Build retbnd call for returned value RETVAL. - - If BNDVAL is not NULL then result is stored - in it. Otherwise a temporary is created to - hold returned value. - - GSI points to a position for a retbnd call - and is set to created stmt. - - Cgraph edge is created for a new call if - UPDATE_EDGE is 1. - - Obtained bounds are returned. */ -tree -chkp_insert_retbnd_call (tree bndval, tree retval, - gimple_stmt_iterator *gsi) -{ - gimple *call; - - if (!bndval) - bndval = create_tmp_reg (pointer_bounds_type_node, "retbnd"); - - call = gimple_build_call (chkp_ret_bnd_fndecl, 1, retval); - gimple_call_set_lhs (call, bndval); - gsi_insert_after (gsi, call, GSI_CONTINUE_LINKING); - - return bndval; -} - -/* Build a GIMPLE_CALL identical to CALL but skipping bounds - arguments. */ - -gcall * -chkp_copy_call_skip_bounds (gcall *call) -{ - bitmap bounds; - unsigned i; - - bitmap_obstack_initialize (NULL); - bounds = BITMAP_ALLOC (NULL); - - for (i = 0; i < gimple_call_num_args (call); i++) - if (POINTER_BOUNDS_P (gimple_call_arg (call, i))) - bitmap_set_bit (bounds, i); - - if (!bitmap_empty_p (bounds)) - call = gimple_call_copy_skip_args (call, bounds); - gimple_call_set_with_bounds (call, false); - - BITMAP_FREE (bounds); - bitmap_obstack_release (NULL); - - return call; -} - -/* Redirect edge E to the correct node according to call_stmt. - Return 1 if bounds removal from call_stmt should be done - instead of redirection. */ - -bool -chkp_redirect_edge (cgraph_edge *e) -{ - bool instrumented = false; - tree decl = e->callee->decl; - - if (e->callee->instrumentation_clone - || chkp_function_instrumented_p (decl)) - instrumented = true; - - if (instrumented - && !gimple_call_with_bounds_p (e->call_stmt)) - e->redirect_callee (cgraph_node::get_create (e->callee->orig_decl)); - else if (!instrumented - && gimple_call_with_bounds_p (e->call_stmt) - && !chkp_gimple_call_builtin_p (e->call_stmt, BUILT_IN_CHKP_BNDCL) - && !chkp_gimple_call_builtin_p (e->call_stmt, BUILT_IN_CHKP_BNDCU) - && !chkp_gimple_call_builtin_p (e->call_stmt, BUILT_IN_CHKP_BNDSTX)) - { - if (e->callee->instrumented_version) - e->redirect_callee (e->callee->instrumented_version); - else - { - tree args = TYPE_ARG_TYPES (TREE_TYPE (decl)); - /* Avoid bounds removal if all args will be removed. */ - if (!args || TREE_VALUE (args) != void_type_node) - return true; - else - gimple_call_set_with_bounds (e->call_stmt, false); - } - } - - return false; -} - -/* Mark statement S to not be instrumented. */ -static void -chkp_mark_stmt (gimple *s) -{ - gimple_set_plf (s, GF_PLF_1, true); -} - -/* Mark statement S to be instrumented. */ -static void -chkp_unmark_stmt (gimple *s) -{ - gimple_set_plf (s, GF_PLF_1, false); -} - -/* Return 1 if statement S should not be instrumented. */ -static bool -chkp_marked_stmt_p (gimple *s) -{ - return gimple_plf (s, GF_PLF_1); -} - -/* Get var to be used for bound temps. */ -static tree -chkp_get_tmp_var (void) -{ - if (!tmp_var) - tmp_var = create_tmp_reg (pointer_bounds_type_node, CHKP_BOUND_TMP_NAME); - - return tmp_var; -} - -/* Get SSA_NAME to be used as temp. */ -static tree -chkp_get_tmp_reg (gimple *stmt) -{ - if (in_chkp_pass) - return make_ssa_name (chkp_get_tmp_var (), stmt); - - return make_temp_ssa_name (pointer_bounds_type_node, stmt, - CHKP_BOUND_TMP_NAME); -} - -/* Get var to be used for size temps. */ -static tree -chkp_get_size_tmp_var (void) -{ - if (!size_tmp_var) - size_tmp_var = create_tmp_reg (chkp_uintptr_type, CHKP_SIZE_TMP_NAME); - - return size_tmp_var; -} - -/* Register bounds BND for address of OBJ. */ -static void -chkp_register_addr_bounds (tree obj, tree bnd) -{ - if (bnd == incomplete_bounds) - return; - - chkp_reg_addr_bounds->put (obj, bnd); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Regsitered bound "); - print_generic_expr (dump_file, bnd); - fprintf (dump_file, " for address of "); - print_generic_expr (dump_file, obj); - fprintf (dump_file, "\n"); - } -} - -/* Return bounds registered for address of OBJ. */ -static tree -chkp_get_registered_addr_bounds (tree obj) -{ - tree *slot = chkp_reg_addr_bounds->get (obj); - return slot ? *slot : NULL_TREE; -} - -/* Mark BOUNDS as completed. */ -static void -chkp_mark_completed_bounds (tree bounds) -{ - chkp_completed_bounds_set->add (bounds); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Marked bounds "); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, " as completed\n"); - } -} - -/* Return 1 if BOUNDS were marked as completed and 0 otherwise. */ -static bool -chkp_completed_bounds (tree bounds) -{ - return chkp_completed_bounds_set->contains (bounds); -} - -/* Clear comleted bound marks. */ -static void -chkp_erase_completed_bounds (void) -{ - delete chkp_completed_bounds_set; - chkp_completed_bounds_set = new hash_set<tree>; -} - -/* This function is used to provide a base address for - chkp_get_hard_register_fake_addr_expr. */ -static tree -chkp_get_hard_register_var_fake_base_address () -{ - int prec = TYPE_PRECISION (ptr_type_node); - return wide_int_to_tree (ptr_type_node, wi::min_value (prec, SIGNED)); -} - -/* If we check bounds for a hard register variable, we cannot - use its address - it is illegal, so instead of that we use - this fake value. */ -static tree -chkp_get_hard_register_fake_addr_expr (tree obj) -{ - tree addr = chkp_get_hard_register_var_fake_base_address (); - tree outer = obj; - while (TREE_CODE (outer) == COMPONENT_REF || TREE_CODE (outer) == ARRAY_REF) - { - if (TREE_CODE (outer) == COMPONENT_REF) - { - addr = fold_build_pointer_plus (addr, - component_ref_field_offset (outer)); - outer = TREE_OPERAND (outer, 0); - } - else if (TREE_CODE (outer) == ARRAY_REF) - { - tree indx = fold_convert(size_type_node, TREE_OPERAND(outer, 1)); - tree offset = size_binop (MULT_EXPR, - array_ref_element_size (outer), indx); - addr = fold_build_pointer_plus (addr, offset); - outer = TREE_OPERAND (outer, 0); - } - } - - return addr; -} - -/* Mark BOUNDS associated with PTR as incomplete. */ -static void -chkp_register_incomplete_bounds (tree bounds, tree ptr) -{ - chkp_incomplete_bounds_map->put (bounds, ptr); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Regsitered incomplete bounds "); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, " for "); - print_generic_expr (dump_file, ptr); - fprintf (dump_file, "\n"); - } -} - -/* Return 1 if BOUNDS are incomplete and 0 otherwise. */ -static bool -chkp_incomplete_bounds (tree bounds) -{ - if (bounds == incomplete_bounds) - return true; - - if (chkp_completed_bounds (bounds)) - return false; - - return chkp_incomplete_bounds_map->get (bounds) != NULL; -} - -/* Clear incomleted bound marks. */ -static void -chkp_erase_incomplete_bounds (void) -{ - delete chkp_incomplete_bounds_map; - chkp_incomplete_bounds_map = new hash_map<tree, tree>; -} - -/* Build and return bndmk call which creates bounds for structure - pointed by PTR. Structure should have complete type. */ -tree -chkp_make_bounds_for_struct_addr (tree ptr) -{ - tree type = TREE_TYPE (ptr); - tree size; - - gcc_assert (POINTER_TYPE_P (type)); - - size = TYPE_SIZE (TREE_TYPE (type)); - - gcc_assert (size); - - return build_call_nary (pointer_bounds_type_node, - build_fold_addr_expr (chkp_bndmk_fndecl), - 2, ptr, size); -} - -/* Traversal function for chkp_may_finish_incomplete_bounds. - Set RES to 0 if at least one argument of phi statement - defining bounds (passed in KEY arg) is unknown. - Traversal stops when first unknown phi argument is found. */ -bool -chkp_may_complete_phi_bounds (tree const &bounds, tree *slot ATTRIBUTE_UNUSED, - bool *res) -{ - gimple *phi; - unsigned i; - - gcc_assert (TREE_CODE (bounds) == SSA_NAME); - - phi = SSA_NAME_DEF_STMT (bounds); - - gcc_assert (phi && gimple_code (phi) == GIMPLE_PHI); - - for (i = 0; i < gimple_phi_num_args (phi); i++) - { - tree phi_arg = gimple_phi_arg_def (phi, i); - if (!phi_arg) - { - *res = false; - /* Do not need to traverse further. */ - return false; - } - } - - return true; -} - -/* Return 1 if all phi nodes created for bounds have their - arguments computed. */ -static bool -chkp_may_finish_incomplete_bounds (void) -{ - bool res = true; - - chkp_incomplete_bounds_map - ->traverse<bool *, chkp_may_complete_phi_bounds> (&res); - - return res; -} - -/* Helper function for chkp_finish_incomplete_bounds. - Recompute args for bounds phi node. */ -bool -chkp_recompute_phi_bounds (tree const &bounds, tree *slot, - void *res ATTRIBUTE_UNUSED) -{ - tree ptr = *slot; - gphi *bounds_phi; - gphi *ptr_phi; - unsigned i; - - gcc_assert (TREE_CODE (bounds) == SSA_NAME); - gcc_assert (TREE_CODE (ptr) == SSA_NAME); - - bounds_phi = as_a <gphi *> (SSA_NAME_DEF_STMT (bounds)); - ptr_phi = as_a <gphi *> (SSA_NAME_DEF_STMT (ptr)); - - for (i = 0; i < gimple_phi_num_args (bounds_phi); i++) - { - tree ptr_arg = gimple_phi_arg_def (ptr_phi, i); - tree bound_arg = chkp_find_bounds (ptr_arg, NULL); - - add_phi_arg (bounds_phi, bound_arg, - gimple_phi_arg_edge (ptr_phi, i), - UNKNOWN_LOCATION); - } - - return true; -} - -/* Mark BOUNDS as invalid. */ -static void -chkp_mark_invalid_bounds (tree bounds) -{ - chkp_invalid_bounds->add (bounds); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Marked bounds "); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, " as invalid\n"); - } -} - -/* Return 1 if BOUNDS were marked as invalid and 0 otherwise. */ -static bool -chkp_valid_bounds (tree bounds) -{ - if (bounds == zero_bounds || bounds == none_bounds) - return false; - - return !chkp_invalid_bounds->contains (bounds); -} - -/* Helper function for chkp_finish_incomplete_bounds. - Check all arguments of phi nodes trying to find - valid completed bounds. If there is at least one - such arg then bounds produced by phi node are marked - as valid completed bounds and all phi args are - recomputed. */ -bool -chkp_find_valid_phi_bounds (tree const &bounds, tree *slot, bool *res) -{ - gimple *phi; - unsigned i; - - gcc_assert (TREE_CODE (bounds) == SSA_NAME); - - if (chkp_completed_bounds (bounds)) - return true; - - phi = SSA_NAME_DEF_STMT (bounds); - - gcc_assert (phi && gimple_code (phi) == GIMPLE_PHI); - - for (i = 0; i < gimple_phi_num_args (phi); i++) - { - tree phi_arg = gimple_phi_arg_def (phi, i); - - gcc_assert (phi_arg); - - if (chkp_valid_bounds (phi_arg) && !chkp_incomplete_bounds (phi_arg)) - { - *res = true; - chkp_mark_completed_bounds (bounds); - chkp_recompute_phi_bounds (bounds, slot, NULL); - return true; - } - } - - return true; -} - -/* Helper function for chkp_finish_incomplete_bounds. - Marks all incompleted bounds as invalid. */ -bool -chkp_mark_invalid_bounds_walker (tree const &bounds, - tree *slot ATTRIBUTE_UNUSED, - void *res ATTRIBUTE_UNUSED) -{ - if (!chkp_completed_bounds (bounds)) - { - chkp_mark_invalid_bounds (bounds); - chkp_mark_completed_bounds (bounds); - } - return true; -} - -/* When all bound phi nodes have all their args computed - we have enough info to find valid bounds. We iterate - through all incompleted bounds searching for valid - bounds. Found valid bounds are marked as completed - and all remaining incompleted bounds are recomputed. - Process continues until no new valid bounds may be - found. All remained incompleted bounds are marked as - invalid (i.e. have no valid source of bounds). */ -static void -chkp_finish_incomplete_bounds (void) -{ - bool found_valid = true; - - while (found_valid) - { - found_valid = false; - - chkp_incomplete_bounds_map-> - traverse<bool *, chkp_find_valid_phi_bounds> (&found_valid); - - if (found_valid) - chkp_incomplete_bounds_map-> - traverse<void *, chkp_recompute_phi_bounds> (NULL); - } - - chkp_incomplete_bounds_map-> - traverse<void *, chkp_mark_invalid_bounds_walker> (NULL); - chkp_incomplete_bounds_map-> - traverse<void *, chkp_recompute_phi_bounds> (NULL); - - chkp_erase_completed_bounds (); - chkp_erase_incomplete_bounds (); -} - -/* Return 1 if type TYPE is a pointer type or a - structure having a pointer type as one of its fields. - Otherwise return 0. */ -bool -chkp_type_has_pointer (const_tree type) -{ - bool res = false; - - if (BOUNDED_TYPE_P (type)) - res = true; - else if (RECORD_OR_UNION_TYPE_P (type)) - { - tree field; - - for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - if (TREE_CODE (field) == FIELD_DECL) - res = res || chkp_type_has_pointer (TREE_TYPE (field)); - } - else if (TREE_CODE (type) == ARRAY_TYPE) - res = chkp_type_has_pointer (TREE_TYPE (type)); - - return res; -} - -unsigned -chkp_type_bounds_count (const_tree type) -{ - unsigned res = 0; - - if (!type) - res = 0; - else if (BOUNDED_TYPE_P (type)) - res = 1; - else if (RECORD_OR_UNION_TYPE_P (type)) - { - bitmap have_bound; - - bitmap_obstack_initialize (NULL); - have_bound = BITMAP_ALLOC (NULL); - chkp_find_bound_slots (type, have_bound); - res = bitmap_count_bits (have_bound); - BITMAP_FREE (have_bound); - bitmap_obstack_release (NULL); - } - - return res; -} - -/* Get bounds associated with NODE via - chkp_set_bounds call. */ -tree -chkp_get_bounds (tree node) -{ - tree *slot; - - if (!chkp_bounds_map) - return NULL_TREE; - - slot = chkp_bounds_map->get (node); - return slot ? *slot : NULL_TREE; -} - -/* Associate bounds VAL with NODE. */ -void -chkp_set_bounds (tree node, tree val) -{ - if (!chkp_bounds_map) - chkp_bounds_map = new hash_map<tree, tree>; - - chkp_bounds_map->put (node, val); -} - -/* Check if statically initialized variable VAR require - static bounds initialization. If VAR is added into - bounds initlization list then 1 is returned. Otherwise - return 0. */ -extern bool -chkp_register_var_initializer (tree var) -{ - if (!flag_check_pointer_bounds - || DECL_INITIAL (var) == error_mark_node) - return false; - - gcc_assert (VAR_P (var)); - gcc_assert (DECL_INITIAL (var)); - - if (TREE_STATIC (var) - && chkp_type_has_pointer (TREE_TYPE (var))) - { - varpool_node::get_create (var)->need_bounds_init = 1; - return true; - } - - return false; -} - -/* Helper function for chkp_finish_file. - - Add new modification statement (RHS is assigned to LHS) - into list of static initializer statementes (passed in ARG). - If statements list becomes too big, emit checker constructor - and start the new one. */ -static void -chkp_add_modification_to_stmt_list (tree lhs, - tree rhs, - void *arg) -{ - struct chkp_ctor_stmt_list *stmts = (struct chkp_ctor_stmt_list *)arg; - tree modify; - - if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) - rhs = build1 (CONVERT_EXPR, TREE_TYPE (lhs), rhs); - - modify = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, rhs); - append_to_statement_list (modify, &stmts->stmts); - - stmts->avail--; -} - -/* Build and return ADDR_EXPR for specified object OBJ. */ -static tree -chkp_build_addr_expr (tree obj) -{ - /* We first check whether it is a "hard reg case". */ - tree base = get_base_address (obj); - if (VAR_P (base) && DECL_HARD_REGISTER (base)) - return chkp_get_hard_register_fake_addr_expr (obj); - - /* If not - return regular ADDR_EXPR. */ - return TREE_CODE (obj) == TARGET_MEM_REF - ? tree_mem_ref_addr (ptr_type_node, obj) - : build_fold_addr_expr (obj); -} - -/* Helper function for chkp_finish_file. - Initialize bound variable BND_VAR with bounds of variable - VAR to statements list STMTS. If statements list becomes - too big, emit checker constructor and start the new one. */ -static void -chkp_output_static_bounds (tree bnd_var, tree var, - struct chkp_ctor_stmt_list *stmts) -{ - tree lb, ub, size; - - if (TREE_CODE (var) == STRING_CST) - { - lb = build1 (CONVERT_EXPR, size_type_node, chkp_build_addr_expr (var)); - size = build_int_cst (size_type_node, TREE_STRING_LENGTH (var) - 1); - } - else if (DECL_SIZE (var) - && !chkp_variable_size_type (TREE_TYPE (var))) - { - /* Compute bounds using statically known size. */ - lb = build1 (CONVERT_EXPR, size_type_node, chkp_build_addr_expr (var)); - size = size_binop (MINUS_EXPR, DECL_SIZE_UNIT (var), size_one_node); - } - else - { - /* Compute bounds using dynamic size. */ - tree call; - - lb = build1 (CONVERT_EXPR, size_type_node, chkp_build_addr_expr (var)); - call = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (chkp_sizeof_fndecl)), - chkp_sizeof_fndecl); - size = build_call_nary (TREE_TYPE (TREE_TYPE (chkp_sizeof_fndecl)), - call, 1, var); - - if (flag_chkp_zero_dynamic_size_as_infinite) - { - tree max_size, cond; - - max_size = build2 (MINUS_EXPR, size_type_node, size_zero_node, lb); - cond = build2 (NE_EXPR, boolean_type_node, size, size_zero_node); - size = build3 (COND_EXPR, size_type_node, cond, size, max_size); - } - - size = size_binop (MINUS_EXPR, size, size_one_node); - } - - ub = size_binop (PLUS_EXPR, lb, size); - stmts->avail -= targetm.chkp_initialize_bounds (bnd_var, lb, ub, - &stmts->stmts); - if (stmts->avail <= 0) - { - cgraph_build_static_cdtor ('B', stmts->stmts, - MAX_RESERVED_INIT_PRIORITY + 2); - stmts->avail = MAX_STMTS_IN_STATIC_CHKP_CTOR; - stmts->stmts = NULL; - } -} - -/* Return entry block to be used for checker initilization code. - Create new block if required. */ -static basic_block -chkp_get_entry_block (void) -{ - if (!entry_block) - entry_block - = split_block_after_labels (ENTRY_BLOCK_PTR_FOR_FN (cfun))->dest; - - return entry_block; -} - -/* Return a bounds var to be used for pointer var PTR_VAR. */ -static tree -chkp_get_bounds_var (tree ptr_var) -{ - tree bnd_var; - tree *slot; - - slot = chkp_bound_vars->get (ptr_var); - if (slot) - bnd_var = *slot; - else - { - bnd_var = create_tmp_reg (pointer_bounds_type_node, - CHKP_BOUND_TMP_NAME); - chkp_bound_vars->put (ptr_var, bnd_var); - } - - return bnd_var; -} - -/* If BND is an abnormal bounds copy, return a copied value. - Otherwise return BND. */ -static tree -chkp_get_orginal_bounds_for_abnormal_copy (tree bnd) -{ - if (bitmap_bit_p (chkp_abnormal_copies, SSA_NAME_VERSION (bnd))) - { - gimple *bnd_def = SSA_NAME_DEF_STMT (bnd); - gcc_checking_assert (gimple_code (bnd_def) == GIMPLE_ASSIGN); - bnd = gimple_assign_rhs1 (bnd_def); - } - - return bnd; -} - -/* Register bounds BND for object PTR in global bounds table. - A copy of bounds may be created for abnormal ssa names. - Returns bounds to use for PTR. */ -static tree -chkp_maybe_copy_and_register_bounds (tree ptr, tree bnd) -{ - bool abnormal_ptr; - - if (!chkp_reg_bounds) - return bnd; - - /* Do nothing if bounds are incomplete_bounds - because it means bounds will be recomputed. */ - if (bnd == incomplete_bounds) - return bnd; - - abnormal_ptr = (TREE_CODE (ptr) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ptr) - && gimple_code (SSA_NAME_DEF_STMT (ptr)) != GIMPLE_PHI); - - /* A single bounds value may be reused multiple times for - different pointer values. It may cause coalescing issues - for abnormal SSA names. To avoid it we create a bounds - copy in case it is computed for abnormal SSA name. - - We also cannot reuse such created copies for other pointers */ - if (abnormal_ptr - || bitmap_bit_p (chkp_abnormal_copies, SSA_NAME_VERSION (bnd))) - { - tree bnd_var = NULL_TREE; - - if (abnormal_ptr) - { - if (SSA_NAME_VAR (ptr)) - bnd_var = chkp_get_bounds_var (SSA_NAME_VAR (ptr)); - } - else - bnd_var = chkp_get_tmp_var (); - - /* For abnormal copies we may just find original - bounds and use them. */ - if (!abnormal_ptr && !SSA_NAME_IS_DEFAULT_DEF (bnd)) - bnd = chkp_get_orginal_bounds_for_abnormal_copy (bnd); - /* For undefined values we usually use none bounds - value but in case of abnormal edge it may cause - coalescing failures. Use default definition of - bounds variable instead to avoid it. */ - else if (SSA_NAME_IS_DEFAULT_DEF (ptr) - && TREE_CODE (SSA_NAME_VAR (ptr)) != PARM_DECL) - { - bnd = get_or_create_ssa_default_def (cfun, bnd_var); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Using default def bounds "); - print_generic_expr (dump_file, bnd); - fprintf (dump_file, " for abnormal default def SSA name "); - print_generic_expr (dump_file, ptr); - fprintf (dump_file, "\n"); - } - } - else - { - tree copy; - gimple *def = SSA_NAME_DEF_STMT (ptr); - gimple *assign; - gimple_stmt_iterator gsi; - - if (bnd_var) - copy = make_ssa_name (bnd_var); - else - copy = make_temp_ssa_name (pointer_bounds_type_node, - NULL, - CHKP_BOUND_TMP_NAME); - bnd = chkp_get_orginal_bounds_for_abnormal_copy (bnd); - assign = gimple_build_assign (copy, bnd); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Creating a copy of bounds "); - print_generic_expr (dump_file, bnd); - fprintf (dump_file, " for abnormal SSA name "); - print_generic_expr (dump_file, ptr); - fprintf (dump_file, "\n"); - } - - if (gimple_code (def) == GIMPLE_NOP) - { - gsi = gsi_last_bb (chkp_get_entry_block ()); - if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi))) - gsi_insert_before (&gsi, assign, GSI_CONTINUE_LINKING); - else - gsi_insert_after (&gsi, assign, GSI_CONTINUE_LINKING); - } - else - { - gimple *bnd_def = SSA_NAME_DEF_STMT (bnd); - /* Sometimes (e.g. when we load a pointer from a - memory) bounds are produced later than a pointer. - We need to insert bounds copy appropriately. */ - if (gimple_code (bnd_def) != GIMPLE_NOP - && stmt_dominates_stmt_p (def, bnd_def)) - gsi = gsi_for_stmt (bnd_def); - else - gsi = gsi_for_stmt (def); - gsi_insert_after (&gsi, assign, GSI_CONTINUE_LINKING); - } - - bnd = copy; - } - - if (abnormal_ptr) - bitmap_set_bit (chkp_abnormal_copies, SSA_NAME_VERSION (bnd)); - } - - chkp_reg_bounds->put (ptr, bnd); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Regsitered bound "); - print_generic_expr (dump_file, bnd); - fprintf (dump_file, " for pointer "); - print_generic_expr (dump_file, ptr); - fprintf (dump_file, "\n"); - } - - return bnd; -} - -/* Get bounds registered for object PTR in global bounds table. */ -static tree -chkp_get_registered_bounds (tree ptr) -{ - tree *slot; - - if (!chkp_reg_bounds) - return NULL_TREE; - - slot = chkp_reg_bounds->get (ptr); - return slot ? *slot : NULL_TREE; -} - -/* Add bound retvals to return statement pointed by GSI. */ - -static void -chkp_add_bounds_to_ret_stmt (gimple_stmt_iterator *gsi) -{ - greturn *ret = as_a <greturn *> (gsi_stmt (*gsi)); - tree retval = gimple_return_retval (ret); - tree ret_decl = DECL_RESULT (cfun->decl); - tree bounds; - - if (!retval) - return; - - if (BOUNDED_P (ret_decl)) - { - bounds = chkp_find_bounds (retval, gsi); - bounds = chkp_maybe_copy_and_register_bounds (ret_decl, bounds); - gimple_return_set_retbnd (ret, bounds); - } - - update_stmt (ret); -} - -/* Force OP to be suitable for using as an argument for call. - New statements (if any) go to SEQ. */ -static tree -chkp_force_gimple_call_op (tree op, gimple_seq *seq) -{ - gimple_seq stmts; - gimple_stmt_iterator si; - - op = force_gimple_operand (unshare_expr (op), &stmts, true, NULL_TREE); - - for (si = gsi_start (stmts); !gsi_end_p (si); gsi_next (&si)) - chkp_mark_stmt (gsi_stmt (si)); - - gimple_seq_add_seq (seq, stmts); - - return op; -} - -/* Generate lower bound check for memory access by ADDR. - Check is inserted before the position pointed by ITER. - DIRFLAG indicates whether memory access is load or store. */ -static void -chkp_check_lower (tree addr, tree bounds, - gimple_stmt_iterator iter, - location_t location, - tree dirflag) -{ - gimple_seq seq; - gimple *check; - tree node; - - if (!chkp_function_instrumented_p (current_function_decl) - && bounds == chkp_get_zero_bounds ()) - return; - - if (dirflag == integer_zero_node - && !flag_chkp_check_read) - return; - - if (dirflag == integer_one_node - && !flag_chkp_check_write) - return; - - seq = NULL; - - node = chkp_force_gimple_call_op (addr, &seq); - - check = gimple_build_call (chkp_checkl_fndecl, 2, node, bounds); - chkp_mark_stmt (check); - gimple_call_set_with_bounds (check, true); - gimple_set_location (check, location); - gimple_seq_add_stmt (&seq, check); - - gsi_insert_seq_before (&iter, seq, GSI_SAME_STMT); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - gimple *before = gsi_stmt (iter); - fprintf (dump_file, "Generated lower bound check for statement "); - print_gimple_stmt (dump_file, before, 0, TDF_VOPS|TDF_MEMSYMS); - fprintf (dump_file, " "); - print_gimple_stmt (dump_file, check, 0, TDF_VOPS|TDF_MEMSYMS); - } -} - -/* Generate upper bound check for memory access by ADDR. - Check is inserted before the position pointed by ITER. - DIRFLAG indicates whether memory access is load or store. */ -static void -chkp_check_upper (tree addr, tree bounds, - gimple_stmt_iterator iter, - location_t location, - tree dirflag) -{ - gimple_seq seq; - gimple *check; - tree node; - - if (!chkp_function_instrumented_p (current_function_decl) - && bounds == chkp_get_zero_bounds ()) - return; - - if (dirflag == integer_zero_node - && !flag_chkp_check_read) - return; - - if (dirflag == integer_one_node - && !flag_chkp_check_write) - return; - - seq = NULL; - - node = chkp_force_gimple_call_op (addr, &seq); - - check = gimple_build_call (chkp_checku_fndecl, 2, node, bounds); - chkp_mark_stmt (check); - gimple_call_set_with_bounds (check, true); - gimple_set_location (check, location); - gimple_seq_add_stmt (&seq, check); - - gsi_insert_seq_before (&iter, seq, GSI_SAME_STMT); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - gimple *before = gsi_stmt (iter); - fprintf (dump_file, "Generated upper bound check for statement "); - print_gimple_stmt (dump_file, before, 0, TDF_VOPS|TDF_MEMSYMS); - fprintf (dump_file, " "); - print_gimple_stmt (dump_file, check, 0, TDF_VOPS|TDF_MEMSYMS); - } -} - -/* Generate lower and upper bound checks for memory access - to memory slot [FIRST, LAST] againsr BOUNDS. Checks - are inserted before the position pointed by ITER. - DIRFLAG indicates whether memory access is load or store. */ -void -chkp_check_mem_access (tree first, tree last, tree bounds, - gimple_stmt_iterator iter, - location_t location, - tree dirflag) -{ - chkp_check_lower (first, bounds, iter, location, dirflag); - chkp_check_upper (last, bounds, iter, location, dirflag); -} - -/* Replace call to _bnd_chk_* pointed by GSI with - bndcu and bndcl calls. DIRFLAG determines whether - check is for read or write. */ - -void -chkp_replace_address_check_builtin (gimple_stmt_iterator *gsi, - tree dirflag) -{ - gimple_stmt_iterator call_iter = *gsi; - gimple *call = gsi_stmt (*gsi); - tree fndecl = gimple_call_fndecl (call); - tree addr = gimple_call_arg (call, 0); - tree bounds = chkp_find_bounds (addr, gsi); - - if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_LBOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_BOUNDS) - chkp_check_lower (addr, bounds, *gsi, gimple_location (call), dirflag); - - if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_UBOUNDS) - chkp_check_upper (addr, bounds, *gsi, gimple_location (call), dirflag); - - if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_BOUNDS) - { - tree size = gimple_call_arg (call, 1); - addr = fold_build_pointer_plus (addr, size); - addr = fold_build_pointer_plus_hwi (addr, -1); - chkp_check_upper (addr, bounds, *gsi, gimple_location (call), dirflag); - } - - gsi_remove (&call_iter, true); -} - -/* Replace call to _bnd_get_ptr_* pointed by GSI with - corresponding bounds extract call. */ - -void -chkp_replace_extract_builtin (gimple_stmt_iterator *gsi) -{ - gimple *call = gsi_stmt (*gsi); - tree fndecl = gimple_call_fndecl (call); - tree addr = gimple_call_arg (call, 0); - tree bounds = chkp_find_bounds (addr, gsi); - gimple *extract; - - if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_GET_PTR_LBOUND) - fndecl = chkp_extract_lower_fndecl; - else if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_GET_PTR_UBOUND) - fndecl = chkp_extract_upper_fndecl; - else - gcc_unreachable (); - - extract = gimple_build_call (fndecl, 1, bounds); - gimple_call_set_lhs (extract, gimple_call_lhs (call)); - chkp_mark_stmt (extract); - - gsi_replace (gsi, extract, false); -} - -/* Return COMPONENT_REF accessing FIELD in OBJ. */ -static tree -chkp_build_component_ref (tree obj, tree field) -{ - tree res; - - /* If object is TMR then we do not use component_ref but - add offset instead. We need it to be able to get addr - of the reasult later. */ - if (TREE_CODE (obj) == TARGET_MEM_REF) - { - tree offs = TMR_OFFSET (obj); - offs = fold_binary_to_constant (PLUS_EXPR, TREE_TYPE (offs), - offs, DECL_FIELD_OFFSET (field)); - - gcc_assert (offs); - - res = copy_node (obj); - TREE_TYPE (res) = TREE_TYPE (field); - TMR_OFFSET (res) = offs; - } - else - res = build3 (COMPONENT_REF, TREE_TYPE (field), obj, field, NULL_TREE); - - return res; -} - -/* Return ARRAY_REF for array ARR and index IDX with - specified element type ETYPE and element size ESIZE. */ -static tree -chkp_build_array_ref (tree arr, tree etype, tree esize, - unsigned HOST_WIDE_INT idx) -{ - tree index = build_int_cst (size_type_node, idx); - tree res; - - /* If object is TMR then we do not use array_ref but - add offset instead. We need it to be able to get addr - of the reasult later. */ - if (TREE_CODE (arr) == TARGET_MEM_REF) - { - tree offs = TMR_OFFSET (arr); - - esize = fold_binary_to_constant (MULT_EXPR, TREE_TYPE (esize), - esize, index); - gcc_assert(esize); - - offs = fold_binary_to_constant (PLUS_EXPR, TREE_TYPE (offs), - offs, esize); - gcc_assert (offs); - - res = copy_node (arr); - TREE_TYPE (res) = etype; - TMR_OFFSET (res) = offs; - } - else - res = build4 (ARRAY_REF, etype, arr, index, NULL_TREE, NULL_TREE); - - return res; -} - -/* Helper function for chkp_add_bounds_to_call_stmt. - Fill ALL_BOUNDS output array with created bounds. - - OFFS is used for recursive calls and holds basic - offset of TYPE in outer structure in bits. - - ITER points a position where bounds are searched. - - ALL_BOUNDS[i] is filled with elem bounds if there - is a field in TYPE which has pointer type and offset - equal to i * POINTER_SIZE in bits. */ -static void -chkp_find_bounds_for_elem (tree elem, tree *all_bounds, - HOST_WIDE_INT offs, - gimple_stmt_iterator *iter) -{ - tree type = TREE_TYPE (elem); - - if (BOUNDED_TYPE_P (type)) - { - if (!all_bounds[offs / POINTER_SIZE]) - { - tree temp = make_temp_ssa_name (type, NULL, ""); - gimple *assign = gimple_build_assign (temp, elem); - gimple_stmt_iterator gsi; - - gsi_insert_before (iter, assign, GSI_SAME_STMT); - gsi = gsi_for_stmt (assign); - - all_bounds[offs / POINTER_SIZE] = chkp_find_bounds (temp, &gsi); - } - } - else if (RECORD_OR_UNION_TYPE_P (type)) - { - tree field; - - for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - if (TREE_CODE (field) == FIELD_DECL) - { - tree base = unshare_expr (elem); - tree field_ref = chkp_build_component_ref (base, field); - HOST_WIDE_INT field_offs - = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)); - if (DECL_FIELD_OFFSET (field)) - field_offs += TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field)) * 8; - - chkp_find_bounds_for_elem (field_ref, all_bounds, - offs + field_offs, iter); - } - } - else if (TREE_CODE (type) == ARRAY_TYPE) - { - tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); - tree etype = TREE_TYPE (type); - HOST_WIDE_INT esize = TREE_INT_CST_LOW (TYPE_SIZE (etype)); - unsigned HOST_WIDE_INT cur; - - if (!maxval || integer_minus_onep (maxval)) - return; - - for (cur = 0; cur <= TREE_INT_CST_LOW (maxval); cur++) - { - tree base = unshare_expr (elem); - tree arr_elem = chkp_build_array_ref (base, etype, - TYPE_SIZE (etype), - cur); - chkp_find_bounds_for_elem (arr_elem, all_bounds, offs + cur * esize, - iter); - } - } -} - -/* Maximum number of elements to check in an array. */ - -#define CHKP_ARRAY_MAX_CHECK_STEPS 4096 - -/* Fill HAVE_BOUND output bitmap with information about - bounds requred for object of type TYPE. - - OFFS is used for recursive calls and holds basic - offset of TYPE in outer structure in bits. - - HAVE_BOUND[i] is set to 1 if there is a field - in TYPE which has pointer type and offset - equal to i * POINTER_SIZE - OFFS in bits. */ -void -chkp_find_bound_slots_1 (const_tree type, bitmap have_bound, - HOST_WIDE_INT offs) -{ - if (BOUNDED_TYPE_P (type)) - bitmap_set_bit (have_bound, offs / POINTER_SIZE); - else if (RECORD_OR_UNION_TYPE_P (type)) - { - tree field; - - for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - if (TREE_CODE (field) == FIELD_DECL) - { - HOST_WIDE_INT field_offs = 0; - if (DECL_FIELD_BIT_OFFSET (field)) - field_offs += TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)); - if (DECL_FIELD_OFFSET (field)) - field_offs += TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field)) * 8; - chkp_find_bound_slots_1 (TREE_TYPE (field), have_bound, - offs + field_offs); - } - } - else if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type)) - { - /* The object type is an array of complete type, i.e., other - than a flexible array. */ - tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); - tree etype = TREE_TYPE (type); - HOST_WIDE_INT esize = TREE_INT_CST_LOW (TYPE_SIZE (etype)); - unsigned HOST_WIDE_INT cur; - - if (!maxval - || TREE_CODE (maxval) != INTEGER_CST - || integer_minus_onep (maxval)) - return; - - for (cur = 0; - cur <= MIN (CHKP_ARRAY_MAX_CHECK_STEPS, TREE_INT_CST_LOW (maxval)); - cur++) - chkp_find_bound_slots_1 (etype, have_bound, offs + cur * esize); - } -} - -/* Fill bitmap RES with information about bounds for - type TYPE. See chkp_find_bound_slots_1 for more - details. */ -void -chkp_find_bound_slots (const_tree type, bitmap res) -{ - bitmap_clear (res); - chkp_find_bound_slots_1 (type, res, 0); -} - -/* Return 1 if call to FNDECL should be instrumented - and 0 otherwise. */ - -static bool -chkp_instrument_normal_builtin (tree fndecl) -{ - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_STRLEN: - case BUILT_IN_STRCPY: - case BUILT_IN_STRNCPY: - case BUILT_IN_STPCPY: - case BUILT_IN_STPNCPY: - case BUILT_IN_STRCAT: - case BUILT_IN_STRNCAT: - case BUILT_IN_MEMCPY: - case BUILT_IN_MEMPCPY: - case BUILT_IN_MEMSET: - case BUILT_IN_MEMMOVE: - case BUILT_IN_BZERO: - case BUILT_IN_STRCMP: - case BUILT_IN_STRNCMP: - case BUILT_IN_BCMP: - case BUILT_IN_MEMCMP: - case BUILT_IN_MEMCPY_CHK: - case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMMOVE_CHK: - case BUILT_IN_MEMSET_CHK: - case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRNCPY_CHK: - case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPNCPY_CHK: - case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRNCAT_CHK: - case BUILT_IN_MALLOC: - case BUILT_IN_CALLOC: - case BUILT_IN_REALLOC: - return 1; - - default: - return 0; - } -} - -/* Add bound arguments to call statement pointed by GSI. - Also performs a replacement of user checker builtins calls - with internal ones. */ - -static void -chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) -{ - gcall *call = as_a <gcall *> (gsi_stmt (*gsi)); - unsigned arg_no = 0; - tree fndecl = gimple_call_fndecl (call); - tree fntype; - tree first_formal_arg; - tree arg; - bool use_fntype = false; - tree op; - ssa_op_iter iter; - gcall *new_call; - - /* Do nothing for internal functions. */ - if (gimple_call_internal_p (call)) - return; - - fntype = TREE_TYPE (TREE_TYPE (gimple_call_fn (call))); - - /* Do nothing if back-end builtin is called. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) - return; - - /* Do nothing for some middle-end builtins. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_OBJECT_SIZE) - return; - - /* Do nothing for calls to not instrumentable functions. */ - if (fndecl && !chkp_instrumentable_p (fndecl)) - return; - - /* Ignore CHKP_INIT_PTR_BOUNDS, CHKP_NULL_PTR_BOUNDS - and CHKP_COPY_PTR_BOUNDS. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_INIT_PTR_BOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_NULL_PTR_BOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_COPY_PTR_BOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_SET_PTR_BOUNDS)) - return; - - /* Check user builtins are replaced with checks. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_LBOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_UBOUNDS - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_CHECK_PTR_BOUNDS)) - { - chkp_replace_address_check_builtin (gsi, integer_minus_one_node); - return; - } - - /* Check user builtins are replaced with bound extract. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_GET_PTR_LBOUND - || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_GET_PTR_UBOUND)) - { - chkp_replace_extract_builtin (gsi); - return; - } - - /* BUILT_IN_CHKP_NARROW_PTR_BOUNDS call is replaced with - target narrow bounds call. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_NARROW_PTR_BOUNDS) - { - tree arg = gimple_call_arg (call, 1); - tree bounds = chkp_find_bounds (arg, gsi); - - gimple_call_set_fndecl (call, chkp_narrow_bounds_fndecl); - gimple_call_set_arg (call, 1, bounds); - update_stmt (call); - - return; - } - - /* BUILT_IN_CHKP_STORE_PTR_BOUNDS call is replaced with - bndstx call. */ - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_STORE_PTR_BOUNDS) - { - tree addr = gimple_call_arg (call, 0); - tree ptr = gimple_call_arg (call, 1); - tree bounds = chkp_find_bounds (ptr, gsi); - gimple_stmt_iterator iter = gsi_for_stmt (call); - - chkp_build_bndstx (addr, ptr, bounds, gsi); - gsi_remove (&iter, true); - - return; - } - - if (!flag_chkp_instrument_calls) - return; - - /* We instrument only some subset of builtins. We also instrument - builtin calls to be inlined. */ - if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && !chkp_instrument_normal_builtin (fndecl)) - { - if (!lookup_attribute ("always_inline", DECL_ATTRIBUTES (fndecl))) - return; - - struct cgraph_node *clone = chkp_maybe_create_clone (fndecl); - if (!clone - || !gimple_has_body_p (clone->decl)) - return; - } - - /* If function decl is available then use it for - formal arguments list. Otherwise use function type. */ - if (fndecl - && DECL_ARGUMENTS (fndecl) - && gimple_call_fntype (call) == TREE_TYPE (fndecl)) - first_formal_arg = DECL_ARGUMENTS (fndecl); - else - { - first_formal_arg = TYPE_ARG_TYPES (fntype); - use_fntype = true; - } - - /* Fill vector of new call args. */ - vec<tree> new_args = vNULL; - new_args.create (gimple_call_num_args (call)); - arg = first_formal_arg; - for (arg_no = 0; arg_no < gimple_call_num_args (call); arg_no++) - { - tree call_arg = gimple_call_arg (call, arg_no); - tree type; - - /* Get arg type using formal argument description - or actual argument type. */ - if (arg) - if (use_fntype) - if (TREE_VALUE (arg) != void_type_node) - { - type = TREE_VALUE (arg); - arg = TREE_CHAIN (arg); - } - else - type = TREE_TYPE (call_arg); - else - { - type = TREE_TYPE (arg); - arg = TREE_CHAIN (arg); - } - else - type = TREE_TYPE (call_arg); - - new_args.safe_push (call_arg); - - if (BOUNDED_TYPE_P (type) - || pass_by_reference (NULL, TYPE_MODE (type), type, true)) - new_args.safe_push (chkp_find_bounds (call_arg, gsi)); - else if (chkp_type_has_pointer (type)) - { - HOST_WIDE_INT max_bounds - = TREE_INT_CST_LOW (TYPE_SIZE (type)) / POINTER_SIZE; - tree *all_bounds = (tree *)xmalloc (sizeof (tree) * max_bounds); - HOST_WIDE_INT bnd_no; - - memset (all_bounds, 0, sizeof (tree) * max_bounds); - - chkp_find_bounds_for_elem (call_arg, all_bounds, 0, gsi); - - for (bnd_no = 0; bnd_no < max_bounds; bnd_no++) - if (all_bounds[bnd_no]) - new_args.safe_push (all_bounds[bnd_no]); - - free (all_bounds); - } - } - - if (new_args.length () == gimple_call_num_args (call)) - new_call = call; - else - { - new_call = gimple_build_call_vec (gimple_op (call, 1), new_args); - gimple_call_set_lhs (new_call, gimple_call_lhs (call)); - gimple_call_copy_flags (new_call, call); - gimple_call_set_chain (new_call, gimple_call_chain (call)); - } - new_args.release (); - - /* For direct calls fndecl is replaced with instrumented version. */ - if (fndecl) - { - tree new_decl = chkp_maybe_create_clone (fndecl)->decl; - gimple_call_set_fndecl (new_call, new_decl); - /* In case of a type cast we should modify used function - type instead of using type of new fndecl. */ - if (gimple_call_fntype (call) != TREE_TYPE (fndecl)) - { - tree type = gimple_call_fntype (call); - type = chkp_copy_function_type_adding_bounds (type); - gimple_call_set_fntype (new_call, type); - } - else - gimple_call_set_fntype (new_call, TREE_TYPE (new_decl)); - } - /* For indirect call we should fix function pointer type if - pass some bounds. */ - else if (new_call != call) - { - tree type = gimple_call_fntype (call); - type = chkp_copy_function_type_adding_bounds (type); - gimple_call_set_fntype (new_call, type); - } - - /* replace old call statement with the new one. */ - if (call != new_call) - { - FOR_EACH_SSA_TREE_OPERAND (op, call, iter, SSA_OP_ALL_DEFS) - { - SSA_NAME_DEF_STMT (op) = new_call; - } - gsi_replace (gsi, new_call, true); - } - else - update_stmt (new_call); - - gimple_call_set_with_bounds (new_call, true); -} - -/* Return constant static bounds var with specified bounds LB and UB. - If such var does not exists then new var is created with specified NAME. */ -static tree -chkp_make_static_const_bounds (HOST_WIDE_INT lb, - HOST_WIDE_INT ub, - const char *name) -{ - tree id = get_identifier (name); - tree var; - varpool_node *node; - symtab_node *snode; - - var = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, - pointer_bounds_type_node); - TREE_STATIC (var) = 1; - TREE_PUBLIC (var) = 1; - - /* With LTO we may have constant bounds already in varpool. - Try to find it. */ - if ((snode = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (var)))) - { - /* We don't allow this symbol usage for non bounds. */ - if (snode->type != SYMTAB_VARIABLE - || !POINTER_BOUNDS_P (snode->decl)) - sorry ("-fcheck-pointer-bounds requires %qs " - "name for internal usage", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (var))); - - return snode->decl; - } - - TREE_USED (var) = 1; - TREE_READONLY (var) = 1; - TREE_ADDRESSABLE (var) = 0; - DECL_ARTIFICIAL (var) = 1; - DECL_READ_P (var) = 1; - DECL_INITIAL (var) = targetm.chkp_make_bounds_constant (lb, ub); - make_decl_one_only (var, DECL_ASSEMBLER_NAME (var)); - /* We may use this symbol during ctors generation in chkp_finish_file - when all symbols are emitted. Force output to avoid undefined - symbols in ctors. */ - node = varpool_node::get_create (var); - node->force_output = 1; - - varpool_node::finalize_decl (var); - - return var; -} - -/* Generate code to make bounds with specified lower bound LB and SIZE. - if AFTER is 1 then code is inserted after position pointed by ITER - otherwise code is inserted before position pointed by ITER. - If ITER is NULL then code is added to entry block. */ -static tree -chkp_make_bounds (tree lb, tree size, gimple_stmt_iterator *iter, bool after) -{ - gimple_seq seq; - gimple_stmt_iterator gsi; - gimple *stmt; - tree bounds; - - if (iter) - gsi = *iter; - else - gsi = gsi_start_bb (chkp_get_entry_block ()); - - seq = NULL; - - lb = chkp_force_gimple_call_op (lb, &seq); - size = chkp_force_gimple_call_op (size, &seq); - - stmt = gimple_build_call (chkp_bndmk_fndecl, 2, lb, size); - chkp_mark_stmt (stmt); - - bounds = chkp_get_tmp_reg (stmt); - gimple_call_set_lhs (stmt, bounds); - - gimple_seq_add_stmt (&seq, stmt); - - if (iter && after) - gsi_insert_seq_after (&gsi, seq, GSI_SAME_STMT); - else - gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Made bounds: "); - print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS); - if (iter) - { - fprintf (dump_file, " inserted before statement: "); - print_gimple_stmt (dump_file, gsi_stmt (*iter), 0, TDF_VOPS|TDF_MEMSYMS); - } - else - fprintf (dump_file, " at function entry\n"); - } - - /* update_stmt (stmt); */ - - return bounds; -} - -/* Return var holding zero bounds. */ -tree -chkp_get_zero_bounds_var (void) -{ - if (!chkp_zero_bounds_var) - chkp_zero_bounds_var - = chkp_make_static_const_bounds (0, -1, - CHKP_ZERO_BOUNDS_VAR_NAME); - return chkp_zero_bounds_var; -} - -/* Return var holding none bounds. */ -tree -chkp_get_none_bounds_var (void) -{ - if (!chkp_none_bounds_var) - chkp_none_bounds_var - = chkp_make_static_const_bounds (-1, 0, - CHKP_NONE_BOUNDS_VAR_NAME); - return chkp_none_bounds_var; -} - -/* Return SSA_NAME used to represent zero bounds. */ -static tree -chkp_get_zero_bounds (void) -{ - if (zero_bounds) - return zero_bounds; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Creating zero bounds..."); - - if ((flag_chkp_use_static_bounds && flag_chkp_use_static_const_bounds) - || flag_chkp_use_static_const_bounds > 0) - { - gimple_stmt_iterator gsi = gsi_start_bb (chkp_get_entry_block ()); - gimple *stmt; - - zero_bounds = chkp_get_tmp_reg (NULL); - stmt = gimple_build_assign (zero_bounds, chkp_get_zero_bounds_var ()); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); - } - else - zero_bounds = chkp_make_bounds (integer_zero_node, - integer_zero_node, - NULL, - false); - - return zero_bounds; -} - -/* Return SSA_NAME used to represent none bounds. */ -static tree -chkp_get_none_bounds (void) -{ - if (none_bounds) - return none_bounds; - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Creating none bounds..."); - - - if ((flag_chkp_use_static_bounds && flag_chkp_use_static_const_bounds) - || flag_chkp_use_static_const_bounds > 0) - { - gimple_stmt_iterator gsi = gsi_start_bb (chkp_get_entry_block ()); - gimple *stmt; - - none_bounds = chkp_get_tmp_reg (NULL); - stmt = gimple_build_assign (none_bounds, chkp_get_none_bounds_var ()); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); - } - else - none_bounds = chkp_make_bounds (integer_minus_one_node, - build_int_cst (size_type_node, 2), - NULL, - false); - - return none_bounds; -} - -/* Return bounds to be used as a result of operation which - should not create poiunter (e.g. MULT_EXPR). */ -static tree -chkp_get_invalid_op_bounds (void) -{ - return chkp_get_zero_bounds (); -} - -/* Return bounds to be used for loads of non-pointer values. */ -static tree -chkp_get_nonpointer_load_bounds (void) -{ - return chkp_get_zero_bounds (); -} - -/* Return 1 if may use bndret call to get bounds for pointer - returned by CALL. */ -static bool -chkp_call_returns_bounds_p (gcall *call) -{ - if (gimple_call_internal_p (call)) - { - if (gimple_call_internal_fn (call) == IFN_VA_ARG) - return true; - return false; - } - - if (gimple_call_builtin_p (call, BUILT_IN_CHKP_NARROW_PTR_BOUNDS) - || chkp_gimple_call_builtin_p (call, BUILT_IN_CHKP_NARROW)) - return true; - - if (gimple_call_with_bounds_p (call)) - return true; - - tree fndecl = gimple_call_fndecl (call); - - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) - return false; - - if (fndecl && !chkp_instrumentable_p (fndecl)) - return false; - - if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) - { - if (chkp_instrument_normal_builtin (fndecl)) - return true; - - if (!lookup_attribute ("always_inline", DECL_ATTRIBUTES (fndecl))) - return false; - - struct cgraph_node *clone = chkp_maybe_create_clone (fndecl); - return (clone && gimple_has_body_p (clone->decl)); - } - - return true; -} - -/* Build bounds returned by CALL. */ -static tree -chkp_build_returned_bound (gcall *call) -{ - gimple_stmt_iterator gsi; - tree bounds; - gimple *stmt; - tree fndecl = gimple_call_fndecl (call); - unsigned int retflags; - tree lhs = gimple_call_lhs (call); - - /* To avoid fixing alloca expands in targets we handle - it separately. */ - if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (fndecl))) - { - tree size = gimple_call_arg (call, 0); - gimple_stmt_iterator iter = gsi_for_stmt (call); - bounds = chkp_make_bounds (lhs, size, &iter, true); - } - /* We know bounds returned by set_bounds builtin call. */ - else if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_SET_PTR_BOUNDS) - { - tree lb = gimple_call_arg (call, 0); - tree size = gimple_call_arg (call, 1); - gimple_stmt_iterator iter = gsi_for_stmt (call); - bounds = chkp_make_bounds (lb, size, &iter, true); - } - /* Detect bounds initialization calls. */ - else if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_INIT_PTR_BOUNDS) - bounds = chkp_get_zero_bounds (); - /* Detect bounds nullification calls. */ - else if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_NULL_PTR_BOUNDS) - bounds = chkp_get_none_bounds (); - /* Detect bounds copy calls. */ - else if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_COPY_PTR_BOUNDS) - { - gimple_stmt_iterator iter = gsi_for_stmt (call); - bounds = chkp_find_bounds (gimple_call_arg (call, 1), &iter); - } - /* Do not use retbnd when returned bounds are equal to some - of passed bounds. */ - else if (((retflags = gimple_call_return_flags (call)) & ERF_RETURNS_ARG) - && (retflags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (call)) - { - gimple_stmt_iterator iter = gsi_for_stmt (call); - unsigned int retarg = retflags & ERF_RETURN_ARG_MASK, argno; - if (gimple_call_with_bounds_p (call)) - { - for (argno = 0; argno < gimple_call_num_args (call); argno++) - if (!POINTER_BOUNDS_P (gimple_call_arg (call, argno))) - { - if (retarg) - retarg--; - else - break; - } - } - else - argno = retarg; - - bounds = chkp_find_bounds (gimple_call_arg (call, argno), &iter); - } - else if (chkp_call_returns_bounds_p (call) - && BOUNDED_P (lhs)) - { - gcc_assert (TREE_CODE (lhs) == SSA_NAME); - - /* In general case build checker builtin call to - obtain returned bounds. */ - stmt = gimple_build_call (chkp_ret_bnd_fndecl, 1, - gimple_call_lhs (call)); - chkp_mark_stmt (stmt); - - gsi = gsi_for_stmt (call); - gsi_insert_after (&gsi, stmt, GSI_SAME_STMT); - - bounds = chkp_get_tmp_reg (stmt); - gimple_call_set_lhs (stmt, bounds); - - update_stmt (stmt); - } - else - bounds = chkp_get_zero_bounds (); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Built returned bounds ("); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, ") for call: "); - print_gimple_stmt (dump_file, call, 0, TDF_VOPS | TDF_MEMSYMS); - } - - bounds = chkp_maybe_copy_and_register_bounds (lhs, bounds); - - return bounds; -} - -/* Return bounds used as returned by call - which produced SSA name VAL. */ -gcall * -chkp_retbnd_call_by_val (tree val) -{ - if (TREE_CODE (val) != SSA_NAME) - return NULL; - - gcc_assert (gimple_code (SSA_NAME_DEF_STMT (val)) == GIMPLE_CALL); - - imm_use_iterator use_iter; - use_operand_p use_p; - FOR_EACH_IMM_USE_FAST (use_p, use_iter, val) - if (chkp_gimple_call_builtin_p (USE_STMT (use_p), BUILT_IN_CHKP_BNDRET)) - return as_a <gcall *> (USE_STMT (use_p)); - - return NULL; -} - -/* Check the next parameter for the given PARM is bounds - and return it's default SSA_NAME (create if required). */ -static tree -chkp_get_next_bounds_parm (tree parm) -{ - tree bounds = TREE_CHAIN (parm); - gcc_assert (POINTER_BOUNDS_P (bounds)); - bounds = ssa_default_def (cfun, bounds); - if (!bounds) - { - bounds = make_ssa_name (TREE_CHAIN (parm), gimple_build_nop ()); - set_ssa_default_def (cfun, TREE_CHAIN (parm), bounds); - } - return bounds; -} - -/* Return bounds to be used for input argument PARM. */ -static tree -chkp_get_bound_for_parm (tree parm) -{ - tree decl = SSA_NAME_VAR (parm); - tree bounds; - - gcc_assert (TREE_CODE (decl) == PARM_DECL); - - bounds = chkp_get_registered_bounds (parm); - - if (!bounds) - bounds = chkp_get_registered_bounds (decl); - - if (!bounds) - { - tree orig_decl = cgraph_node::get (cfun->decl)->orig_decl; - - /* For static chain param we return zero bounds - because currently we do not check dereferences - of this pointer. */ - if (cfun->static_chain_decl == decl) - bounds = chkp_get_zero_bounds (); - /* If non instrumented runtime is used then it may be useful - to use zero bounds for input arguments of main - function. */ - else if (flag_chkp_zero_input_bounds_for_main - && id_equal (DECL_ASSEMBLER_NAME (orig_decl), "main")) - bounds = chkp_get_zero_bounds (); - else if (BOUNDED_P (parm)) - { - bounds = chkp_get_next_bounds_parm (decl); - bounds = chkp_maybe_copy_and_register_bounds (decl, bounds); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Built arg bounds ("); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, ") for arg: "); - print_node (dump_file, "", decl, 0); - } - } - else - bounds = chkp_get_zero_bounds (); - } - - if (!chkp_get_registered_bounds (parm)) - bounds = chkp_maybe_copy_and_register_bounds (parm, bounds); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Using bounds "); - print_generic_expr (dump_file, bounds); - fprintf (dump_file, " for parm "); - print_generic_expr (dump_file, parm); - fprintf (dump_file, " of type "); - print_generic_expr (dump_file, TREE_TYPE (parm)); - fprintf (dump_file, ".\n"); - } - - return bounds; -} - -/* Build and return CALL_EXPR for bndstx builtin with specified - arguments. */ -tree -chkp_build_bndldx_call (tree addr, tree ptr) -{ - tree fn = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (chkp_bndldx_fndecl)), - chkp_bndldx_fndecl); - tree call = build_call_nary (TREE_TYPE (TREE_TYPE (chkp_bndldx_fndecl)), - fn, 2, addr, ptr); - CALL_WITH_BOUNDS_P (call) = true; - return call; -} - -/* Insert code to load bounds for PTR located by ADDR. - Code is inserted after position pointed by GSI. - Loaded bounds are returned. */ -static tree -chkp_build_bndldx (tree addr, tree ptr, gimple_stmt_iterator *gsi) -{ - gimple_seq seq; - gimple *stmt; - tree bounds; - - seq = NULL; - - addr = chkp_force_gimple_call_op (addr, &seq); - ptr = chkp_force_gimple_call_op (ptr, &seq); - - stmt = gimple_build_call (chkp_bndldx_fndecl, 2, addr, ptr); - chkp_mark_stmt (stmt); - bounds = chkp_get_tmp_reg (stmt); - gimple_call_set_lhs (stmt, bounds); - - gimple_seq_add_stmt (&seq, stmt); - - gsi_insert_seq_after (gsi, seq, GSI_CONTINUE_LINKING); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Generated bndldx for pointer "); - print_generic_expr (dump_file, ptr); - fprintf (dump_file, ": "); - print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS | TDF_MEMSYMS); - } - - return bounds; -} - -/* Build and return CALL_EXPR for bndstx builtin with specified - arguments. */ -tree -chkp_build_bndstx_call (tree addr, tree ptr, tree bounds) -{ - tree fn = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (chkp_bndstx_fndecl)), - chkp_bndstx_fndecl); - tree call = build_call_nary (TREE_TYPE (TREE_TYPE (chkp_bndstx_fndecl)), - fn, 3, ptr, bounds, addr); - CALL_WITH_BOUNDS_P (call) = true; - return call; -} - -/* Insert code to store BOUNDS for PTR stored by ADDR. - New statements are inserted after position pointed - by GSI. */ -void -chkp_build_bndstx (tree addr, tree ptr, tree bounds, - gimple_stmt_iterator *gsi) -{ - gimple_seq seq; - gimple *stmt; - - seq = NULL; - - addr = chkp_force_gimple_call_op (addr, &seq); - ptr = chkp_force_gimple_call_op (ptr, &seq); - - stmt = gimple_build_call (chkp_bndstx_fndecl, 3, ptr, bounds, addr); - chkp_mark_stmt (stmt); - gimple_call_set_with_bounds (stmt, true); - - gimple_seq_add_stmt (&seq, stmt); - - gsi_insert_seq_after (gsi, seq, GSI_CONTINUE_LINKING); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Generated bndstx for pointer store "); - print_gimple_stmt (dump_file, gsi_stmt (*gsi), 0, TDF_VOPS|TDF_MEMSYMS); - print_gimple_stmt (dump_file, stmt, 2, TDF_VOPS|TDF_MEMSYMS); - } -} - -/* This function is called when call statement - is inlined and therefore we can't use bndret - for its LHS anymore. Function fixes bndret - call using new RHS value if possible. */ -void -chkp_fixup_inlined_call (tree lhs, tree rhs) -{ - tree addr, bounds; - gcall *retbnd, *bndldx; - - if (!BOUNDED_P (lhs)) - return; - - /* Search for retbnd call. */ - retbnd = chkp_retbnd_call_by_val (lhs); - if (!retbnd) - return; - - /* Currently only handle cases when call is replaced - with a memory access. In this case bndret call - may be replaced with bndldx call. Otherwise we - have to search for bounds which may cause wrong - result due to various optimizations applied. */ - switch (TREE_CODE (rhs)) - { - case VAR_DECL: - if (DECL_REGISTER (rhs)) - return; - break; - - case MEM_REF: - break; - - case ARRAY_REF: - case COMPONENT_REF: - addr = get_base_address (rhs); - if (!DECL_P (addr) - && TREE_CODE (addr) != MEM_REF) - return; - if (DECL_P (addr) && DECL_REGISTER (addr)) - return; - break; - - default: - return; - } - - /* Create a new statements sequence with bndldx call. */ - gimple_stmt_iterator gsi = gsi_for_stmt (retbnd); - addr = build_fold_addr_expr (rhs); - chkp_build_bndldx (addr, lhs, &gsi); - bndldx = as_a <gcall *> (gsi_stmt (gsi)); - - /* Remove bndret call. */ - bounds = gimple_call_lhs (retbnd); - gsi = gsi_for_stmt (retbnd); - gsi_remove (&gsi, true); - - /* Link new bndldx call. */ - gimple_call_set_lhs (bndldx, bounds); - update_stmt (bndldx); -} - -/* Compute bounds for pointer NODE which was assigned in - assignment statement ASSIGN. Return computed bounds. */ -static tree -chkp_compute_bounds_for_assignment (tree node, gimple *assign) -{ - enum tree_code rhs_code = gimple_assign_rhs_code (assign); - tree rhs1 = gimple_assign_rhs1 (assign); - tree bounds = NULL_TREE; - gimple_stmt_iterator iter = gsi_for_stmt (assign); - tree base = NULL; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Computing bounds for assignment: "); - print_gimple_stmt (dump_file, assign, 0, TDF_VOPS|TDF_MEMSYMS); - } - - switch (rhs_code) - { - case MEM_REF: - case TARGET_MEM_REF: - case COMPONENT_REF: - case ARRAY_REF: - /* We need to load bounds from the bounds table. */ - bounds = chkp_find_bounds_loaded (node, rhs1, &iter); - break; - - case VAR_DECL: - case SSA_NAME: - case ADDR_EXPR: - case POINTER_PLUS_EXPR: - case NOP_EXPR: - case CONVERT_EXPR: - case INTEGER_CST: - /* Bounds are just propagated from RHS. */ - bounds = chkp_find_bounds (rhs1, &iter); - base = rhs1; - break; - - case VIEW_CONVERT_EXPR: - /* Bounds are just propagated from RHS. */ - bounds = chkp_find_bounds (TREE_OPERAND (rhs1, 0), &iter); - break; - - case PARM_DECL: - if (BOUNDED_P (rhs1)) - { - /* We need to load bounds from the bounds table. */ - bounds = chkp_build_bndldx (chkp_build_addr_expr (rhs1), - node, &iter); - TREE_ADDRESSABLE (rhs1) = 1; - } - else - bounds = chkp_get_nonpointer_load_bounds (); - break; - - case MINUS_EXPR: - case PLUS_EXPR: - case BIT_AND_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - { - tree rhs2 = gimple_assign_rhs2 (assign); - tree bnd1 = chkp_find_bounds (rhs1, &iter); - tree bnd2 = chkp_find_bounds (rhs2, &iter); - - /* First we try to check types of operands. If it - does not help then look at bound values. - - If some bounds are incomplete and other are - not proven to be valid (i.e. also incomplete - or invalid because value is not pointer) then - resulting value is incomplete and will be - recomputed later in chkp_finish_incomplete_bounds. */ - if (BOUNDED_P (rhs1) - && !BOUNDED_P (rhs2)) - bounds = bnd1; - else if (BOUNDED_P (rhs2) - && !BOUNDED_P (rhs1) - && rhs_code != MINUS_EXPR) - bounds = bnd2; - else if (chkp_incomplete_bounds (bnd1)) - if (chkp_valid_bounds (bnd2) && rhs_code != MINUS_EXPR - && !chkp_incomplete_bounds (bnd2)) - bounds = bnd2; - else - bounds = incomplete_bounds; - else if (chkp_incomplete_bounds (bnd2)) - if (chkp_valid_bounds (bnd1) - && !chkp_incomplete_bounds (bnd1)) - bounds = bnd1; - else - bounds = incomplete_bounds; - else if (!chkp_valid_bounds (bnd1)) - if (chkp_valid_bounds (bnd2) && rhs_code != MINUS_EXPR) - bounds = bnd2; - else if (bnd2 == chkp_get_zero_bounds ()) - bounds = bnd2; - else - bounds = bnd1; - else if (!chkp_valid_bounds (bnd2)) - bounds = bnd1; - else - /* Seems both operands may have valid bounds - (e.g. pointer minus pointer). In such case - use default invalid op bounds. */ - bounds = chkp_get_invalid_op_bounds (); - - base = (bounds == bnd1) ? rhs1 : (bounds == bnd2) ? rhs2 : NULL; - } - break; - - case BIT_NOT_EXPR: - case NEGATE_EXPR: - case LSHIFT_EXPR: - case RSHIFT_EXPR: - case LROTATE_EXPR: - case RROTATE_EXPR: - case EQ_EXPR: - case NE_EXPR: - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case MULT_EXPR: - case RDIV_EXPR: - case TRUNC_DIV_EXPR: - case FLOOR_DIV_EXPR: - case CEIL_DIV_EXPR: - case ROUND_DIV_EXPR: - case TRUNC_MOD_EXPR: - case FLOOR_MOD_EXPR: - case CEIL_MOD_EXPR: - case ROUND_MOD_EXPR: - case EXACT_DIV_EXPR: - case FIX_TRUNC_EXPR: - case FLOAT_EXPR: - case REALPART_EXPR: - case IMAGPART_EXPR: - case POINTER_DIFF_EXPR: - /* No valid bounds may be produced by these exprs. */ - bounds = chkp_get_invalid_op_bounds (); - break; - - case COND_EXPR: - { - tree val1 = gimple_assign_rhs2 (assign); - tree val2 = gimple_assign_rhs3 (assign); - tree bnd1 = chkp_find_bounds (val1, &iter); - tree bnd2 = chkp_find_bounds (val2, &iter); - gimple *stmt; - - if (chkp_incomplete_bounds (bnd1) || chkp_incomplete_bounds (bnd2)) - bounds = incomplete_bounds; - else if (bnd1 == bnd2) - bounds = bnd1; - else - { - rhs1 = unshare_expr (rhs1); - - bounds = chkp_get_tmp_reg (assign); - stmt = gimple_build_assign (bounds, COND_EXPR, rhs1, bnd1, bnd2); - gsi_insert_after (&iter, stmt, GSI_SAME_STMT); - - if (!chkp_valid_bounds (bnd1) && !chkp_valid_bounds (bnd2)) - chkp_mark_invalid_bounds (bounds); - } - } - break; - - case MAX_EXPR: - case MIN_EXPR: - { - tree rhs2 = gimple_assign_rhs2 (assign); - tree bnd1 = chkp_find_bounds (rhs1, &iter); - tree bnd2 = chkp_find_bounds (rhs2, &iter); - - if (chkp_incomplete_bounds (bnd1) || chkp_incomplete_bounds (bnd2)) - bounds = incomplete_bounds; - else if (bnd1 == bnd2) - bounds = bnd1; - else - { - gimple *stmt; - tree cond = build2 (rhs_code == MAX_EXPR ? GT_EXPR : LT_EXPR, - boolean_type_node, rhs1, rhs2); - bounds = chkp_get_tmp_reg (assign); - stmt = gimple_build_assign (bounds, COND_EXPR, cond, bnd1, bnd2); - - gsi_insert_after (&iter, stmt, GSI_SAME_STMT); - - if (!chkp_valid_bounds (bnd1) && !chkp_valid_bounds (bnd2)) - chkp_mark_invalid_bounds (bounds); - } - } - break; - - default: - bounds = chkp_get_zero_bounds (); - warning (0, "pointer bounds were lost due to unexpected expression %s", - get_tree_code_name (rhs_code)); - } - - gcc_assert (bounds); - - /* We may reuse bounds of other pointer we copy/modify. But it is not - allowed for abnormal ssa names. If we produced a pointer using - abnormal ssa name, we better make a bounds copy to avoid coalescing - issues. */ - if (base - && TREE_CODE (base) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (base)) - { - gimple *stmt = gimple_build_assign (chkp_get_tmp_reg (NULL), bounds); - gsi_insert_after (&iter, stmt, GSI_SAME_STMT); - bounds = gimple_assign_lhs (stmt); - } - - if (node) - bounds = chkp_maybe_copy_and_register_bounds (node, bounds); - - return bounds; -} - -/* Compute bounds for ssa name NODE defined by DEF_STMT pointed by ITER. - - There are just few statement codes allowed: NOP (for default ssa names), - ASSIGN, CALL, PHI, ASM. - - Return computed bounds. */ -static tree -chkp_get_bounds_by_definition (tree node, gimple *def_stmt, - gphi_iterator *iter) -{ - tree var, bounds; - enum gimple_code code = gimple_code (def_stmt); - gphi *stmt; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Searching for bounds for node: "); - print_generic_expr (dump_file, node); - - fprintf (dump_file, " using its definition: "); - print_gimple_stmt (dump_file, def_stmt, 0, TDF_VOPS | TDF_MEMSYMS); - } - - switch (code) - { - case GIMPLE_NOP: - var = SSA_NAME_VAR (node); - switch (TREE_CODE (var)) - { - case PARM_DECL: - bounds = chkp_get_bound_for_parm (node); - break; - - case VAR_DECL: - /* For uninitialized pointers use none bounds. */ - bounds = chkp_get_none_bounds (); - bounds = chkp_maybe_copy_and_register_bounds (node, bounds); - break; - - case RESULT_DECL: - { - tree base_type; - - gcc_assert (TREE_CODE (TREE_TYPE (node)) == REFERENCE_TYPE); - - base_type = TREE_TYPE (TREE_TYPE (node)); - - gcc_assert (TYPE_SIZE (base_type) - && TREE_CODE (TYPE_SIZE (base_type)) == INTEGER_CST - && tree_to_uhwi (TYPE_SIZE (base_type)) != 0); - - bounds = chkp_make_bounds (node, TYPE_SIZE_UNIT (base_type), - NULL, false); - bounds = chkp_maybe_copy_and_register_bounds (node, bounds); - } - break; - - default: - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Unexpected var with no definition\n"); - print_generic_expr (dump_file, var); - } - internal_error ("chkp_get_bounds_by_definition: Unexpected var of type %s", - get_tree_code_name (TREE_CODE (var))); - } - break; - - case GIMPLE_ASSIGN: - bounds = chkp_compute_bounds_for_assignment (node, def_stmt); - break; - - case GIMPLE_CALL: - bounds = chkp_build_returned_bound (as_a <gcall *> (def_stmt)); - break; - - case GIMPLE_PHI: - if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node)) - if (SSA_NAME_VAR (node)) - var = chkp_get_bounds_var (SSA_NAME_VAR (node)); - else - var = make_temp_ssa_name (pointer_bounds_type_node, - NULL, - CHKP_BOUND_TMP_NAME); - else - var = chkp_get_tmp_var (); - stmt = create_phi_node (var, gimple_bb (def_stmt)); - bounds = gimple_phi_result (stmt); - *iter = gsi_for_phi (stmt); - - bounds = chkp_maybe_copy_and_register_bounds (node, bounds); - - /* Created bounds do not have all phi args computed and - therefore we do not know if there is a valid source - of bounds for that node. Therefore we mark bounds - as incomplete and then recompute them when all phi - args are computed. */ - chkp_register_incomplete_bounds (bounds, node); - break; - - case GIMPLE_ASM: - bounds = chkp_get_zero_bounds (); - bounds = chkp_maybe_copy_and_register_bounds (node, bounds); - break; - - default: - internal_error ("chkp_get_bounds_by_definition: Unexpected GIMPLE code %s", - gimple_code_name[code]); - } - - return bounds; -} - -/* Return CALL_EXPR for bndmk with specified LOWER_BOUND and SIZE. */ -tree -chkp_build_make_bounds_call (tree lower_bound, tree size) -{ - tree call = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (chkp_bndmk_fndecl)), - chkp_bndmk_fndecl); - return build_call_nary (TREE_TYPE (TREE_TYPE (chkp_bndmk_fndecl)), - call, 2, lower_bound, size); -} - -/* Create static bounds var of specfified OBJ which is - is either VAR_DECL or string constant. */ -static tree -chkp_make_static_bounds (tree obj) -{ - static int string_id = 1; - static int var_id = 1; - tree *slot; - const char *var_name; - char *bnd_var_name; - tree bnd_var; - - /* First check if we already have required var. */ - if (chkp_static_var_bounds) - { - /* For vars we use assembler name as a key in - chkp_static_var_bounds map. It allows to - avoid duplicating bound vars for decls - sharing assembler name. */ - if (VAR_P (obj)) - { - tree name = DECL_ASSEMBLER_NAME (obj); - slot = chkp_static_var_bounds->get (name); - if (slot) - return *slot; - } - else - { - slot = chkp_static_var_bounds->get (obj); - if (slot) - return *slot; - } - } - - /* Build decl for bounds var. */ - if (VAR_P (obj)) - { - if (DECL_IGNORED_P (obj)) - { - bnd_var_name = (char *) xmalloc (strlen (CHKP_VAR_BOUNDS_PREFIX) + 10); - sprintf (bnd_var_name, "%s%d", CHKP_VAR_BOUNDS_PREFIX, var_id++); - } - else - { - var_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (obj)); - - /* For hidden symbols we want to skip first '*' char. */ - if (*var_name == '*') - var_name++; - - bnd_var_name = (char *) xmalloc (strlen (var_name) - + strlen (CHKP_BOUNDS_OF_SYMBOL_PREFIX) + 1); - strcpy (bnd_var_name, CHKP_BOUNDS_OF_SYMBOL_PREFIX); - strcat (bnd_var_name, var_name); - } - - bnd_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, - get_identifier (bnd_var_name), - pointer_bounds_type_node); - - /* Address of the obj will be used as lower bound. */ - TREE_ADDRESSABLE (obj) = 1; - } - else - { - bnd_var_name = (char *) xmalloc (strlen (CHKP_STRING_BOUNDS_PREFIX) + 10); - sprintf (bnd_var_name, "%s%d", CHKP_STRING_BOUNDS_PREFIX, string_id++); - - bnd_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, - get_identifier (bnd_var_name), - pointer_bounds_type_node); - } - - free (bnd_var_name); - - TREE_PUBLIC (bnd_var) = 0; - TREE_USED (bnd_var) = 1; - TREE_READONLY (bnd_var) = 0; - TREE_STATIC (bnd_var) = 1; - TREE_ADDRESSABLE (bnd_var) = 0; - DECL_ARTIFICIAL (bnd_var) = 1; - DECL_COMMON (bnd_var) = 1; - DECL_COMDAT (bnd_var) = 1; - DECL_READ_P (bnd_var) = 1; - DECL_INITIAL (bnd_var) = chkp_build_addr_expr (obj); - /* Force output similar to constant bounds. - See chkp_make_static_const_bounds. */ - varpool_node::get_create (bnd_var)->force_output = 1; - /* Mark symbol as requiring bounds initialization. */ - varpool_node::get_create (bnd_var)->need_bounds_init = 1; - varpool_node::finalize_decl (bnd_var); - - /* Add created var to the map to use it for other references - to obj. */ - if (!chkp_static_var_bounds) - chkp_static_var_bounds = new hash_map<tree, tree>; - - if (VAR_P (obj)) - { - tree name = DECL_ASSEMBLER_NAME (obj); - chkp_static_var_bounds->put (name, bnd_var); - } - else - chkp_static_var_bounds->put (obj, bnd_var); - - return bnd_var; -} - -/* When var has incomplete type we cannot get size to - compute its bounds. In such cases we use checker - builtin call which determines object size at runtime. */ -static tree -chkp_generate_extern_var_bounds (tree var) -{ - tree bounds, size_reloc, lb, size, max_size, cond; - gimple_stmt_iterator gsi; - gimple_seq seq = NULL; - gimple *stmt; - - /* If instrumentation is not enabled for vars having - incomplete type then just return zero bounds to avoid - checks for this var. */ - if (!flag_chkp_incomplete_type) - return chkp_get_zero_bounds (); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Generating bounds for extern symbol '"); - print_generic_expr (dump_file, var); - fprintf (dump_file, "'\n"); - } - - stmt = gimple_build_call (chkp_sizeof_fndecl, 1, var); - - size_reloc = create_tmp_reg (chkp_uintptr_type, CHKP_SIZE_TMP_NAME); - gimple_call_set_lhs (stmt, size_reloc); - - gimple_seq_add_stmt (&seq, stmt); - - lb = chkp_build_addr_expr (var); - size = make_ssa_name (chkp_get_size_tmp_var ()); - - if (flag_chkp_zero_dynamic_size_as_infinite) - { - /* We should check that size relocation was resolved. - If it was not then use maximum possible size for the var. */ - max_size = build2 (MINUS_EXPR, chkp_uintptr_type, integer_zero_node, - fold_convert (chkp_uintptr_type, lb)); - max_size = chkp_force_gimple_call_op (max_size, &seq); - - cond = build2 (NE_EXPR, boolean_type_node, - size_reloc, integer_zero_node); - stmt = gimple_build_assign (size, COND_EXPR, cond, size_reloc, max_size); - gimple_seq_add_stmt (&seq, stmt); - } - else - { - stmt = gimple_build_assign (size, size_reloc); - gimple_seq_add_stmt (&seq, stmt); - } - - gsi = gsi_start_bb (chkp_get_entry_block ()); - gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING); - - bounds = chkp_make_bounds (lb, size, &gsi, true); - - return bounds; -} - -/* Return 1 if TYPE has fields with zero size or fields - marked with chkp_variable_size attribute. */ -bool -chkp_variable_size_type (tree type) -{ - bool res = false; - tree field; - - if (RECORD_OR_UNION_TYPE_P (type)) - for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - { - if (TREE_CODE (field) == FIELD_DECL) - res = res - || lookup_attribute ("bnd_variable_size", DECL_ATTRIBUTES (field)) - || chkp_variable_size_type (TREE_TYPE (field)); - } - else - res = !TYPE_SIZE (type) - || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST - || tree_to_uhwi (TYPE_SIZE (type)) == 0; - - return res; -} - -/* Compute and return bounds for address of DECL which is - one of VAR_DECL, PARM_DECL, RESULT_DECL. */ -static tree -chkp_get_bounds_for_decl_addr (tree decl) -{ - tree bounds; - - gcc_assert (VAR_P (decl) - || TREE_CODE (decl) == PARM_DECL - || TREE_CODE (decl) == RESULT_DECL); - - bounds = chkp_get_registered_addr_bounds (decl); - - if (bounds) - return bounds; - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Building bounds for address of decl "); - print_generic_expr (dump_file, decl); - fprintf (dump_file, "\n"); - } - - /* Use zero bounds if size is unknown and checks for - unknown sizes are restricted. */ - if ((!DECL_SIZE (decl) - || (chkp_variable_size_type (TREE_TYPE (decl)) - && (TREE_STATIC (decl) - || DECL_EXTERNAL (decl) - || TREE_PUBLIC (decl)))) - && !flag_chkp_incomplete_type) - return chkp_get_zero_bounds (); - - if (VOID_TYPE_P (TREE_TYPE (decl))) - return chkp_get_zero_bounds (); - - if (flag_chkp_use_static_bounds - && VAR_P (decl) - && (TREE_STATIC (decl) - || DECL_EXTERNAL (decl) - || TREE_PUBLIC (decl)) - && !DECL_THREAD_LOCAL_P (decl)) - { - tree bnd_var = chkp_make_static_bounds (decl); - gimple_stmt_iterator gsi = gsi_start_bb (chkp_get_entry_block ()); - gimple *stmt; - - bounds = chkp_get_tmp_reg (NULL); - stmt = gimple_build_assign (bounds, bnd_var); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); - } - else if (!DECL_SIZE (decl) - || (chkp_variable_size_type (TREE_TYPE (decl)) - && (TREE_STATIC (decl) - || DECL_EXTERNAL (decl) - || TREE_PUBLIC (decl)))) - { - gcc_assert (VAR_P (decl)); - bounds = chkp_generate_extern_var_bounds (decl); - } - else - { - tree lb = chkp_build_addr_expr (decl); - bounds = chkp_make_bounds (lb, DECL_SIZE_UNIT (decl), NULL, false); - } - - return bounds; -} - -/* Compute and return bounds for constant string. */ -static tree -chkp_get_bounds_for_string_cst (tree cst) -{ - tree bounds; - tree lb; - tree size; - - gcc_assert (TREE_CODE (cst) == STRING_CST); - - bounds = chkp_get_registered_bounds (cst); - - if (bounds) - return bounds; - - if ((flag_chkp_use_static_bounds && flag_chkp_use_static_const_bounds) - || flag_chkp_use_static_const_bounds > 0) - { - tree bnd_var = chkp_make_static_bounds (cst); - gimple_stmt_iterator gsi = gsi_start_bb (chkp_get_entry_block ()); - gimple *stmt; - - bounds = chkp_get_tmp_reg (NULL); - stmt = gimple_build_assign (bounds, bnd_var); - gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); - } - else - { - lb = chkp_build_addr_expr (cst); - size = build_int_cst (chkp_uintptr_type, TREE_STRING_LENGTH (cst)); - bounds = chkp_make_bounds (lb, size, NULL, false); - } - - bounds = chkp_maybe_copy_and_register_bounds (cst, bounds); - - return bounds; -} - -/* Generate code to instersect bounds BOUNDS1 and BOUNDS2 and - return the result. if ITER is not NULL then Code is inserted - before position pointed by ITER. Otherwise code is added to - entry block. */ -static tree -chkp_intersect_bounds (tree bounds1, tree bounds2, gimple_stmt_iterator *iter) -{ - if (!bounds1 || bounds1 == chkp_get_zero_bounds ()) - return bounds2 ? bounds2 : bounds1; - else if (!bounds2 || bounds2 == chkp_get_zero_bounds ()) - return bounds1; - else - { - gimple_seq seq; - gimple *stmt; - tree bounds; - - seq = NULL; - - stmt = gimple_build_call (chkp_intersect_fndecl, 2, bounds1, bounds2); - chkp_mark_stmt (stmt); - - bounds = chkp_get_tmp_reg (stmt); - gimple_call_set_lhs (stmt, bounds); - - gimple_seq_add_stmt (&seq, stmt); - - /* We are probably doing narrowing for constant expression. - In such case iter may be undefined. */ - if (!iter) - { - gimple_stmt_iterator gsi = gsi_last_bb (chkp_get_entry_block ()); - iter = &gsi; - gsi_insert_seq_after (iter, seq, GSI_SAME_STMT); - } - else - gsi_insert_seq_before (iter, seq, GSI_SAME_STMT); - - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Bounds intersection: "); - print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS); - fprintf (dump_file, " inserted before statement: "); - print_gimple_stmt (dump_file, gsi_stmt (*iter), 0, - TDF_VOPS|TDF_MEMSYMS); - } - - return bounds; - } -} - -/* Return 1 if we are allowed to narrow bounds for addressed FIELD - and 0 othersize. REF is reference to the field. */ - -static bool -chkp_may_narrow_to_field (tree ref, tree field) -{ - return DECL_SIZE (field) && TREE_CODE (DECL_SIZE (field)) == INTEGER_CST - && tree_to_uhwi (DECL_SIZE (field)) != 0 - && !(flag_chkp_flexible_struct_trailing_arrays - && array_at_struct_end_p (ref)) - && (!DECL_FIELD_OFFSET (field) - || TREE_CODE (DECL_FIELD_OFFSET (field)) == INTEGER_CST) - && (!DECL_FIELD_BIT_OFFSET (field) - || TREE_CODE (DECL_FIELD_BIT_OFFSET (field)) == INTEGER_CST) - && !lookup_attribute ("bnd_variable_size", DECL_ATTRIBUTES (field)) - && !chkp_variable_size_type (TREE_TYPE (field)); -} - -/* Return 1 if bounds for FIELD should be narrowed to - field's own size. REF is reference to the field. */ - -static bool -chkp_narrow_bounds_for_field (tree ref, tree field) -{ - HOST_WIDE_INT offs; - HOST_WIDE_INT bit_offs; - - if (!chkp_may_narrow_to_field (ref, field)) - return false; - - /* Access to compiler generated fields should not cause - bounds narrowing. */ - if (DECL_ARTIFICIAL (field)) - return false; - - offs = tree_to_uhwi (DECL_FIELD_OFFSET (field)); - bit_offs = tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field)); - - return (flag_chkp_narrow_bounds - && (flag_chkp_first_field_has_own_bounds - || offs - || bit_offs)); -} - -/* Perform narrowing for BOUNDS of an INNER reference. Shift boundary - by OFFSET bytes and limit to SIZE bytes. Newly created statements are - added to ITER. */ - -static tree -chkp_narrow_size_and_offset (tree bounds, tree inner, tree offset, - tree size, gimple_stmt_iterator *iter) -{ - tree addr = chkp_build_addr_expr (unshare_expr (inner)); - tree t = TREE_TYPE (addr); - - gimple *stmt = gimple_build_assign (NULL_TREE, addr); - addr = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME); - gimple_assign_set_lhs (stmt, addr); - gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT); - - stmt = gimple_build_assign (NULL_TREE, POINTER_PLUS_EXPR, addr, offset); - tree shifted = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME); - gimple_assign_set_lhs (stmt, shifted); - gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT); - - tree bounds2 = chkp_make_bounds (shifted, size, iter, false); - - return chkp_intersect_bounds (bounds, bounds2, iter); -} - -/* Perform narrowing for BOUNDS using bounds computed for field - access COMPONENT. ITER meaning is the same as for - chkp_intersect_bounds. */ - -static tree -chkp_narrow_bounds_to_field (tree bounds, tree component, - gimple_stmt_iterator *iter) -{ - tree field = TREE_OPERAND (component, 1); - tree size = DECL_SIZE_UNIT (field); - tree field_ptr = chkp_build_addr_expr (component); - tree field_bounds; - - field_bounds = chkp_make_bounds (field_ptr, size, iter, false); - - return chkp_intersect_bounds (field_bounds, bounds, iter); -} - -/* Parse field or array access NODE. - - PTR ouput parameter holds a pointer to the outermost - object. - - BITFIELD output parameter is set to 1 if bitfield is - accessed and to 0 otherwise. If it is 1 then ELT holds - outer component for accessed bit field. - - SAFE outer parameter is set to 1 if access is safe and - checks are not required. - - BOUNDS outer parameter holds bounds to be used to check - access (may be NULL). - - If INNERMOST_BOUNDS is 1 then try to narrow bounds to the - innermost accessed component. */ -static void -chkp_parse_array_and_component_ref (tree node, tree *ptr, - tree *elt, bool *safe, - bool *bitfield, - tree *bounds, - gimple_stmt_iterator *iter, - bool innermost_bounds) -{ - tree comp_to_narrow = NULL_TREE; - tree last_comp = NULL_TREE; - bool array_ref_found = false; - tree *nodes; - tree var; - int len; - int i; - - /* Compute tree height for expression. */ - var = node; - len = 1; - while (TREE_CODE (var) == COMPONENT_REF - || TREE_CODE (var) == ARRAY_REF - || TREE_CODE (var) == VIEW_CONVERT_EXPR - || TREE_CODE (var) == BIT_FIELD_REF) - { - var = TREE_OPERAND (var, 0); - len++; - } - - gcc_assert (len > 1); - - /* It is more convenient for us to scan left-to-right, - so walk tree again and put all node to nodes vector - in reversed order. */ - nodes = XALLOCAVEC (tree, len); - nodes[len - 1] = node; - for (i = len - 2; i >= 0; i--) - nodes[i] = TREE_OPERAND (nodes[i + 1], 0); - - if (bounds) - *bounds = NULL; - *safe = true; - *bitfield = ((TREE_CODE (node) == COMPONENT_REF - && DECL_BIT_FIELD_TYPE (TREE_OPERAND (node, 1))) - || TREE_CODE (node) == BIT_FIELD_REF); - /* To get bitfield address we will need outer element. */ - if (*bitfield) - *elt = nodes[len - 2]; - else - *elt = NULL_TREE; - - /* If we have indirection in expression then compute - outermost structure bounds. Computed bounds may be - narrowed later. */ - if (TREE_CODE (nodes[0]) == MEM_REF || INDIRECT_REF_P (nodes[0])) - { - *safe = false; - *ptr = TREE_OPERAND (nodes[0], 0); - if (bounds) - *bounds = chkp_find_bounds (*ptr, iter); - } - else - { - gcc_assert (VAR_P (var) - || TREE_CODE (var) == PARM_DECL - || TREE_CODE (var) == RESULT_DECL - || TREE_CODE (var) == STRING_CST - || TREE_CODE (var) == SSA_NAME); - - *ptr = chkp_build_addr_expr (var); - - /* For hard register cases chkp_build_addr_expr returns INTEGER_CST - and later on chkp_find_bounds will fail to find proper bounds. - In order to avoid that, we find/create bounds right aways using - the var itself. */ - if (VAR_P (var) && DECL_HARD_REGISTER (var)) - *bounds = chkp_make_addressed_object_bounds (var, iter); - } - - /* In this loop we are trying to find a field access - requiring narrowing. There are two simple rules - for search: - 1. Leftmost array_ref is chosen if any. - 2. Rightmost suitable component_ref is chosen if innermost - bounds are required and no array_ref exists. */ - for (i = 1; i < len; i++) - { - var = nodes[i]; - - if (TREE_CODE (var) == ARRAY_REF) - { - *safe = false; - array_ref_found = true; - if (flag_chkp_narrow_bounds - && !flag_chkp_narrow_to_innermost_arrray - && (!last_comp - || chkp_may_narrow_to_field (var, - TREE_OPERAND (last_comp, 1)))) - { - comp_to_narrow = last_comp; - break; - } - } - else if (TREE_CODE (var) == COMPONENT_REF) - { - tree field = TREE_OPERAND (var, 1); - - if (innermost_bounds - && !array_ref_found - && chkp_narrow_bounds_for_field (var, field)) - comp_to_narrow = var; - last_comp = var; - - if (flag_chkp_narrow_bounds - && flag_chkp_narrow_to_innermost_arrray - && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE) - { - if (bounds) - *bounds = chkp_narrow_bounds_to_field (*bounds, var, iter); - comp_to_narrow = NULL; - } - } - else if (TREE_CODE (var) == BIT_FIELD_REF) - { - if (flag_chkp_narrow_bounds && bounds) - { - tree offset, size; - chkp_parse_bit_field_ref (var, UNKNOWN_LOCATION, &offset, &size); - *bounds - = chkp_narrow_size_and_offset (*bounds, TREE_OPERAND (var, 0), - offset, size, iter); - } - } - else if (TREE_CODE (var) == VIEW_CONVERT_EXPR) - /* Nothing to do for it. */ - ; - else - gcc_unreachable (); - } - - if (comp_to_narrow && DECL_SIZE (TREE_OPERAND (comp_to_narrow, 1)) && bounds) - *bounds = chkp_narrow_bounds_to_field (*bounds, comp_to_narrow, iter); - - if (innermost_bounds && bounds && !*bounds) - *bounds = chkp_find_bounds (*ptr, iter); -} - -/* Parse BIT_FIELD_REF to a NODE for a given location LOC. Return OFFSET - and SIZE in bytes. */ - -static -void chkp_parse_bit_field_ref (tree node, location_t loc, tree *offset, - tree *size) -{ - tree bpu = fold_convert (size_type_node, bitsize_int (BITS_PER_UNIT)); - tree offs = fold_convert (size_type_node, TREE_OPERAND (node, 2)); - tree rem = size_binop_loc (loc, TRUNC_MOD_EXPR, offs, bpu); - offs = size_binop_loc (loc, TRUNC_DIV_EXPR, offs, bpu); - - tree s = fold_convert (size_type_node, TREE_OPERAND (node, 1)); - s = size_binop_loc (loc, PLUS_EXPR, s, rem); - s = size_binop_loc (loc, CEIL_DIV_EXPR, s, bpu); - s = fold_convert (size_type_node, s); - - *offset = offs; - *size = s; -} - -/* Compute and return bounds for address of OBJ. */ -static tree -chkp_make_addressed_object_bounds (tree obj, gimple_stmt_iterator *iter) -{ - tree bounds = chkp_get_registered_addr_bounds (obj); - - if (bounds) - return bounds; - - switch (TREE_CODE (obj)) - { - case VAR_DECL: - case PARM_DECL: - case RESULT_DECL: - bounds = chkp_get_bounds_for_decl_addr (obj); - break; - - case STRING_CST: - bounds = chkp_get_bounds_for_string_cst (obj); - break; - - case ARRAY_REF: - case COMPONENT_REF: - case BIT_FIELD_REF: - { - tree elt; - tree ptr; - bool safe; - bool bitfield; - - chkp_parse_array_and_component_ref (obj, &ptr, &elt, &safe, - &bitfield, &bounds, iter, true); - - gcc_assert (bounds); - } - break; - - case FUNCTION_DECL: - case LABEL_DECL: - bounds = chkp_get_zero_bounds (); - break; - - case MEM_REF: - bounds = chkp_find_bounds (TREE_OPERAND (obj, 0), iter); - break; - - case REALPART_EXPR: - case IMAGPART_EXPR: - bounds = chkp_make_addressed_object_bounds (TREE_OPERAND (obj, 0), iter); - break; - - default: - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "chkp_make_addressed_object_bounds: " - "unexpected object of type %s\n", - get_tree_code_name (TREE_CODE (obj))); - print_node (dump_file, "", obj, 0); - } - internal_error ("chkp_make_addressed_object_bounds: " - "Unexpected tree code %s", - get_tree_code_name (TREE_CODE (obj))); - } - - chkp_register_addr_bounds (obj, bounds); - - return bounds; -} - -/* Compute bounds for pointer PTR loaded from PTR_SRC. Generate statements - to compute bounds if required. Computed bounds should be available at - position pointed by ITER. - - If PTR_SRC is NULL_TREE then pointer definition is identified. - - If PTR_SRC is not NULL_TREE then ITER points to statements which loads - PTR. If PTR is a any memory reference then ITER points to a statement - after which bndldx will be inserterd. In both cases ITER will be updated - to point to the inserted bndldx statement. */ - -static tree -chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter) -{ - tree addr = NULL_TREE; - tree bounds = NULL_TREE; - - if (!ptr_src) - ptr_src = ptr; - - bounds = chkp_get_registered_bounds (ptr_src); - - if (bounds) - return bounds; - - switch (TREE_CODE (ptr_src)) - { - case MEM_REF: - case VAR_DECL: - if (BOUNDED_P (ptr_src)) - if (VAR_P (ptr) && DECL_REGISTER (ptr)) - bounds = chkp_get_zero_bounds (); - else - { - addr = chkp_build_addr_expr (ptr_src); - bounds = chkp_build_bndldx (addr, ptr, iter); - } - else - bounds = chkp_get_nonpointer_load_bounds (); - break; - - case ARRAY_REF: - case COMPONENT_REF: - addr = get_base_address (ptr_src); - if (VAR_P (addr) && DECL_HARD_REGISTER (addr)) - { - bounds = chkp_get_zero_bounds (); - break; - } - if (DECL_P (addr) - || TREE_CODE (addr) == MEM_REF - || TREE_CODE (addr) == TARGET_MEM_REF) - { - if (BOUNDED_P (ptr_src)) - if (VAR_P (ptr) && DECL_REGISTER (ptr)) - bounds = chkp_get_zero_bounds (); - else - { - addr = chkp_build_addr_expr (ptr_src); - bounds = chkp_build_bndldx (addr, ptr, iter); - } - else - bounds = chkp_get_nonpointer_load_bounds (); - } - else - { - gcc_assert (TREE_CODE (addr) == SSA_NAME); - bounds = chkp_find_bounds (addr, iter); - } - break; - - case PARM_DECL: - /* Handled above but failed. */ - bounds = chkp_get_invalid_op_bounds (); - break; - - case TARGET_MEM_REF: - addr = chkp_build_addr_expr (ptr_src); - bounds = chkp_build_bndldx (addr, ptr, iter); - break; - - case SSA_NAME: - bounds = chkp_get_registered_bounds (ptr_src); - if (!bounds) - { - gimple *def_stmt = SSA_NAME_DEF_STMT (ptr_src); - gphi_iterator phi_iter; - - bounds = chkp_get_bounds_by_definition (ptr_src, def_stmt, &phi_iter); - - gcc_assert (bounds); - - if (gphi *def_phi = dyn_cast <gphi *> (def_stmt)) - { - unsigned i; - - for (i = 0; i < gimple_phi_num_args (def_phi); i++) - { - tree arg = gimple_phi_arg_def (def_phi, i); - tree arg_bnd; - gphi *phi_bnd; - - arg_bnd = chkp_find_bounds (arg, NULL); - - /* chkp_get_bounds_by_definition created new phi - statement and phi_iter points to it. - - Previous call to chkp_find_bounds could create - new basic block and therefore change phi statement - phi_iter points to. */ - phi_bnd = phi_iter.phi (); - - add_phi_arg (phi_bnd, arg_bnd, - gimple_phi_arg_edge (def_phi, i), - UNKNOWN_LOCATION); - } - - /* If all bound phi nodes have their arg computed - then we may finish its computation. See - chkp_finish_incomplete_bounds for more details. */ - if (chkp_may_finish_incomplete_bounds ()) - chkp_finish_incomplete_bounds (); - } - - gcc_assert (bounds == chkp_get_registered_bounds (ptr_src) - || chkp_incomplete_bounds (bounds)); - } - break; - - case ADDR_EXPR: - case WITH_SIZE_EXPR: - bounds = chkp_make_addressed_object_bounds (TREE_OPERAND (ptr_src, 0), iter); - break; - - case INTEGER_CST: - case COMPLEX_CST: - case VECTOR_CST: - if (integer_zerop (ptr_src)) - bounds = chkp_get_none_bounds (); - else - bounds = chkp_get_invalid_op_bounds (); - break; - - default: - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "chkp_find_bounds: unexpected ptr of type %s\n", - get_tree_code_name (TREE_CODE (ptr_src))); - print_node (dump_file, "", ptr_src, 0); - } - internal_error ("chkp_find_bounds: Unexpected tree code %s", - get_tree_code_name (TREE_CODE (ptr_src))); - } - - if (!bounds) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (stderr, "chkp_find_bounds: cannot find bounds for pointer\n"); - print_node (dump_file, "", ptr_src, 0); - } - internal_error ("chkp_find_bounds: Cannot find bounds for pointer"); - } - - return bounds; -} - -/* Normal case for bounds search without forced narrowing. */ -static tree -chkp_find_bounds (tree ptr, gimple_stmt_iterator *iter) -{ - return chkp_find_bounds_1 (ptr, NULL_TREE, iter); -} - -/* Search bounds for pointer PTR loaded from PTR_SRC - by statement *ITER points to. */ -static tree -chkp_find_bounds_loaded (tree ptr, tree ptr_src, gimple_stmt_iterator *iter) -{ - return chkp_find_bounds_1 (ptr, ptr_src, iter); -} - -/* Helper function which checks type of RHS and finds all pointers in - it. For each found pointer we build it's accesses in LHS and RHS - objects and then call HANDLER for them. Function is used to copy - or initilize bounds for copied object. */ -static void -chkp_walk_pointer_assignments (tree lhs, tree rhs, void *arg, - assign_handler handler) -{ - tree type = TREE_TYPE (lhs); - - /* We have nothing to do with clobbers. */ - if (TREE_CLOBBER_P (rhs)) - return; - - if (BOUNDED_TYPE_P (type)) - handler (lhs, rhs, arg); - else if (RECORD_OR_UNION_TYPE_P (type)) - { - tree field; - - if (TREE_CODE (rhs) == CONSTRUCTOR) - { - unsigned HOST_WIDE_INT cnt; - tree val; - - FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs), cnt, field, val) - { - if (field && chkp_type_has_pointer (TREE_TYPE (field))) - { - tree lhs_field = chkp_build_component_ref (lhs, field); - chkp_walk_pointer_assignments (lhs_field, val, arg, handler); - } - } - } - else - for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) - if (TREE_CODE (field) == FIELD_DECL - && chkp_type_has_pointer (TREE_TYPE (field))) - { - tree rhs_field = chkp_build_component_ref (rhs, field); - tree lhs_field = chkp_build_component_ref (lhs, field); - chkp_walk_pointer_assignments (lhs_field, rhs_field, arg, handler); - } - } - else if (TREE_CODE (type) == ARRAY_TYPE) - { - unsigned HOST_WIDE_INT cur = 0; - tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); - tree etype = TREE_TYPE (type); - tree esize = TYPE_SIZE (etype); - - if (TREE_CODE (rhs) == CONSTRUCTOR) - { - unsigned HOST_WIDE_INT cnt; - tree purp, val, lhs_elem; - - FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs), cnt, purp, val) - { - if (purp && TREE_CODE (purp) == RANGE_EXPR) - { - tree lo_index = TREE_OPERAND (purp, 0); - tree hi_index = TREE_OPERAND (purp, 1); - - for (cur = (unsigned)tree_to_uhwi (lo_index); - cur <= (unsigned)tree_to_uhwi (hi_index); - cur++) - { - lhs_elem = chkp_build_array_ref (lhs, etype, esize, cur); - chkp_walk_pointer_assignments (lhs_elem, val, arg, handler); - } - } - else - { - if (purp) - { - gcc_assert (TREE_CODE (purp) == INTEGER_CST); - cur = tree_to_uhwi (purp); - } - - lhs_elem = chkp_build_array_ref (lhs, etype, esize, cur++); - - chkp_walk_pointer_assignments (lhs_elem, val, arg, handler); - } - } - } - /* Copy array only when size is known. */ - else if (maxval && !integer_minus_onep (maxval)) - for (cur = 0; cur <= TREE_INT_CST_LOW (maxval); cur++) - { - tree lhs_elem = chkp_build_array_ref (lhs, etype, esize, cur); - tree rhs_elem = chkp_build_array_ref (rhs, etype, esize, cur); - chkp_walk_pointer_assignments (lhs_elem, rhs_elem, arg, handler); - } - } - else - internal_error("chkp_walk_pointer_assignments: unexpected RHS type: %s", - get_tree_code_name (TREE_CODE (type))); -} - -/* Add code to copy bounds for assignment of RHS to LHS. - ARG is an iterator pointing ne code position. */ -static void -chkp_copy_bounds_for_elem (tree lhs, tree rhs, void *arg) -{ - gimple_stmt_iterator *iter = (gimple_stmt_iterator *)arg; - tree bounds = chkp_find_bounds (rhs, iter); - tree addr = chkp_build_addr_expr(lhs); - - chkp_build_bndstx (addr, rhs, bounds, iter); -} - -/* Emit static bound initilizers and size vars. */ -void -chkp_finish_file (void) -{ - struct varpool_node *node; - struct chkp_ctor_stmt_list stmts; - - if (seen_error ()) - return; - - /* Iterate through varpool and generate bounds initialization - constructors for all statically initialized pointers. */ - stmts.avail = MAX_STMTS_IN_STATIC_CHKP_CTOR; - stmts.stmts = NULL; - FOR_EACH_VARIABLE (node) - /* Check that var is actually emitted and we need and may initialize - its bounds. */ - if (node->need_bounds_init - && !POINTER_BOUNDS_P (node->decl) - && DECL_RTL (node->decl) - && MEM_P (DECL_RTL (node->decl)) - && TREE_ASM_WRITTEN (node->decl)) - { - chkp_walk_pointer_assignments (node->decl, - DECL_INITIAL (node->decl), - &stmts, - chkp_add_modification_to_stmt_list); - - if (stmts.avail <= 0) - { - cgraph_build_static_cdtor ('P', stmts.stmts, - MAX_RESERVED_INIT_PRIORITY + 3); - stmts.avail = MAX_STMTS_IN_STATIC_CHKP_CTOR; - stmts.stmts = NULL; - } - } - - if (stmts.stmts) - cgraph_build_static_cdtor ('P', stmts.stmts, - MAX_RESERVED_INIT_PRIORITY + 3); - - /* Iterate through varpool and generate bounds initialization - constructors for all static bounds vars. */ - stmts.avail = MAX_STMTS_IN_STATIC_CHKP_CTOR; - stmts.stmts = NULL; - FOR_EACH_VARIABLE (node) - if (node->need_bounds_init - && POINTER_BOUNDS_P (node->decl) - && TREE_ASM_WRITTEN (node->decl)) - { - tree bnd = node->decl; - tree var; - - gcc_assert (DECL_INITIAL (bnd) - && TREE_CODE (DECL_INITIAL (bnd)) == ADDR_EXPR); - - var = TREE_OPERAND (DECL_INITIAL (bnd), 0); - chkp_output_static_bounds (bnd, var, &stmts); - } - - if (stmts.stmts) - cgraph_build_static_cdtor ('B', stmts.stmts, - MAX_RESERVED_INIT_PRIORITY + 2); - - delete chkp_static_var_bounds; - delete chkp_bounds_map; -} - -/* An instrumentation function which is called for each statement - having memory access we want to instrument. It inserts check - code and bounds copy code. - - ITER points to statement to instrument. - - NODE holds memory access in statement to check. - - LOC holds the location information for statement. - - DIRFLAGS determines whether access is read or write. - - ACCESS_OFFS should be added to address used in NODE - before check. - - ACCESS_SIZE holds size of checked access. - - SAFE indicates if NODE access is safe and should not be - checked. */ -static void -chkp_process_stmt (gimple_stmt_iterator *iter, tree node, - location_t loc, tree dirflag, - tree access_offs, tree access_size, - bool safe) -{ - tree node_type = TREE_TYPE (node); - tree size = access_size ? access_size : TYPE_SIZE_UNIT (node_type); - tree addr_first = NULL_TREE; /* address of the first accessed byte */ - tree addr_last = NULL_TREE; /* address of the last accessed byte */ - tree ptr = NULL_TREE; /* a pointer used for dereference */ - tree bounds = NULL_TREE; - bool reg_store = false; - - /* We do not need instrumentation for clobbers. */ - if (dirflag == integer_one_node - && gimple_code (gsi_stmt (*iter)) == GIMPLE_ASSIGN - && TREE_CLOBBER_P (gimple_assign_rhs1 (gsi_stmt (*iter)))) - return; - - switch (TREE_CODE (node)) - { - case ARRAY_REF: - case COMPONENT_REF: - { - bool bitfield; - tree elt; - - if (safe) - { - /* We are not going to generate any checks, so do not - generate bounds as well. */ - addr_first = chkp_build_addr_expr (node); - break; - } - - chkp_parse_array_and_component_ref (node, &ptr, &elt, &safe, - &bitfield, &bounds, iter, false); - - /* Break if there is no dereference and operation is safe. */ - - if (bitfield) - { - tree field = TREE_OPERAND (node, 1); - - if (TREE_CODE (DECL_SIZE_UNIT (field)) == INTEGER_CST) - size = DECL_SIZE_UNIT (field); - - if (elt) - elt = chkp_build_addr_expr (elt); - addr_first = fold_convert_loc (loc, ptr_type_node, elt ? elt : ptr); - addr_first = fold_build_pointer_plus_loc (loc, - addr_first, - byte_position (field)); - } - else - addr_first = chkp_build_addr_expr (node); - } - break; - - case INDIRECT_REF: - ptr = TREE_OPERAND (node, 0); - addr_first = ptr; - break; - - case MEM_REF: - ptr = TREE_OPERAND (node, 0); - addr_first = chkp_build_addr_expr (node); - break; - - case TARGET_MEM_REF: - ptr = TMR_BASE (node); - addr_first = chkp_build_addr_expr (node); - break; - - case ARRAY_RANGE_REF: - printf("ARRAY_RANGE_REF\n"); - debug_gimple_stmt(gsi_stmt(*iter)); - debug_tree(node); - gcc_unreachable (); - break; - - case BIT_FIELD_REF: - { - tree offset, size; - - gcc_assert (!access_offs); - gcc_assert (!access_size); - - chkp_parse_bit_field_ref (node, loc, &offset, &size); - - chkp_process_stmt (iter, TREE_OPERAND (node, 0), loc, - dirflag, offset, size, safe); - return; - } - break; - - case VAR_DECL: - case RESULT_DECL: - case PARM_DECL: - if (dirflag != integer_one_node - || DECL_REGISTER (node)) - return; - - safe = true; - addr_first = chkp_build_addr_expr (node); - break; - - default: - return; - } - - /* If addr_last was not computed then use (addr_first + size - 1) - expression to compute it. */ - if (!addr_last) - { - addr_last = fold_build_pointer_plus_loc (loc, addr_first, size); - addr_last = fold_build_pointer_plus_hwi_loc (loc, addr_last, -1); - } - - /* Shift both first_addr and last_addr by access_offs if specified. */ - if (access_offs) - { - addr_first = fold_build_pointer_plus_loc (loc, addr_first, access_offs); - addr_last = fold_build_pointer_plus_loc (loc, addr_last, access_offs); - } - - if (dirflag == integer_one_node) - { - tree base = get_base_address (node); - if (VAR_P (base) && DECL_HARD_REGISTER (base)) - reg_store = true; - } - - /* Generate bndcl/bndcu checks if memory access is not safe. */ - if (!safe) - { - gimple_stmt_iterator stmt_iter = *iter; - - if (!bounds) - bounds = chkp_find_bounds (ptr, iter); - - chkp_check_mem_access (addr_first, addr_last, bounds, - stmt_iter, loc, dirflag); - } - - /* We need to store bounds in case pointer is stored. */ - if (dirflag == integer_one_node - && !reg_store - && chkp_type_has_pointer (node_type) - && flag_chkp_store_bounds) - { - gimple *stmt = gsi_stmt (*iter); - tree rhs1 = gimple_assign_rhs1 (stmt); - enum tree_code rhs_code = gimple_assign_rhs_code (stmt); - - if (get_gimple_rhs_class (rhs_code) == GIMPLE_SINGLE_RHS) - chkp_walk_pointer_assignments (node, rhs1, iter, - chkp_copy_bounds_for_elem); - else - { - bounds = chkp_compute_bounds_for_assignment (NULL_TREE, stmt); - chkp_build_bndstx (addr_first, rhs1, bounds, iter); - } - } -} - -/* Add code to copy bounds for all pointers copied - in ASSIGN created during inline of EDGE. */ -void -chkp_copy_bounds_for_assign (gimple *assign, struct cgraph_edge *edge) -{ - tree lhs = gimple_assign_lhs (assign); - tree rhs = gimple_assign_rhs1 (assign); - gimple_stmt_iterator iter = gsi_for_stmt (assign); - - if (!flag_chkp_store_bounds) - return; - - chkp_walk_pointer_assignments (lhs, rhs, &iter, chkp_copy_bounds_for_elem); - - /* We should create edges for all created calls to bndldx and bndstx. */ - while (gsi_stmt (iter) != assign) - { - gimple *stmt = gsi_stmt (iter); - if (gimple_code (stmt) == GIMPLE_CALL) - { - tree fndecl = gimple_call_fndecl (stmt); - struct cgraph_node *callee = cgraph_node::get_create (fndecl); - - gcc_assert (chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDSTX) - || chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDLDX) - || chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET)); - - edge->caller->create_edge (callee, as_a <gcall *> (stmt), edge->count); - } - gsi_prev (&iter); - } -} - -/* Some code transformation made during instrumentation pass - may put code into inconsistent state. Here we find and fix - such flaws. */ -void -chkp_fix_cfg () -{ - basic_block bb; - gimple_stmt_iterator i; - - /* We could insert some code right after stmt which ends bb. - We wanted to put this code on fallthru edge but did not - add new edges from the beginning because it may cause new - phi node creation which may be incorrect due to incomplete - bound phi nodes. */ - FOR_ALL_BB_FN (bb, cfun) - for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) - { - gimple *stmt = gsi_stmt (i); - gimple_stmt_iterator next = i; - - gsi_next (&next); - - if (stmt_ends_bb_p (stmt) - && !gsi_end_p (next)) - { - edge fall = find_fallthru_edge (bb->succs); - basic_block dest = NULL; - int flags = 0; - - gcc_assert (fall); - - /* We cannot split abnormal edge. Therefore we - store its params, make it regular and then - rebuild abnormal edge after split. */ - if (fall->flags & EDGE_ABNORMAL) - { - flags = fall->flags & ~EDGE_FALLTHRU; - dest = fall->dest; - - fall->flags &= ~EDGE_COMPLEX; - } - - while (!gsi_end_p (next)) - { - gimple *next_stmt = gsi_stmt (next); - gsi_remove (&next, false); - gsi_insert_on_edge (fall, next_stmt); - } - - gsi_commit_edge_inserts (); - - /* Re-create abnormal edge. */ - if (dest) - make_edge (bb, dest, flags); - } - } -} - -/* Walker callback for chkp_replace_function_pointers. Replaces - function pointer in the specified operand with pointer to the - instrumented function version. */ -static tree -chkp_replace_function_pointer (tree *op, int *walk_subtrees, - void *data ATTRIBUTE_UNUSED) -{ - if (TREE_CODE (*op) == FUNCTION_DECL - && chkp_instrumentable_p (*op) - && (DECL_BUILT_IN_CLASS (*op) == NOT_BUILT_IN - /* For builtins we replace pointers only for selected - function and functions having definitions. */ - || (DECL_BUILT_IN_CLASS (*op) == BUILT_IN_NORMAL - && (chkp_instrument_normal_builtin (*op) - || gimple_has_body_p (*op))))) - { - struct cgraph_node *node = cgraph_node::get_create (*op); - struct cgraph_node *clone = NULL; - - if (!node->instrumentation_clone) - clone = chkp_maybe_create_clone (*op); - - if (clone) - *op = clone->decl; - *walk_subtrees = 0; - } - - return NULL; -} - -/* This function searches for function pointers in statement - pointed by GSI and replaces them with pointers to instrumented - function versions. */ -static void -chkp_replace_function_pointers (gimple_stmt_iterator *gsi) -{ - gimple *stmt = gsi_stmt (*gsi); - /* For calls we want to walk call args only. */ - if (gimple_code (stmt) == GIMPLE_CALL) - { - unsigned i; - for (i = 0; i < gimple_call_num_args (stmt); i++) - walk_tree (gimple_call_arg_ptr (stmt, i), - chkp_replace_function_pointer, NULL, NULL); - } - else - walk_gimple_stmt (gsi, NULL, chkp_replace_function_pointer, NULL); -} - -/* This function instruments all statements working with memory, - calls and rets. - - It also removes excess statements from static initializers. */ -static void -chkp_instrument_function (void) -{ - basic_block bb, next; - gimple_stmt_iterator i; - enum gimple_rhs_class grhs_class; - bool safe = lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl)); - - bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb; - do - { - next = bb->next_bb; - for (i = gsi_start_bb (bb); !gsi_end_p (i); ) - { - gimple *s = gsi_stmt (i); - - /* Skip statement marked to not be instrumented. */ - if (chkp_marked_stmt_p (s)) - { - gsi_next (&i); - continue; - } - - chkp_replace_function_pointers (&i); - - switch (gimple_code (s)) - { - case GIMPLE_ASSIGN: - chkp_process_stmt (&i, gimple_assign_lhs (s), - gimple_location (s), integer_one_node, - NULL_TREE, NULL_TREE, safe); - chkp_process_stmt (&i, gimple_assign_rhs1 (s), - gimple_location (s), integer_zero_node, - NULL_TREE, NULL_TREE, safe); - grhs_class = get_gimple_rhs_class (gimple_assign_rhs_code (s)); - if (grhs_class == GIMPLE_BINARY_RHS) - chkp_process_stmt (&i, gimple_assign_rhs2 (s), - gimple_location (s), integer_zero_node, - NULL_TREE, NULL_TREE, safe); - break; - - case GIMPLE_RETURN: - { - greturn *r = as_a <greturn *> (s); - if (gimple_return_retval (r) != NULL_TREE) - { - chkp_process_stmt (&i, gimple_return_retval (r), - gimple_location (r), - integer_zero_node, - NULL_TREE, NULL_TREE, safe); - - /* Additionally we need to add bounds - to return statement. */ - chkp_add_bounds_to_ret_stmt (&i); - } - } - break; - - case GIMPLE_CALL: - chkp_add_bounds_to_call_stmt (&i); - break; - - default: - ; - } - - gsi_next (&i); - - /* We do not need any actual pointer stores in checker - static initializer. */ - if (lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl)) - && gimple_code (s) == GIMPLE_ASSIGN - && gimple_store_p (s)) - { - gimple_stmt_iterator del_iter = gsi_for_stmt (s); - gsi_remove (&del_iter, true); - unlink_stmt_vdef (s); - release_defs(s); - } - } - bb = next; - } - while (bb); - - /* Some input params may have bounds and be address taken. In this case - we should store incoming bounds into bounds table. */ - tree arg; - if (flag_chkp_store_bounds) - for (arg = DECL_ARGUMENTS (cfun->decl); arg; arg = DECL_CHAIN (arg)) - if (TREE_ADDRESSABLE (arg)) - { - if (BOUNDED_P (arg)) - { - tree bounds = chkp_get_next_bounds_parm (arg); - tree def_ptr = ssa_default_def (cfun, arg); - gimple_stmt_iterator iter - = gsi_start_bb (chkp_get_entry_block ()); - chkp_build_bndstx (chkp_build_addr_expr (arg), - def_ptr ? def_ptr : arg, - bounds, &iter); - - /* Skip bounds arg. */ - arg = TREE_CHAIN (arg); - } - else if (chkp_type_has_pointer (TREE_TYPE (arg))) - { - tree orig_arg = arg; - bitmap slots = BITMAP_ALLOC (NULL); - gimple_stmt_iterator iter - = gsi_start_bb (chkp_get_entry_block ()); - bitmap_iterator bi; - unsigned bnd_no; - - chkp_find_bound_slots (TREE_TYPE (arg), slots); - - EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi) - { - tree bounds = chkp_get_next_bounds_parm (arg); - HOST_WIDE_INT offs = bnd_no * POINTER_SIZE / BITS_PER_UNIT; - tree addr = chkp_build_addr_expr (orig_arg); - tree ptr = build2 (MEM_REF, ptr_type_node, addr, - build_int_cst (ptr_type_node, offs)); - chkp_build_bndstx (chkp_build_addr_expr (ptr), ptr, - bounds, &iter); - - arg = DECL_CHAIN (arg); - } - BITMAP_FREE (slots); - } - } -} - -/* Find init/null/copy_ptr_bounds calls and replace them - with assignments. It should allow better code - optimization. */ - -static void -chkp_remove_useless_builtins () -{ - basic_block bb; - gimple_stmt_iterator gsi; - - FOR_EACH_BB_FN (bb, cfun) - { - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - { - gimple *stmt = gsi_stmt (gsi); - tree fndecl; - enum built_in_function fcode; - - /* Find builtins returning first arg and replace - them with assignments. */ - if (gimple_code (stmt) == GIMPLE_CALL - && (fndecl = gimple_call_fndecl (stmt)) - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && (fcode = DECL_FUNCTION_CODE (fndecl)) - && (fcode == BUILT_IN_CHKP_INIT_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_NULL_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_COPY_PTR_BOUNDS - || fcode == BUILT_IN_CHKP_SET_PTR_BOUNDS)) - { - tree res = gimple_call_arg (stmt, 0); - update_call_from_tree (&gsi, res); - stmt = gsi_stmt (gsi); - update_stmt (stmt); - } - } - } -} - -/* Initialize pass. */ -static void -chkp_init (void) -{ - basic_block bb; - gimple_stmt_iterator i; - - in_chkp_pass = true; - - for (bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb; bb; bb = bb->next_bb) - for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) - chkp_unmark_stmt (gsi_stmt (i)); - - chkp_invalid_bounds = new hash_set<tree>; - chkp_completed_bounds_set = new hash_set<tree>; - delete chkp_reg_bounds; - chkp_reg_bounds = new hash_map<tree, tree>; - delete chkp_bound_vars; - chkp_bound_vars = new hash_map<tree, tree>; - chkp_reg_addr_bounds = new hash_map<tree, tree>; - chkp_incomplete_bounds_map = new hash_map<tree, tree>; - delete chkp_bounds_map; - chkp_bounds_map = new hash_map<tree, tree>; - chkp_abnormal_copies = BITMAP_GGC_ALLOC (); - - entry_block = NULL; - zero_bounds = NULL_TREE; - none_bounds = NULL_TREE; - incomplete_bounds = integer_zero_node; - tmp_var = NULL_TREE; - size_tmp_var = NULL_TREE; - - chkp_uintptr_type = lang_hooks.types.type_for_mode (ptr_mode, true); - - /* We create these constant bounds once for each object file. - These symbols go to comdat section and result in single copy - of each one in the final binary. */ - chkp_get_zero_bounds_var (); - chkp_get_none_bounds_var (); - - calculate_dominance_info (CDI_DOMINATORS); - calculate_dominance_info (CDI_POST_DOMINATORS); - - bitmap_obstack_initialize (NULL); -} - -/* Finalize instrumentation pass. */ -static void -chkp_fini (void) -{ - in_chkp_pass = false; - - delete chkp_invalid_bounds; - delete chkp_completed_bounds_set; - delete chkp_reg_addr_bounds; - delete chkp_incomplete_bounds_map; - - free_dominance_info (CDI_DOMINATORS); - free_dominance_info (CDI_POST_DOMINATORS); - - bitmap_obstack_release (NULL); - - entry_block = NULL; - zero_bounds = NULL_TREE; - none_bounds = NULL_TREE; -} - -/* Main instrumentation pass function. */ -static unsigned int -chkp_execute (void) -{ - chkp_init (); - - chkp_instrument_function (); - - chkp_remove_useless_builtins (); - - chkp_function_mark_instrumented (cfun->decl); - - chkp_fix_cfg (); - - chkp_fini (); - - return 0; -} - -/* Instrumentation pass gate. */ -static bool -chkp_gate (void) -{ - cgraph_node *node = cgraph_node::get (cfun->decl); - return ((node != NULL - && node->instrumentation_clone) - || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl))); -} - -namespace { - -const pass_data pass_data_chkp = -{ - GIMPLE_PASS, /* type */ - "chkp", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - PROP_ssa | PROP_cfg, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - TODO_verify_il - | TODO_update_ssa /* todo_flags_finish */ -}; - -class pass_chkp : public gimple_opt_pass -{ -public: - pass_chkp (gcc::context *ctxt) - : gimple_opt_pass (pass_data_chkp, ctxt) - {} - - /* opt_pass methods: */ - virtual opt_pass * clone () - { - return new pass_chkp (m_ctxt); - } - - virtual bool gate (function *) - { - return chkp_gate (); - } - - virtual unsigned int execute (function *) - { - return chkp_execute (); - } - -}; // class pass_chkp - -} // anon namespace - -gimple_opt_pass * -make_pass_chkp (gcc::context *ctxt) -{ - return new pass_chkp (ctxt); -} - -#include "gt-tree-chkp.h" diff --git a/gcc/tree-chkp.h b/gcc/tree-chkp.h deleted file mode 100644 index 5cfae3d82ce..00000000000 --- a/gcc/tree-chkp.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Declaration of interface functions of Pointer Bounds Checker. - Copyright (C) 2014-2018 Free Software Foundation, Inc. - -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/>. */ - -#ifndef GCC_TREE_CHKP_H -#define GCC_TREE_CHKP_H - -#define DECL_BOUNDS(NODE) (chkp_get_bounds (DECL_WRTL_CHECK (NODE))) - -#define SET_DECL_BOUNDS(NODE, VAL) \ - (chkp_set_bounds (DECL_WRTL_CHECK (NODE), VAL)) - -extern tree chkp_get_bounds (tree node); -extern void chkp_set_bounds (tree node, tree val); -extern bool chkp_register_var_initializer (tree var); -extern void chkp_finish_file (void); -extern bool chkp_type_has_pointer (const_tree type); -extern unsigned chkp_type_bounds_count (const_tree type); -extern tree chkp_make_bounds_for_struct_addr (tree ptr); -extern tree chkp_get_zero_bounds_var (void); -extern tree chkp_get_none_bounds_var (void); -extern void chkp_check_mem_access (tree first, tree last, tree bounds, - gimple_stmt_iterator iter, - location_t location, - tree dirflag); -extern void chkp_fix_cfg (void); -extern bool chkp_variable_size_type (tree type); -extern tree chkp_build_make_bounds_call (tree lb, tree size); -extern tree chkp_build_bndldx_call (tree addr, tree ptr); -extern tree chkp_build_bndstx_call (tree addr, tree ptr, tree bounds); -extern void chkp_find_bound_slots (const_tree type, bitmap res); -extern void chkp_build_bndstx (tree addr, tree ptr, tree bounds, - gimple_stmt_iterator *gsi); -extern gcall *chkp_retbnd_call_by_val (tree val); -extern bool chkp_function_instrumented_p (tree fndecl); -extern void chkp_function_mark_instrumented (tree fndecl); -extern void chkp_copy_bounds_for_assign (gimple *assign, - struct cgraph_edge *edge); -extern bool chkp_gimple_call_builtin_p (gimple *call, - enum built_in_function code); -extern rtx chkp_expand_zero_bounds (void); -extern void chkp_expand_bounds_reset_for_mem (tree mem, tree ptr); -extern tree chkp_insert_retbnd_call (tree bndval, tree retval, - gimple_stmt_iterator *gsi); -extern gcall *chkp_copy_call_skip_bounds (gcall *call); -extern bool chkp_redirect_edge (cgraph_edge *e); -extern void chkp_fixup_inlined_call (tree lhs, tree rhs); - -#endif /* GCC_TREE_CHKP_H */ diff --git a/gcc/tree-core.h b/gcc/tree-core.h index f7be51f0e44..2bebb22a7e9 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -165,16 +165,6 @@ enum built_in_class { #define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) ENUM, enum built_in_function { #include "builtins.def" - - BEGIN_CHKP_BUILTINS, - -#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) -#define DEF_BUILTIN_CHKP(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) \ - ENUM##_CHKP = ENUM + BEGIN_CHKP_BUILTINS + 1, -#include "builtins.def" - - END_CHKP_BUILTINS = BEGIN_CHKP_BUILTINS * 2 + 1, - /* Complex division routines in libgcc. These are done via builtins because emit_library_call_value can't handle complex values. */ BUILT_IN_COMPLEX_MUL_MIN, @@ -210,10 +200,6 @@ enum combined_fn { CFN_##ENUM = int (ENUM), #include "builtins.def" -#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) -#define DEF_BUILTIN_CHKP(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) \ - CFN_##ENUM##_CHKP = int (ENUM##_CHKP), -#include "builtins.def" #define DEF_INTERNAL_FN(CODE, FLAGS, FNSPEC) \ CFN_##CODE = int (END_BUILTINS) + int (IFN_##CODE), diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ae36cc710fd..ca4dc321d20 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -57,7 +57,6 @@ along with GCC; see the file COPYING3. If not see #include "value-prof.h" #include "cfgloop.h" #include "builtins.h" -#include "tree-chkp.h" #include "stringpool.h" #include "attribs.h" #include "sreal.h" @@ -122,7 +121,7 @@ eni_weights eni_time_weights; /* Prototypes. */ -static tree declare_return_variable (copy_body_data *, tree, tree, tree, +static tree declare_return_variable (copy_body_data *, tree, tree, basic_block); static void remap_block (tree *, copy_body_data *); static void copy_bind_expr (tree *, int *, copy_body_data *); @@ -1403,15 +1402,6 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id) retval); /* id->retvar is already substituted. Skip it on later remapping. */ skip_first = true; - - /* We need to copy bounds if return structure with pointers into - instrumented function. */ - if (chkp_function_instrumented_p (id->dst_fn) - && !bndslot - && !BOUNDED_P (id->retvar) - && chkp_type_has_pointer (TREE_TYPE (id->retvar))) - id->assign_stmts.safe_push (copy); - } else return stmts; @@ -1889,29 +1879,13 @@ copy_bb (copy_body_data *id, basic_block bb, gcall *new_call; vec<tree> argarray; size_t nargs = gimple_call_num_args (id->call_stmt); - size_t n, i, nargs_to_copy; - bool remove_bounds = false; + size_t n; for (p = DECL_ARGUMENTS (id->src_fn); p; p = DECL_CHAIN (p)) nargs--; - /* Bounds should be removed from arg pack in case - we handle not instrumented call in instrumented - function. */ - nargs_to_copy = nargs; - if (gimple_call_with_bounds_p (id->call_stmt) - && !gimple_call_with_bounds_p (stmt)) - { - for (i = gimple_call_num_args (id->call_stmt) - nargs; - i < gimple_call_num_args (id->call_stmt); - i++) - if (POINTER_BOUNDS_P (gimple_call_arg (id->call_stmt, i))) - nargs_to_copy--; - remove_bounds = true; - } - /* Create the new array of arguments. */ - n = nargs_to_copy + gimple_call_num_args (call_stmt); + n = nargs + gimple_call_num_args (call_stmt); argarray.create (n); argarray.safe_grow_cleared (n); @@ -1920,26 +1894,11 @@ copy_bb (copy_body_data *id, basic_block bb, gimple_call_arg_ptr (call_stmt, 0), gimple_call_num_args (call_stmt) * sizeof (tree)); - if (remove_bounds) - { - /* Append the rest of arguments removing bounds. */ - unsigned cur = gimple_call_num_args (call_stmt); - i = gimple_call_num_args (id->call_stmt) - nargs; - for (i = gimple_call_num_args (id->call_stmt) - nargs; - i < gimple_call_num_args (id->call_stmt); - i++) - if (!POINTER_BOUNDS_P (gimple_call_arg (id->call_stmt, i))) - argarray[cur++] = gimple_call_arg (id->call_stmt, i); - gcc_assert (cur == n); - } - else - { - /* Append the arguments passed in '...' */ - memcpy (argarray.address () + gimple_call_num_args (call_stmt), - gimple_call_arg_ptr (id->call_stmt, 0) - + (gimple_call_num_args (id->call_stmt) - nargs), - nargs * sizeof (tree)); - } + /* Append the arguments passed in '...' */ + memcpy (argarray.address () + gimple_call_num_args (call_stmt), + gimple_call_arg_ptr (id->call_stmt, 0) + + (gimple_call_num_args (id->call_stmt) - nargs), + nargs * sizeof (tree)); new_call = gimple_build_call_vec (gimple_call_fn (call_stmt), argarray); @@ -1966,20 +1925,13 @@ copy_bb (copy_body_data *id, basic_block bb, { /* __builtin_va_arg_pack_len () should be replaced by the number of anonymous arguments. */ - size_t nargs = gimple_call_num_args (id->call_stmt), i; + size_t nargs = gimple_call_num_args (id->call_stmt); tree count, p; gimple *new_stmt; for (p = DECL_ARGUMENTS (id->src_fn); p; p = DECL_CHAIN (p)) nargs--; - /* For instrumented calls we should ignore bounds. */ - for (i = gimple_call_num_args (id->call_stmt) - nargs; - i < gimple_call_num_args (id->call_stmt); - i++) - if (POINTER_BOUNDS_P (gimple_call_arg (id->call_stmt, i))) - nargs--; - count = build_int_cst (integer_type_node, nargs); new_stmt = gimple_build_assign (gimple_call_lhs (stmt), count); gsi_replace (©_gsi, new_stmt, false); @@ -3308,14 +3260,12 @@ initialize_inlined_parameters (copy_body_data *id, gimple *stmt, is set only for CALL_EXPR_RETURN_SLOT_OPT. MODIFY_DEST, if non-null, was the LHS of the MODIFY_EXPR to which this call is the RHS. - RETURN_BOUNDS holds a destination for returned bounds. - The return value is a (possibly null) value that holds the result as seen by the caller. */ static tree declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, - tree return_bounds, basic_block entry_bb) + basic_block entry_bb) { tree callee = id->src_fn; tree result = DECL_RESULT (callee); @@ -3494,20 +3444,6 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, /* Remember this so we can ignore it in remap_decls. */ id->retvar = var; - - /* If returned bounds are used, then make var for them. */ - if (return_bounds) - { - tree bndtemp = create_tmp_var (pointer_bounds_type_node, "retbnd"); - DECL_SEEN_IN_BIND_EXPR_P (bndtemp) = 1; - TREE_NO_WARNING (bndtemp) = 1; - declare_inline_vars (id->block, bndtemp); - - id->retbnd = bndtemp; - insert_init_stmt (id, entry_bb, - gimple_build_assign (bndtemp, chkp_get_zero_bounds_var ())); - } - return use; } @@ -4368,7 +4304,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) hash_map<tree, tree> *st = NULL; tree return_slot; tree modify_dest; - tree return_bounds = NULL; struct cgraph_edge *cg_edge; cgraph_inline_failed_t reason; basic_block return_block; @@ -4377,7 +4312,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) bool successfully_inlined = false; bool purge_dead_abnormal_edges; gcall *call_stmt; - unsigned int i; unsigned int prop_mask, src_properties; struct function *dst_cfun; tree simduid; @@ -4658,24 +4592,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) { modify_dest = gimple_call_lhs (stmt); - /* Remember where to copy returned bounds. */ - if (gimple_call_with_bounds_p (stmt) - && TREE_CODE (modify_dest) == SSA_NAME) - { - gcall *retbnd = chkp_retbnd_call_by_val (modify_dest); - if (retbnd) - { - return_bounds = gimple_call_lhs (retbnd); - /* If returned bounds are not used then just - remove unused call. */ - if (!return_bounds) - { - gimple_stmt_iterator iter = gsi_for_stmt (retbnd); - gsi_remove (&iter, true); - } - } - } - /* The function which we are inlining might not return a value, in which case we should issue a warning that the function does not return a value. In that case the optimizers will @@ -4706,8 +4622,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) } /* Declare the return variable for the function. */ - use_retvar = declare_return_variable (id, return_slot, modify_dest, - return_bounds, bb); + use_retvar = declare_return_variable (id, return_slot, modify_dest, bb); /* Add local vars in this inlined callee to caller. */ add_local_variables (id->src_cfun, cfun, id); @@ -4814,12 +4729,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) gimple_set_location (clobber_stmt, gimple_location (old_stmt)); gsi_insert_after (&stmt_gsi, clobber_stmt, GSI_SAME_STMT); } - - /* Copy bounds if we copy structure with bounds. */ - if (chkp_function_instrumented_p (id->dst_fn) - && !BOUNDED_P (use_retvar) - && chkp_type_has_pointer (TREE_TYPE (use_retvar))) - id->assign_stmts.safe_push (stmt); } else { @@ -4873,20 +4782,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) gsi_remove (&stmt_gsi, true); } - /* Put returned bounds into the correct place if required. */ - if (return_bounds) - { - gimple *old_stmt = SSA_NAME_DEF_STMT (return_bounds); - gimple *new_stmt = gimple_build_assign (return_bounds, id->retbnd); - gimple_stmt_iterator bnd_gsi = gsi_for_stmt (old_stmt); - unlink_stmt_vdef (old_stmt); - gsi_replace (&bnd_gsi, new_stmt, false); - maybe_clean_or_replace_eh_stmt (old_stmt, new_stmt); - cgraph_update_edges_for_call_stmt (old_stmt, - gimple_call_fndecl (old_stmt), - new_stmt); - } - if (purge_dead_abnormal_edges) { gimple_purge_dead_eh_edges (return_block); @@ -4903,9 +4798,6 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id) TREE_USED (gimple_assign_rhs1 (stmt)) = 1; } - /* Copy bounds for all generated assigns that need it. */ - for (i = 0; i < id->assign_stmts.length (); i++) - chkp_copy_bounds_for_assign (id->assign_stmts[i], cg_edge); id->assign_stmts.release (); /* Output the inlining info for this abstract function, since it has been diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 7625d1963ff..8ec32ccbcc1 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -339,11 +339,6 @@ extern void register_pass (register_pass_info *); extern void register_pass (opt_pass* pass, pass_positioning_ops pos, const char* ref_pass_name, int ref_pass_inst_number); -extern simple_ipa_opt_pass *make_pass_ipa_chkp_versioning (gcc::context *ctxt); -extern simple_ipa_opt_pass *make_pass_ipa_chkp_early_produce_thunks (gcc::context *ctxt); -extern simple_ipa_opt_pass *make_pass_ipa_chkp_produce_thunks (gcc::context *ctxt); -extern gimple_opt_pass *make_pass_chkp (gcc::context *ctxt); -extern gimple_opt_pass *make_pass_chkp_opt (gcc::context *ctxt); extern gimple_opt_pass *make_pass_asan (gcc::context *ctxt); extern gimple_opt_pass *make_pass_asan_O0 (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tsan (gcc::context *ctxt); @@ -492,7 +487,6 @@ extern simple_ipa_opt_pass *make_pass_ipa_tree_profile (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_auto_profile (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_build_ssa_passes (gcc::context *ctxt); -extern simple_ipa_opt_pass *make_pass_chkp_instrumentation_passes (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_local_optimization_passes (gcc::context *ctxt); extern ipa_opt_pass_d *make_pass_ipa_whole_program_visibility (gcc::context diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 125507ee348..c5fc04150d8 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1285,7 +1285,6 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, break; case VOID_TYPE: - case POINTER_BOUNDS_TYPE: case INTEGER_TYPE: case REAL_TYPE: case FIXED_POINT_TYPE: diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 5591097d018..2f0e54294ad 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -138,7 +138,6 @@ along with GCC; see the file COPYING3. If not see #include "dbgcnt.h" #include "params.h" #include "builtins.h" -#include "tree-chkp.h" #include "cfgloop.h" #include "stor-layout.h" #include "optabs-query.h" @@ -2080,8 +2079,6 @@ insert_clobber_before_stack_restore (tree saved_val, tree var, else if (gimple_assign_ssa_name_copy_p (stmt)) insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var, visited); - else if (chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET)) - continue; else gcc_assert (is_gimple_debug (stmt)); } diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 7ec3cc15854..d23148675c9 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -65,7 +65,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-dfa.h" #include "cfgloop.h" #include "tree-scalar-evolution.h" -#include "tree-chkp.h" #include "tree-ssa-propagate.h" #include "gimple-fold.h" @@ -778,21 +777,7 @@ propagate_necessity (bool aggressive) && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_ALIGNED_ALLOC || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC)) - { - gimple *bounds_def_stmt; - tree bounds; - - /* For instrumented calls we should also check used - bounds are returned by the same allocation call. */ - if (!gimple_call_with_bounds_p (stmt) - || ((bounds = gimple_call_arg (stmt, 1)) - && TREE_CODE (bounds) == SSA_NAME - && (bounds_def_stmt = SSA_NAME_DEF_STMT (bounds)) - && chkp_gimple_call_builtin_p (bounds_def_stmt, - BUILT_IN_CHKP_BNDRET) - && gimple_call_arg (bounds_def_stmt, 0) == ptr)) - continue; - } + continue; } FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) @@ -1276,23 +1261,6 @@ eliminate_unnecessary_stmts (void) && !gimple_plf (def_stmt, STMT_NECESSARY)) gimple_set_plf (stmt, STMT_NECESSARY, false); } - /* We did not propagate necessity for free calls fed - by allocation function to allow unnecessary - alloc-free sequence elimination. For instrumented - calls it also means we did not mark bounds producer - as necessary and it is time to do it in case free - call is not removed. */ - if (gimple_call_with_bounds_p (stmt)) - { - gimple *bounds_def_stmt; - tree bounds = gimple_call_arg (stmt, 1); - gcc_assert (TREE_CODE (bounds) == SSA_NAME); - bounds_def_stmt = SSA_NAME_DEF_STMT (bounds); - if (bounds_def_stmt - && !gimple_plf (bounds_def_stmt, STMT_NECESSARY)) - gimple_set_plf (bounds_def_stmt, STMT_NECESSARY, - gimple_plf (stmt, STMT_NECESSARY)); - } } /* If GSI is not necessary then remove it. */ @@ -1341,9 +1309,7 @@ eliminate_unnecessary_stmts (void) && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC && !ALLOCA_FUNCTION_CODE_P - (DECL_FUNCTION_CODE (call)))) - /* Avoid doing so for bndret calls for the same reason. */ - && !chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET)) + (DECL_FUNCTION_CODE (call))))) { something_changed = true; if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 11b1938216e..144902d15dc 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2781,7 +2781,6 @@ create_expression_by_pieces (basic_block block, pre_expr expr, args.quick_push (arg); } gcall *call = gimple_build_call_vec (fn, args); - gimple_call_set_with_bounds (call, currop->with_bounds); if (sc) gimple_call_set_chain (call, sc); tree forcedname = make_ssa_name (currop->type); diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 4aec41e96c1..b6cc8846435 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1133,8 +1133,6 @@ copy_reference_ops_from_call (gcall *call, if (stmt_could_throw_p (call) && (lr = lookup_stmt_eh_lp (call)) > 0) temp.op2 = size_int (lr); temp.off = -1; - if (gimple_call_with_bounds_p (call)) - temp.with_bounds = 1; result->safe_push (temp); /* Copy the call arguments. As they can be references as well, diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index 9356520cbe5..5857cfc1c8a 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -87,8 +87,6 @@ typedef struct vn_reference_op_struct /* Dependence info, used for [TARGET_]MEM_REF only. */ unsigned short clique; unsigned short base; - /* 1 for instrumented calls. */ - unsigned with_bounds : 1; unsigned reverse : 1; /* For storing TYPE_ALIGN for array ref element size computation. */ unsigned align : 6; diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 7a89174d6aa..804905d09a2 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -46,7 +46,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-propagate.h" #include "tree-ssa-strlen.h" #include "params.h" -#include "ipa-chkp.h" #include "tree-hash-traits.h" #include "tree-object-size.h" #include "builtins.h" @@ -576,7 +575,6 @@ get_string_length (strinfo *si) if (si->stmt) { gimple *stmt = si->stmt, *lenstmt; - bool with_bounds = gimple_call_with_bounds_p (stmt); tree callee, lhs, fn, tem; location_t loc; gimple_stmt_iterator gsi; @@ -595,20 +593,11 @@ get_string_length (strinfo *si) { case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHKP: - case BUILT_IN_STRCAT_CHK_CHKP: gsi = gsi_for_stmt (stmt); fn = builtin_decl_implicit (BUILT_IN_STRLEN); gcc_assert (lhs == NULL_TREE); tem = unshare_expr (gimple_call_arg (stmt, 0)); - if (with_bounds) - { - lenstmt = gimple_build_call (chkp_maybe_create_clone (fn)->decl, - 2, tem, gimple_call_arg (stmt, 1)); - gimple_call_set_with_bounds (lenstmt, true); - } - else - lenstmt = gimple_build_call (fn, 1, tem); + lenstmt = gimple_build_call (fn, 1, tem); lhs = make_ssa_name (TREE_TYPE (TREE_TYPE (fn)), lenstmt); gimple_call_set_lhs (lenstmt, lhs); gimple_set_vuse (lenstmt, gimple_vuse (stmt)); @@ -628,16 +617,8 @@ get_string_length (strinfo *si) lhs = NULL_TREE; /* FALLTHRU */ case BUILT_IN_STRCPY: - case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: gcc_assert (builtin_decl_implicit_p (BUILT_IN_STPCPY)); - if (gimple_call_num_args (stmt) == (with_bounds ? 4 : 2)) - fn = builtin_decl_implicit (BUILT_IN_STPCPY); - else - fn = builtin_decl_explicit (BUILT_IN_STPCPY_CHK); - if (with_bounds) - fn = chkp_maybe_create_clone (fn)->decl; + fn = builtin_decl_implicit (BUILT_IN_STPCPY); gcc_assert (lhs == NULL_TREE); if (dump_file && (dump_flags & TDF_DETAILS) != 0) { @@ -656,8 +637,6 @@ get_string_length (strinfo *si) /* FALLTHRU */ case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: gcc_assert (lhs != NULL_TREE); loc = gimple_location (stmt); set_endptr_and_length (loc, si, lhs); @@ -1002,9 +981,7 @@ valid_builtin_call (gimple *stmt) case BUILT_IN_MEMCMP: case BUILT_IN_MEMCMP_EQ: case BUILT_IN_STRCHR: - case BUILT_IN_STRCHR_CHKP: case BUILT_IN_STRLEN: - case BUILT_IN_STRLEN_CHKP: /* The above functions should be pure. Punt if they aren't. */ if (gimple_vdef (stmt) || gimple_vuse (stmt) == NULL_TREE) return false; @@ -1014,25 +991,15 @@ valid_builtin_call (gimple *stmt) case BUILT_IN_MALLOC: case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMPCPY_CHKP: - case BUILT_IN_MEMPCPY_CHK_CHKP: case BUILT_IN_MEMSET: case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHKP: - case BUILT_IN_STRCAT_CHK_CHKP: case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: /* The above functions should be neither const nor pure. Punt if they aren't. */ if (gimple_vdef (stmt) == NULL_TREE || gimple_vuse (stmt) == NULL_TREE) @@ -1121,10 +1088,6 @@ adjust_last_stmt (strinfo *si, gimple *stmt, bool is_strcat) case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: break; - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: - len_arg_no = 4; - break; default: return; } @@ -1328,12 +1291,11 @@ handle_builtin_strchr (gimple_stmt_iterator *gsi) tree src; gimple *stmt = gsi_stmt (*gsi); tree lhs = gimple_call_lhs (stmt); - bool with_bounds = gimple_call_with_bounds_p (stmt); if (lhs == NULL_TREE) return; - if (!integer_zerop (gimple_call_arg (stmt, with_bounds ? 2 : 1))) + if (!integer_zerop (gimple_call_arg (stmt, 1))) return; src = gimple_call_arg (stmt, 0); @@ -1440,9 +1402,8 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) gimple *stmt = gsi_stmt (*gsi); strinfo *si, *dsi, *olddsi, *zsi; location_t loc; - bool with_bounds = gimple_call_with_bounds_p (stmt); - src = gimple_call_arg (stmt, with_bounds ? 2 : 1); + src = gimple_call_arg (stmt, 1); dst = gimple_call_arg (stmt, 0); lhs = gimple_call_lhs (stmt); idx = get_stridx (src); @@ -1473,15 +1434,11 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) { case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: if (lhs != NULL_TREE || !builtin_decl_implicit_p (BUILT_IN_STPCPY)) return; break; case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: if (lhs == NULL_TREE) return; else @@ -1599,19 +1556,16 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) switch (bcode) { case BUILT_IN_STRCPY: - case BUILT_IN_STRCPY_CHKP: fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (lhs) ssa_ver_to_stridx[SSA_NAME_VERSION (lhs)] = didx; break; case BUILT_IN_STRCPY_CHK: - case BUILT_IN_STRCPY_CHK_CHKP: fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); if (lhs) ssa_ver_to_stridx[SSA_NAME_VERSION (lhs)] = didx; break; case BUILT_IN_STPCPY: - case BUILT_IN_STPCPY_CHKP: /* This would need adjustment of the lhs (subtract one), or detection that the trailing '\0' doesn't need to be written, if it will be immediately overwritten. @@ -1623,7 +1577,6 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) } break; case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STPCPY_CHK_CHKP: /* This would need adjustment of the lhs (subtract one), or detection that the trailing '\0' doesn't need to be written, if it will be immediately overwritten. @@ -1673,33 +1626,14 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) fprintf (dump_file, "Optimizing: "); print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); } - if (with_bounds) - { - fn = chkp_maybe_create_clone (fn)->decl; - if (gimple_call_num_args (stmt) == 4) - success = update_gimple_call (gsi, fn, 5, dst, - gimple_call_arg (stmt, 1), - src, - gimple_call_arg (stmt, 3), - len); - else - success = update_gimple_call (gsi, fn, 6, dst, - gimple_call_arg (stmt, 1), - src, - gimple_call_arg (stmt, 3), - len, - gimple_call_arg (stmt, 4)); - } + if (gimple_call_num_args (stmt) == 2) + success = update_gimple_call (gsi, fn, 3, dst, src, len); else - if (gimple_call_num_args (stmt) == 2) - success = update_gimple_call (gsi, fn, 3, dst, src, len); - else - success = update_gimple_call (gsi, fn, 4, dst, src, len, - gimple_call_arg (stmt, 2)); + success = update_gimple_call (gsi, fn, 4, dst, src, len, + gimple_call_arg (stmt, 2)); if (success) { stmt = gsi_stmt (*gsi); - gimple_call_set_with_bounds (stmt, with_bounds); update_stmt (stmt); if (dump_file && (dump_flags & TDF_DETAILS) != 0) { @@ -2068,11 +2002,9 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) gimple *stmt = gsi_stmt (*gsi); - bool with_bounds = gimple_call_with_bounds_p (stmt); - - tree dst = gimple_call_arg (stmt, with_bounds ? 1 : 0); - tree src = gimple_call_arg (stmt, with_bounds ? 2 : 1); - tree len = gimple_call_arg (stmt, with_bounds ? 3 : 2); + tree dst = gimple_call_arg (stmt, 0); + tree src = gimple_call_arg (stmt, 1); + tree len = gimple_call_arg (stmt, 2); tree dstsize = NULL_TREE, srcsize = NULL_TREE; int didx = get_stridx (dst); @@ -2177,10 +2109,9 @@ handle_builtin_memcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) tree src, dst, len, lhs, oldlen, newlen; gimple *stmt = gsi_stmt (*gsi); strinfo *si, *dsi, *olddsi; - bool with_bounds = gimple_call_with_bounds_p (stmt); - len = gimple_call_arg (stmt, with_bounds ? 4 : 2); - src = gimple_call_arg (stmt, with_bounds ? 2 : 1); + len = gimple_call_arg (stmt, 2); + src = gimple_call_arg (stmt, 1); dst = gimple_call_arg (stmt, 0); idx = get_stridx (src); if (idx == 0) @@ -2315,8 +2246,6 @@ handle_builtin_memcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) { case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: /* Allow adjust_last_stmt to decrease this memcpy's size. */ laststmt.stmt = stmt; laststmt.len = dsi->nonzero_chars; @@ -2326,8 +2255,6 @@ handle_builtin_memcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) break; case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMPCPY_CHKP: - case BUILT_IN_MEMPCPY_CHK_CHKP: break; default: gcc_unreachable (); @@ -2350,9 +2277,8 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) gimple *stmt = gsi_stmt (*gsi); strinfo *si, *dsi; location_t loc = gimple_location (stmt); - bool with_bounds = gimple_call_with_bounds_p (stmt); - tree src = gimple_call_arg (stmt, with_bounds ? 2 : 1); + tree src = gimple_call_arg (stmt, 1); tree dst = gimple_call_arg (stmt, 0); /* Bail if the source is the same as destination. It will be diagnosed @@ -2483,19 +2409,17 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) switch (bcode) { case BUILT_IN_STRCAT: - case BUILT_IN_STRCAT_CHKP: if (srclen != NULL_TREE) fn = builtin_decl_implicit (BUILT_IN_MEMCPY); else fn = builtin_decl_implicit (BUILT_IN_STRCPY); break; case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHK_CHKP: if (srclen != NULL_TREE) fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); else fn = builtin_decl_explicit (BUILT_IN_STRCPY_CHK); - objsz = gimple_call_arg (stmt, with_bounds ? 4 : 2); + objsz = gimple_call_arg (stmt, 2); break; default: gcc_unreachable (); @@ -2548,35 +2472,15 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) fprintf (dump_file, "Optimizing: "); print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); } - if (with_bounds) - { - fn = chkp_maybe_create_clone (fn)->decl; - if (srclen != NULL_TREE) - success = update_gimple_call (gsi, fn, 5 + (objsz != NULL_TREE), - dst, - gimple_call_arg (stmt, 1), - src, - gimple_call_arg (stmt, 3), - len, objsz); - else - success = update_gimple_call (gsi, fn, 4 + (objsz != NULL_TREE), - dst, - gimple_call_arg (stmt, 1), - src, - gimple_call_arg (stmt, 3), - objsz); - } + if (srclen != NULL_TREE) + success = update_gimple_call (gsi, fn, 3 + (objsz != NULL_TREE), + dst, src, len, objsz); else - if (srclen != NULL_TREE) - success = update_gimple_call (gsi, fn, 3 + (objsz != NULL_TREE), - dst, src, len, objsz); - else - success = update_gimple_call (gsi, fn, 2 + (objsz != NULL_TREE), - dst, src, objsz); + success = update_gimple_call (gsi, fn, 2 + (objsz != NULL_TREE), + dst, src, objsz); if (success) { stmt = gsi_stmt (*gsi); - gimple_call_set_with_bounds (stmt, with_bounds); update_stmt (stmt); if (dump_file && (dump_flags & TDF_DETAILS) != 0) { @@ -3423,21 +3327,15 @@ strlen_check_and_optimize_stmt (gimple_stmt_iterator *gsi, bool *cleanup_eh) switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_STRLEN: - case BUILT_IN_STRLEN_CHKP: handle_builtin_strlen (gsi); break; case BUILT_IN_STRCHR: - case BUILT_IN_STRCHR_CHKP: handle_builtin_strchr (gsi); break; case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: case BUILT_IN_STPCPY: case BUILT_IN_STPCPY_CHK: - case BUILT_IN_STRCPY_CHKP: - case BUILT_IN_STRCPY_CHK_CHKP: - case BUILT_IN_STPCPY_CHKP: - case BUILT_IN_STPCPY_CHK_CHKP: handle_builtin_strcpy (DECL_FUNCTION_CODE (callee), gsi); break; @@ -3457,16 +3355,10 @@ strlen_check_and_optimize_stmt (gimple_stmt_iterator *gsi, bool *cleanup_eh) case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY_CHK: - case BUILT_IN_MEMCPY_CHKP: - case BUILT_IN_MEMCPY_CHK_CHKP: - case BUILT_IN_MEMPCPY_CHKP: - case BUILT_IN_MEMPCPY_CHK_CHKP: handle_builtin_memcpy (DECL_FUNCTION_CODE (callee), gsi); break; case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: - case BUILT_IN_STRCAT_CHKP: - case BUILT_IN_STRCAT_CHK_CHKP: handle_builtin_strcat (DECL_FUNCTION_CODE (callee), gsi); break; case BUILT_IN_MALLOC: diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 26c1d4205ee..c8594851957 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -36,7 +36,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-into-ssa.h" #include "tree-cfg.h" #include "tree-stdarg.h" -#include "tree-chkp.h" /* A simple pass that attempts to optimize stdarg functions on architectures that need to save register arguments to stack on entry to stdarg functions. @@ -1038,11 +1037,6 @@ expand_ifn_va_arg_1 (function *fun) unsigned int nargs = gimple_call_num_args (stmt); gcc_assert (useless_type_conversion_p (TREE_TYPE (lhs), type)); - /* We replace call with a new expr. This may require - corresponding bndret call fixup. */ - if (chkp_function_instrumented_p (fun->decl)) - chkp_fixup_inlined_call (lhs, expr); - if (nargs == 4) { /* We've transported the size of with WITH_SIZE_EXPR here as diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 912fa5f0f02..02267406595 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -30,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-streamer.h" #include "cgraph.h" #include "builtins.h" -#include "ipa-chkp.h" #include "gomp-constants.h" #include "stringpool.h" #include "attribs.h" diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c index e4689615310..63fc45284e0 100644 --- a/gcc/tree-streamer.c +++ b/gcc/tree-streamer.c @@ -312,7 +312,6 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node) case IDENTIFIER_NODE: case INTEGER_CST: case INTEGER_TYPE: - case POINTER_BOUNDS_TYPE: case REAL_TYPE: case TREE_LIST: case VOID_CST: diff --git a/gcc/tree.c b/gcc/tree.c index 2c75953542b..b0c3a798470 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -827,7 +827,6 @@ tree_code_size (enum tree_code code) case UNION_TYPE: case QUAL_UNION_TYPE: case VOID_TYPE: - case POINTER_BOUNDS_TYPE: case FUNCTION_TYPE: case METHOD_TYPE: case LANG_TYPE: return sizeof (tree_type_non_common); @@ -1508,7 +1507,6 @@ wide_int_to_tree_1 (tree type, const wide_int_ref &pcst) case POINTER_TYPE: case REFERENCE_TYPE: - case POINTER_BOUNDS_TYPE: /* Cache NULL pointer and zero bounds. */ if (hwi == 0) { @@ -3783,7 +3781,6 @@ type_contains_placeholder_1 (const_tree type) switch (TREE_CODE (type)) { case VOID_TYPE: - case POINTER_BOUNDS_TYPE: case COMPLEX_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: @@ -9910,8 +9907,6 @@ build_common_tree_nodes (bool signed_char) void_type_node = make_node (VOID_TYPE); layout_type (void_type_node); - pointer_bounds_type_node = targetm.chkp_bound_type (); - /* We are not going to have real types in C with less than byte alignment, so we might as well not have any types that claim to have it. */ SET_TYPE_ALIGN (void_type_node, BITS_PER_UNIT); diff --git a/gcc/tree.def b/gcc/tree.def index 9696fee6813..cee41c2a9c9 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -31,11 +31,7 @@ along with GCC; see the file COPYING3. If not see These tree codes have been sorted so that the macros in tree.h that check for various tree codes are optimized into range checks. This gives a measurable performance improvement. When adding a new - code, consider its placement in relation to the other codes. - - When adding a new tree code which might appear as GIMPLE_ASSIGN RHS - code, proper handler in chkp_compute_bounds_for_assignment may - be required. */ + code, consider its placement in relation to the other codes. */ /* Any erroneous construct is parsed into a node of this type. This type of node is accepted without complaint in all contexts @@ -237,11 +233,6 @@ DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0) /* The void type in C */ DEFTREECODE (VOID_TYPE, "void_type", tcc_type, 0) -/* Type to hold bounds for a pointer. - Has TYPE_PRECISION component to specify number of bits used - by this type. */ -DEFTREECODE (POINTER_BOUNDS_TYPE, "pointer_bounds_type", tcc_type, 0) - /* Type of functions. Special fields: TREE_TYPE type of value returned. TYPE_ARG_TYPES list of types of arguments expected. diff --git a/gcc/tree.h b/gcc/tree.h index ef8bff405fe..79b675025d9 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -595,21 +595,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, /* Nonzero if this type is a complete type. */ #define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE) -/* Nonzero if this type is a pointer bounds type. */ -#define POINTER_BOUNDS_TYPE_P(NODE) \ - (TREE_CODE (NODE) == POINTER_BOUNDS_TYPE) - -/* Nonzero if this node has a pointer bounds type. */ -#define POINTER_BOUNDS_P(NODE) \ - (POINTER_BOUNDS_TYPE_P (TREE_TYPE (NODE))) - -/* Nonzero if this type supposes bounds existence. */ -#define BOUNDED_TYPE_P(type) (POINTER_TYPE_P (type)) - -/* Nonzero for objects with bounded type. */ -#define BOUNDED_P(node) \ - BOUNDED_TYPE_P (TREE_TYPE (node)) - /* Nonzero if this type is the (possibly qualified) void type. */ #define VOID_TYPE_P(NODE) (TREE_CODE (NODE) == VOID_TYPE) @@ -918,9 +903,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, #define CALL_ALLOCA_FOR_VAR_P(NODE) \ (CALL_EXPR_CHECK (NODE)->base.protected_flag) -/* In a CALL_EXPR, means call was instrumented by Pointer Bounds Checker. */ -#define CALL_WITH_BOUNDS_P(NODE) (CALL_EXPR_CHECK (NODE)->base.deprecated_flag) - /* Used in classes in C++. */ #define TREE_PRIVATE(NODE) ((NODE)->base.private_flag) /* Used in classes in C++. */ @@ -3856,8 +3838,6 @@ tree_strip_any_location_wrapper (tree exp) #define COMPLEX_FLOATN_NX_TYPE_NODE(IDX) global_trees[TI_COMPLEX_FLOATN_NX_TYPE_FIRST + (IDX)] -#define pointer_bounds_type_node global_trees[TI_POINTER_BOUNDS_TYPE] - #define void_type_node global_trees[TI_VOID_TYPE] /* The C type `void *'. */ #define ptr_type_node global_trees[TI_PTR_TYPE] diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 16cdbd64f46..d50a179b27d 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see #include "dumpfile.h" #include "builtins.h" #include "params.h" -#include "tree-chkp.h" /* In this file value profile based optimizations are placed. Currently the following optimizations are implemented (for more detailed descriptions @@ -1299,7 +1298,6 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, gcall *dcall_stmt; gassign *load_stmt; gcond *cond_stmt; - gcall *iretbnd_stmt = NULL; tree tmp0, tmp1, tmp; basic_block cond_bb, dcall_bb, icall_bb, join_bb = NULL; tree optype = build_pointer_type (void_type_node); @@ -1308,14 +1306,10 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, int lp_nr, dflags; edge e_eh, e; edge_iterator ei; - gimple_stmt_iterator psi; cond_bb = gimple_bb (icall_stmt); gsi = gsi_for_stmt (icall_stmt); - if (gimple_call_with_bounds_p (icall_stmt) && gimple_call_lhs (icall_stmt)) - iretbnd_stmt = chkp_retbnd_call_by_val (gimple_call_lhs (icall_stmt)); - tmp0 = make_temp_ssa_name (optype, NULL, "PROF"); tmp1 = make_temp_ssa_name (optype, NULL, "PROF"); tmp = unshare_expr (gimple_call_fn (icall_stmt)); @@ -1405,55 +1399,6 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, gimple_call_set_lhs (dcall_stmt, duplicate_ssa_name (result, dcall_stmt)); add_phi_arg (phi, gimple_call_lhs (dcall_stmt), e_dj, UNKNOWN_LOCATION); - - /* If indirect call has following BUILT_IN_CHKP_BNDRET - call then we need to make it's copy for the direct - call. */ - if (iretbnd_stmt) - { - if (gimple_call_lhs (iretbnd_stmt)) - { - gimple *copy; - - if (TREE_CODE (gimple_vdef (iretbnd_stmt)) == SSA_NAME) - { - unlink_stmt_vdef (iretbnd_stmt); - release_ssa_name (gimple_vdef (iretbnd_stmt)); - } - gimple_set_vdef (iretbnd_stmt, NULL_TREE); - gimple_set_vuse (iretbnd_stmt, NULL_TREE); - update_stmt (iretbnd_stmt); - - result = gimple_call_lhs (iretbnd_stmt); - phi = create_phi_node (result, join_bb); - - copy = gimple_copy (iretbnd_stmt); - gimple_call_set_arg (copy, 0, - gimple_call_lhs (dcall_stmt)); - gimple_call_set_lhs (copy, duplicate_ssa_name (result, copy)); - gsi_insert_on_edge (e_dj, copy); - add_phi_arg (phi, gimple_call_lhs (copy), - e_dj, UNKNOWN_LOCATION); - - gimple_call_set_arg (iretbnd_stmt, 0, - gimple_call_lhs (icall_stmt)); - gimple_call_set_lhs (iretbnd_stmt, - duplicate_ssa_name (result, iretbnd_stmt)); - psi = gsi_for_stmt (iretbnd_stmt); - gsi_remove (&psi, false); - gsi_insert_on_edge (e_ij, iretbnd_stmt); - add_phi_arg (phi, gimple_call_lhs (iretbnd_stmt), - e_ij, UNKNOWN_LOCATION); - - gsi_commit_one_edge_insert (e_dj, NULL); - gsi_commit_one_edge_insert (e_ij, NULL); - } - else - { - psi = gsi_for_stmt (iretbnd_stmt); - gsi_remove (&psi, true); - } - } } /* Build an EH edge for the direct call if necessary. */ diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 16e1ea8f997..acd93e58edf 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -9898,8 +9898,7 @@ vt_add_function_parameters (void) for (parm = DECL_ARGUMENTS (current_function_decl); parm; parm = DECL_CHAIN (parm)) - if (!POINTER_BOUNDS_P (parm)) - vt_add_function_parameter (parm); + vt_add_function_parameter (parm); if (DECL_HAS_VALUE_EXPR_P (DECL_RESULT (current_function_decl))) { diff --git a/gcc/varasm.c b/gcc/varasm.c index 4d332f50270..5769bc6d63e 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1377,10 +1377,6 @@ make_decl_rtl (tree decl) } id = DECL_ASSEMBLER_NAME (decl); - if (TREE_CODE (decl) == FUNCTION_DECL - && cgraph_node::get (decl) - && cgraph_node::get (decl)->instrumentation_clone) - ultimate_transparent_alias_target (&id); name = IDENTIFIER_POINTER (id); if (name[0] != '*' && TREE_CODE (decl) != FUNCTION_DECL @@ -1832,10 +1828,7 @@ assemble_start_function (tree decl, const char *fnname) /* Make function name accessible from other files, if appropriate. */ - if (TREE_PUBLIC (decl) - || (cgraph_node::get (decl)->instrumentation_clone - && cgraph_node::get (decl)->instrumented_version - && TREE_PUBLIC (cgraph_node::get (decl)->instrumented_version->decl))) + if (TREE_PUBLIC (decl)) { notice_global_symbol (decl); @@ -4912,7 +4905,6 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align, case REFERENCE_TYPE: case OFFSET_TYPE: case FIXED_POINT_TYPE: - case POINTER_BOUNDS_TYPE: case NULLPTR_TYPE: cst = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); if (reverse) @@ -5821,11 +5813,6 @@ do_assemble_alias (tree decl, tree target) #ifdef ASM_OUTPUT_DEF tree orig_decl = decl; - if (TREE_CODE (decl) == FUNCTION_DECL - && cgraph_node::get (decl)->instrumentation_clone - && cgraph_node::get (decl)->instrumented_version) - orig_decl = cgraph_node::get (decl)->instrumented_version->decl; - /* Make name accessible from other files, if appropriate. */ if (TREE_PUBLIC (decl) || TREE_PUBLIC (orig_decl)) @@ -6150,13 +6137,6 @@ int maybe_assemble_visibility (tree decl) { enum symbol_visibility vis = DECL_VISIBILITY (decl); - - if (TREE_CODE (decl) == FUNCTION_DECL - && cgraph_node::get (decl) - && cgraph_node::get (decl)->instrumentation_clone - && cgraph_node::get (decl)->instrumented_version) - vis = DECL_VISIBILITY (cgraph_node::get (decl)->instrumented_version->decl); - if (vis != VISIBILITY_DEFAULT) { targetm.asm_out.assemble_visibility (decl, vis); diff --git a/gcc/varpool.c b/gcc/varpool.c index 418753cca2a..afba2deca14 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -400,12 +400,6 @@ ctor_for_folding (tree decl) if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL) return error_mark_node; - /* Static constant bounds are created to be - used instead of constants and therefore - do not let folding it. */ - if (POINTER_BOUNDS_P (decl)) - return error_mark_node; - if (TREE_CODE (decl) == CONST_DECL || DECL_IN_CONSTANT_POOL (decl)) return DECL_INITIAL (decl); |