Hi! I've committed several backports patches from trunk to 4.8 branch after bootstrapping/regtesting them on x86_64-linux and i686-linux.
Jakub
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-06 Jakub Jelinek <ja...@redhat.com> Meador Inge <mead...@codesourcery.com> PR target/58595 * config/arm/arm.c (arm_tls_symbol_p): Remove. (arm_legitimize_address): Call legitimize_tls_address for any arm_tls_referenced_p expression, handle constant addend. Call it before testing for !TARGET_ARM. (thumb_legitimize_address): Don't handle arm_tls_symbol_p here. 2014-03-06 Jakub Jelinek <ja...@redhat.com> PR target/58595 * gcc.dg/tls/pr58595.c: New test. --- gcc/config/arm/arm.c (revision 208379) +++ gcc/config/arm/arm.c (revision 208380) @@ -235,7 +235,6 @@ static tree arm_gimplify_va_arg_expr (tr static void arm_option_override (void); static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode); static bool arm_cannot_copy_insn_p (rtx); -static bool arm_tls_symbol_p (rtx x); static int arm_issue_rate (void); static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; static bool arm_output_addr_const_extra (FILE *, rtx); @@ -7336,6 +7335,32 @@ legitimize_tls_address (rtx x, rtx reg) rtx arm_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode) { + if (arm_tls_referenced_p (x)) + { + rtx addend = NULL; + + if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS) + { + addend = XEXP (XEXP (x, 0), 1); + x = XEXP (XEXP (x, 0), 0); + } + + if (GET_CODE (x) != SYMBOL_REF) + return x; + + gcc_assert (SYMBOL_REF_TLS_MODEL (x) != 0); + + x = legitimize_tls_address (x, NULL_RTX); + + if (addend) + { + x = gen_rtx_PLUS (SImode, x, addend); + orig_x = x; + } + else + return x; + } + if (!TARGET_ARM) { /* TODO: legitimize_address for Thumb2. */ @@ -7344,9 +7369,6 @@ arm_legitimize_address (rtx x, rtx orig_ return thumb_legitimize_address (x, orig_x, mode); } - if (arm_tls_symbol_p (x)) - return legitimize_tls_address (x, NULL_RTX); - if (GET_CODE (x) == PLUS) { rtx xop0 = XEXP (x, 0); @@ -7459,9 +7481,6 @@ arm_legitimize_address (rtx x, rtx orig_ rtx thumb_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode) { - if (arm_tls_symbol_p (x)) - return legitimize_tls_address (x, NULL_RTX); - if (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1)) && (INTVAL (XEXP (x, 1)) >= 32 * GET_MODE_SIZE (mode) @@ -7756,20 +7775,6 @@ thumb_legitimize_reload_address (rtx *x_ /* Test for various thread-local symbols. */ -/* Return TRUE if X is a thread-local symbol. */ - -static bool -arm_tls_symbol_p (rtx x) -{ - if (! TARGET_HAVE_TLS) - return false; - - if (GET_CODE (x) != SYMBOL_REF) - return false; - - return SYMBOL_REF_TLS_MODEL (x) != 0; -} - /* Helper for arm_tls_referenced_p. */ static int --- gcc/testsuite/gcc.dg/tls/pr58595.c (revision 0) +++ gcc/testsuite/gcc.dg/tls/pr58595.c (revision 208380) @@ -0,0 +1,28 @@ +/* PR target/58595 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ +/* { dg-require-effective-target tls } */ +/* { dg-require-effective-target sync_int_long } */ + +struct S { unsigned long a, b; }; +__thread struct S s; +void bar (unsigned long *); + +__attribute__((noinline)) void +foo (void) +{ + int i; + for (i = 0; i < 10; i++) + __sync_fetch_and_add (&s.b, 1L); +} + +int +main () +{ + s.b = 12; + foo (); + if (s.b != 22) + __builtin_abort (); + return 0; +}
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-13 Jakub Jelinek <ja...@redhat.com> PR middle-end/36282 * c-pragma.c (apply_pragma_weak): Only look at TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) if DECL_ASSEMBLER_NAME_SET_P (decl). (maybe_apply_pending_pragma_weaks): Exit early if vec_safe_is_empty (pending_weaks) rather than only when !pending_weaks. (maybe_apply_pragma_weak): Likewise. If !DECL_ASSEMBLER_NAME_SET_P, set assembler name back to NULL afterwards. * c-c++-common/pr36282-1.c: New test. * c-c++-common/pr36282-2.c: New test. * c-c++-common/pr36282-3.c: New test. * c-c++-common/pr36282-4.c: New test. --- gcc/c-family/c-pragma.c (revision 208556) +++ gcc/c-family/c-pragma.c (revision 208557) @@ -263,6 +263,7 @@ apply_pragma_weak (tree decl, tree value if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl) && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma. */ + && DECL_ASSEMBLER_NAME_SET_P (decl) && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) warning (OPT_Wpragmas, "applying #pragma weak %q+D after first use " "results in unspecified behavior", decl); @@ -280,7 +281,7 @@ maybe_apply_pragma_weak (tree decl) /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */ /* No weak symbols pending, take the short-cut. */ - if (!pending_weaks) + if (vec_safe_is_empty (pending_weaks)) return; /* If it's not visible outside this file, it doesn't matter whether it's weak. */ @@ -292,7 +293,13 @@ maybe_apply_pragma_weak (tree decl) if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) return; - id = DECL_ASSEMBLER_NAME (decl); + if (DECL_ASSEMBLER_NAME_SET_P (decl)) + id = DECL_ASSEMBLER_NAME (decl); + else + { + id = DECL_ASSEMBLER_NAME (decl); + SET_DECL_ASSEMBLER_NAME (decl, NULL_TREE); + } FOR_EACH_VEC_ELT (*pending_weaks, i, pe) if (id == pe->name) @@ -313,7 +320,7 @@ maybe_apply_pending_pragma_weaks (void) pending_weak *pe; symtab_node *target; - if (!pending_weaks) + if (vec_safe_is_empty (pending_weaks)) return; FOR_EACH_VEC_ELT (*pending_weaks, i, pe) --- gcc/testsuite/c-c++-common/pr36282-1.c (revision 0) +++ gcc/testsuite/c-c++-common/pr36282-1.c (revision 208557) @@ -0,0 +1,12 @@ +/* PR middle-end/36282 */ +/* { dg-do compile } */ + +#pragma weak bar + +extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n); +extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */ + +void +foo (void) +{ +} --- gcc/testsuite/c-c++-common/pr36282-2.c (revision 0) +++ gcc/testsuite/c-c++-common/pr36282-2.c (revision 208557) @@ -0,0 +1,10 @@ +/* PR middle-end/36282 */ +/* { dg-do compile } */ + +extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n); +extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */ + +void +foo (void) +{ +} --- gcc/testsuite/c-c++-common/pr36282-4.c (revision 0) +++ gcc/testsuite/c-c++-common/pr36282-4.c (revision 208557) @@ -0,0 +1,13 @@ +/* PR middle-end/36282 */ +/* { dg-do compile } */ + +#pragma weak bar +void bar (void); + +extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n); +extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */ + +void +foo (void) +{ +} --- gcc/testsuite/c-c++-common/pr36282-3.c (revision 0) +++ gcc/testsuite/c-c++-common/pr36282-3.c (revision 208557) @@ -0,0 +1,13 @@ +/* PR middle-end/36282 */ +/* { dg-do compile } */ + +void bar (void); +#pragma weak bar + +extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n); +extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */ + +void +foo (void) +{ +}
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-17 Jakub Jelinek <ja...@redhat.com> PR target/60516 * config/i386/i386.c (ix86_expand_epilogue): Adjust REG_CFA_ADJUST_CFA note creation for the 2010-08-31 changes. * gcc.target/i386/pr60516.c: New test. --- gcc/config/i386/i386.c (revision 208622) +++ gcc/config/i386/i386.c (revision 208623) @@ -11708,8 +11708,9 @@ ix86_expand_epilogue (int style) m->fs.cfa_offset -= UNITS_PER_WORD; m->fs.sp_offset -= UNITS_PER_WORD; - add_reg_note (insn, REG_CFA_ADJUST_CFA, - copy_rtx (XVECEXP (PATTERN (insn), 0, 1))); + rtx x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD); + x = gen_rtx_SET (VOIDmode, stack_pointer_rtx, x); + add_reg_note (insn, REG_CFA_ADJUST_CFA, x); add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (VOIDmode, ecx, pc_rtx)); RTX_FRAME_RELATED_P (insn) = 1; --- gcc/testsuite/gcc.target/i386/pr60516.c (revision 0) +++ gcc/testsuite/gcc.target/i386/pr60516.c (revision 208623) @@ -0,0 +1,20 @@ +/* PR target/60516 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct S { char c[65536]; }; + +__attribute__((ms_abi, thiscall)) void +foo (void *x, struct S y) +{ +} + +__attribute__((ms_abi, fastcall)) void +bar (void *x, void *y, struct S z) +{ +} + +__attribute__((ms_abi, stdcall)) void +baz (struct S x) +{ +}
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-22 Jakub Jelinek <ja...@redhat.com> PR debug/60603 * c-opts.c (c_finish_options): Restore cb_file_change call to <built-in>. * cpp.c (gfc_cpp_init): Restore cb_change_file call to <built-in>. * gcc.dg/debug/dwarf2/dwarf2-macro2.c: New test. --- gcc/c-family/c-opts.c (revision 208762) +++ gcc/c-family/c-opts.c (revision 208763) @@ -1274,17 +1274,18 @@ c_finish_options (void) { size_t i; - { - /* Make sure all of the builtins about to be declared have - BUILTINS_LOCATION has their source_location. */ - source_location builtins_loc = BUILTINS_LOCATION; - cpp_force_token_locations (parse_in, &builtins_loc); + cb_file_change (parse_in, + linemap_add (line_table, LC_RENAME, 0, + _("<built-in>"), 0)); + /* Make sure all of the builtins about to be declared have + BUILTINS_LOCATION has their source_location. */ + source_location builtins_loc = BUILTINS_LOCATION; + cpp_force_token_locations (parse_in, &builtins_loc); - cpp_init_builtins (parse_in, flag_hosted); - c_cpp_builtins (parse_in); + cpp_init_builtins (parse_in, flag_hosted); + c_cpp_builtins (parse_in); - cpp_stop_forcing_token_locations (parse_in); - } + cpp_stop_forcing_token_locations (parse_in); /* We're about to send user input to cpplib, so make it warn for things that we previously (when we sent it internal definitions) --- gcc/fortran/cpp.c (revision 208762) +++ gcc/fortran/cpp.c (revision 208763) @@ -576,6 +576,7 @@ gfc_cpp_init (void) if (gfc_option.flag_preprocessed) return; + cpp_change_file (cpp_in, LC_RENAME, _("<built-in>")); if (!gfc_cpp_option.no_predefined) { /* Make sure all of the builtins about to be declared have --- gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro2.c (revision 0) +++ gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro2.c (revision 208763) @@ -0,0 +1,7 @@ +/* Test to make sure the macro info includes the predefined macros with line number 0. */ +/* { dg-do compile } */ +/* { dg-options "-g3 -gdwarf-2 -dA -fverbose-asm" } */ +/* { dg-final { scan-assembler "At line number 0" } } */ + +#define FOO 1 +int i;
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-28 Jakub Jelinek <ja...@redhat.com> PR c++/60689 * c-tree.h (c_build_function_call_vec): New prototype. * c-typeck.c (build_function_call_vec): Don't call resolve_overloaded_builtin here. (c_build_function_call_vec): New wrapper function around build_function_call_vec. Call resolve_overloaded_builtin here. (convert_lvalue_to_rvalue, build_function_call, build_atomic_assign): Call c_build_function_call_vec instead of build_function_call_vec. * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. * c-decl.c (finish_decl): Likewise. * c-common.c (add_atomic_size_parameter): When creating new params vector, push the size argument first. * c-c++-common/pr60689.c: New test. --- gcc/c-family/c-common.c (revision 208911) +++ gcc/c-family/c-common.c (revision 208912) @@ -10453,6 +10453,7 @@ add_atomic_size_parameter (unsigned n, l len = params->length (); vec_alloc (v, len + 1); + v->quick_push (build_int_cst (size_type_node, n)); for (z = 0; z < len; z++) v->quick_push ((*params)[z]); f = build_function_call_vec (loc, vNULL, function, v, NULL); --- gcc/c/c-parser.c (revision 208911) +++ gcc/c/c-parser.c (revision 208912) @@ -6904,8 +6904,8 @@ c_parser_postfix_expression_after_primar sizeof_ptr_memacc_comptypes); /* FIXME diagnostics: Ideally we want the FUNCNAME, not the "(" after the FUNCNAME, which is what we have now. */ - expr.value = build_function_call_vec (op_loc, expr.value, exprlist, - origtypes); + expr.value = c_build_function_call_vec (op_loc, expr.value, exprlist, + origtypes); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) == INTEGER_CST && TREE_CODE (orig_expr.value) == FUNCTION_DECL --- gcc/c/c-typeck.c (revision 208911) +++ gcc/c/c-typeck.c (revision 208912) @@ -2666,7 +2666,7 @@ build_function_call (location_t loc, tre vec_alloc (v, list_length (params)); for (; params; params = TREE_CHAIN (params)) v->quick_push (TREE_VALUE (params)); - ret = build_function_call_vec (loc, function, v, NULL); + ret = c_build_function_call_vec (loc, function, v, NULL); vec_free (v); return ret; } @@ -2705,14 +2705,6 @@ build_function_call_vec (location_t loc, /* Convert anything with function type to a pointer-to-function. */ if (TREE_CODE (function) == FUNCTION_DECL) { - /* Implement type-directed function overloading for builtins. - resolve_overloaded_builtin and targetm.resolve_overloaded_builtin - handle all the type checking. The result is a complete expression - that implements this function call. */ - tem = resolve_overloaded_builtin (loc, function, params); - if (tem) - return tem; - name = DECL_NAME (function); if (flag_tm) @@ -2863,6 +2855,30 @@ build_function_call_vec (location_t loc, } return require_complete_type (result); } + +/* Like build_function_call_vec, but call also resolve_overloaded_builtin. */ + +tree +c_build_function_call_vec (location_t loc, tree function, + vec<tree, va_gc> *params, + vec<tree, va_gc> *origtypes) +{ + /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue. */ + STRIP_TYPE_NOPS (function); + + /* Convert anything with function type to a pointer-to-function. */ + if (TREE_CODE (function) == FUNCTION_DECL) + { + /* Implement type-directed function overloading for builtins. + resolve_overloaded_builtin and targetm.resolve_overloaded_builtin + handle all the type checking. The result is a complete expression + that implements this function call. */ + tree tem = resolve_overloaded_builtin (loc, function, params); + if (tem) + return tem; + } + return build_function_call_vec (loc, function, params, origtypes); +} /* Convert the argument expressions in the vector VALUES to the types in the list TYPELIST. --- gcc/c/c-tree.h (revision 208911) +++ gcc/c/c-tree.h (revision 208912) @@ -640,6 +640,8 @@ extern tree c_finish_omp_task (location_ extern tree c_finish_omp_clauses (tree); extern tree c_build_va_arg (location_t, tree, tree); extern tree c_finish_transaction (location_t, tree, int); +extern tree c_build_function_call_vec (location_t, tree, vec<tree, va_gc> *, + vec<tree, va_gc> *); /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ --- gcc/c/c-decl.c (revision 208911) +++ gcc/c/c-decl.c (revision 208912) @@ -4507,8 +4507,8 @@ finish_decl (tree decl, location_t init_ cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0); vec_alloc (v, 1); v->quick_push (cleanup); - cleanup = build_function_call_vec (DECL_SOURCE_LOCATION (decl), - cleanup_decl, v, NULL); + cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl), + cleanup_decl, v, NULL); vec_free (v); /* Don't warn about decl unused; the cleanup uses it. */ --- gcc/testsuite/c-c++-common/pr60689.c (revision 0) +++ gcc/testsuite/c-c++-common/pr60689.c (revision 208912) @@ -0,0 +1,10 @@ +/* PR c++/60689 */ +/* { dg-do compile } */ + +struct S { char x[9]; }; + +void +foo (struct S *x, struct S *y, struct S *z) +{ + __atomic_exchange (x, y, z, __ATOMIC_SEQ_CST); +}
2014-04-10 Jakub Jelinek <ja...@redhat.com> Backport from mainline 2014-03-28 Jakub Jelinek <ja...@redhat.com> PR target/60693 * config/i386/i386.c (ix86_copy_addr_to_reg): Call copy_addr_to_reg also if addr has VOIDmode. * gcc.target/i386/pr60693.c: New test. --- gcc/config/i386/i386.c (revision 208914) +++ gcc/config/i386/i386.c (revision 208915) @@ -22755,7 +22755,7 @@ counter_mode (rtx count_exp) static rtx ix86_copy_addr_to_reg (rtx addr) { - if (GET_MODE (addr) == Pmode) + if (GET_MODE (addr) == Pmode || GET_MODE (addr) == VOIDmode) return copy_addr_to_reg (addr); else { --- gcc/testsuite/gcc.target/i386/pr60693.c (revision 0) +++ gcc/testsuite/gcc.target/i386/pr60693.c (revision 208915) @@ -0,0 +1,13 @@ +/* PR target/60693 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +void bar (char *); + +void +foo (void) +{ + char buf[4096]; + __builtin_memcpy (buf, (void *) 0x8000, 4096); + bar (buf); +}