From 4e91a07b9010003cb22c22c20c6aa6417a57333b Mon Sep 17 00:00:00 2001 From: msebor Date: Fri, 2 Sep 2016 02:14:50 +0000 Subject: PR tree-optimization/71831 - __builtin_object_size poor results with no optimization gcc/testsuite/ChangeLog: PR tree-optimization/71831 * gcc.dg/builtin-object-size-16.c: New test. * gcc.dg/builtin-object-size-17.c: New test. gcc/ChangeLog: PR tree-optimization/71831 * tree-object-size.h: Return bool instead of the size and add argument for the size. * tree-object-size.c (compute_object_offset): Update signature. (addr_object_size): Same. (compute_builtin_object_size): Return bool instead of the size and add argument for the size. Handle POINTER_PLUS_EXPR when optimization is disabled. (expr_object_size): Adjust. (plus_stmt_object_size): Adjust. (pass_object_sizes::execute): Adjust. * builtins.c (fold_builtin_object_size): Adjust. * doc/extend.texi (Object Size Checking): Update. * ubsan.c (instrument_object_size): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239953 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/builtins.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gcc/builtins.c') diff --git a/gcc/builtins.c b/gcc/builtins.c index b981bcd281a..1073e35b17b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -9615,7 +9615,7 @@ fold_builtin_object_size (tree ptr, tree ost) if (TREE_CODE (ptr) == ADDR_EXPR) { - bytes = compute_builtin_object_size (ptr, object_size_type); + compute_builtin_object_size (ptr, object_size_type, &bytes); if (wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } @@ -9624,9 +9624,8 @@ fold_builtin_object_size (tree ptr, tree ost) /* If object size is not known yet, delay folding until later. Maybe subsequent passes will help determining it. */ - bytes = compute_builtin_object_size (ptr, object_size_type); - if (bytes != (unsigned HOST_WIDE_INT) (object_size_type < 2 ? -1 : 0) - && wi::fits_to_tree_p (bytes, size_type_node)) + if (compute_builtin_object_size (ptr, object_size_type, &bytes) + && wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } -- cgit v1.2.1 From acbc95ac1c85f2a0057a1d9dab3405377bb463d3 Mon Sep 17 00:00:00 2001 From: edlinger Date: Fri, 9 Sep 2016 23:08:54 +0000 Subject: 2016-09-10 Bernd Edlinger * doc/tm.texi.in (INITIAL_FRAME_POINTER_OFFSET): Remove. (ELIMINABLE_REGS, TARGET_CAN_ELIMINATE, INITIAL_ELIMINATION_OFFSET) : Update documentation. * target.def (frame_pointer_required, can_eliminate): Likewise. * doc/tm.texi: Regenerated. * builtins.c (expand_builtin_setjmp_receiver): Remove #ifdef ELIMINABLE_REGS. * df-scan.c (df_hard_reg_init): Likewise. * ira.c (ira_setup_eliminable_regset): Likewise. * lra-eliminations.c (reg_eliminate_1, (update_reg_eliminate, init_elim_table): Likewise. * reload1.c (reg_eliminate_1, verify_initial_elim_offsets, set_initial_elim_offsets, update_eliminables, init_elim_table): Likewise. * rtlanal.c (get_initial_register_offset): Likewise. * config/ft32/ft32.h (INITIAL_FRAME_POINTER_OFFSET): Remove. * config/m32r/m32r.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. * config/moxie/moxie.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. * config/vax/vax.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. * config/fr30/fr30.h: Fix comment. * config/frv/frv.c: Likewise. * config/frv/frv.h: Likewise. * config/ft32/ft32.h: Likewise. * config/visium/visium.h: Likewise. * config/pa/pa64-linux.h: Likewise. * config/v850/v850.h: Likewise. * config/cris/cris.c: Likewise. * config/ia64/ia64.h: Likewise. * config/moxie/moxie.h: Likewise. * config/m32r/m32r.h: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240058 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/builtins.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/builtins.c') diff --git a/gcc/builtins.c b/gcc/builtins.c index 1073e35b17b..4a2a398744b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -862,7 +862,6 @@ expand_builtin_setjmp_receiver (rtx receiver_label) if (!HARD_FRAME_POINTER_IS_ARG_POINTER && fixed_regs[ARG_POINTER_REGNUM]) { -#ifdef ELIMINABLE_REGS /* If the argument pointer can be eliminated in favor of the frame pointer, we don't need to restore it. We assume here that if such an elimination is present, it can always be used. @@ -877,7 +876,6 @@ expand_builtin_setjmp_receiver (rtx receiver_label) break; if (i == ARRAY_SIZE (elim_regs)) -#endif { /* Now restore our arg pointer from the address at which it was saved in our stack frame. */ -- cgit v1.2.1 From 3bb45f768ac518fea4baca349f976a2f30503478 Mon Sep 17 00:00:00 2001 From: vries Date: Sat, 10 Sep 2016 14:38:56 +0000 Subject: Make canonical_va_list_type more strict 2016-09-10 Tom de Vries PR C/71602 * builtins.c (std_canonical_va_list_type): Strictly return non-null for va_list type only. * config/i386/i386.c (ix86_canonical_va_list_type): Same. * gimplify.c (gimplify_va_arg_expr): Handle &va_list. * c-common.c (build_va_arg): Handle more strict targetm.canonical_va_list_type. Replace first argument type error with assert. * c-c++-common/va-arg-va-list-type.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240072 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/builtins.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gcc/builtins.c') diff --git a/gcc/builtins.c b/gcc/builtins.c index 4a2a398744b..e779c71ba40 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4087,10 +4087,6 @@ std_canonical_va_list_type (tree type) { tree wtype, htype; - if (INDIRECT_REF_P (type)) - type = TREE_TYPE (type); - else if (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE (type))) - type = TREE_TYPE (type); wtype = va_list_type_node; htype = type; /* Treat structure va_list types. */ -- cgit v1.2.1 From ac29ece21d1243ab39f49fd72ef7c171cf1feaee Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 16 Sep 2016 19:20:44 +0000 Subject: Add inline functions for various bitwise operations. * hwint.h (least_bit_hwi, pow2_or_zerop, pow2p_hwi, ctz_or_zero): New. * hwint.c (exact_log2): Use pow2p_hwi. (ctz_hwi, ffs_hwi): Use least_bit_hwi. * alias.c (memrefs_conflict_p): Use pow2_or_zerop. * builtins.c (get_object_alignment_2, get_object_alignment) (get_pointer_alignment, fold_builtin_atomic_always_lock_free): Use least_bit_hwi. * calls.c (compute_argument_addresses, store_one_arg): Use least_bit_hwi. * cfgexpand.c (expand_one_stack_var_at): Use least_bit_hwi. * combine.c (force_to_mode): Use least_bit_hwi. * emit-rtl.c (set_mem_attributes_minus_bitpos, adjust_address_1): Use least_bit_hwi. * expmed.c (synth_mult, expand_divmod): Use ctz_or_zero, ctz_hwi. (init_expmed_one_conv): Use pow2p_hwi. * fold-const.c (round_up_loc, round_down_loc): Use pow2_or_zerop. (fold_binary_loc): Use pow2p_hwi. * function.c (assign_parm_find_stack_rtl): Use least_bit_hwi. * gimple-fold.c (gimple_fold_builtin_memory_op): Use pow2p_hwi. * gimple-ssa-strength-reduction.c (replace_ref): Use least_bit_hwi. * hsa-gen.c (gen_hsa_addr_with_align, hsa_bitmemref_alignment): Use least_bit_hwi. * ipa-cp.c (ipcp_alignment_lattice::meet_with_1): Use least_bit_hwi. * ipa-prop.c (ipa_modify_call_arguments): Use least_bit_hwi. * omp-low.c (oacc_loop_fixed_partitions) (oacc_loop_auto_partitions): Use least_bit_hwi. * rtlanal.c (nonzero_bits1): Use ctz_or_zero. * stor-layout.c (place_field): Use least_bit_hwi. * tree-pretty-print.c (dump_generic_node): Use pow2p_hwi. * tree-sra.c (build_ref_for_offset): Use least_bit_hwi. * tree-ssa-ccp.c (ccp_finalize): Use least_bit_hwi. * tree-ssa-math-opts.c (bswap_replace): Use least_bit_hwi. * tree-ssa-strlen.c (handle_builtin_memcmp): Use pow2p_hwi. * tree-vect-data-refs.c (vect_analyze_group_access_1) (vect_grouped_store_supported, vect_grouped_load_supported) (vect_permute_load_chain, vect_shift_permute_load_chain) (vect_transform_grouped_load): Use pow2p_hwi. * tree-vect-generic.c (expand_vector_divmod): Use ctz_or_zero. * tree-vect-patterns.c (vect_recog_divmod_pattern): Use ctz_or_zero. * tree-vect-stmts.c (vectorizable_mask_load_store): Use least_bit_hwi. * tsan.c (instrument_expr): Use least_bit_hwi. * var-tracking.c (negative_power_of_two_p): Use pow2_or_zerop. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240194 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/builtins.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/builtins.c') diff --git a/gcc/builtins.c b/gcc/builtins.c index e779c71ba40..189aeac6912 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -305,7 +305,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, { ptr_bitmask = TREE_INT_CST_LOW (TREE_OPERAND (addr, 1)); ptr_bitmask *= BITS_PER_UNIT; - align = ptr_bitmask & -ptr_bitmask; + align = least_bit_hwi (ptr_bitmask); addr = TREE_OPERAND (addr, 0); } @@ -325,7 +325,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT step = 1; if (TMR_STEP (exp)) step = TREE_INT_CST_LOW (TMR_STEP (exp)); - align = MIN (align, (step & -step) * BITS_PER_UNIT); + align = MIN (align, least_bit_hwi (step) * BITS_PER_UNIT); } if (TMR_INDEX2 (exp)) align = BITS_PER_UNIT; @@ -404,7 +404,7 @@ get_object_alignment (tree exp) ptr & (align - 1) == bitpos. */ if (bitpos != 0) - align = (bitpos & -bitpos); + align = least_bit_hwi (bitpos); return align; } @@ -502,7 +502,7 @@ get_pointer_alignment (tree exp) ptr & (align - 1) == bitpos. */ if (bitpos != 0) - align = (bitpos & -bitpos); + align = least_bit_hwi (bitpos); return align; } @@ -5559,7 +5559,7 @@ fold_builtin_atomic_always_lock_free (tree arg0, tree arg1) /* Either this argument is null, or it's a fake pointer encoding the alignment of the object. */ - val = val & -val; + val = least_bit_hwi (val); val *= BITS_PER_UNIT; if (val == 0 || mode_align < val) -- cgit v1.2.1