Hello. I'm going to install following backports.
Patches can bootstrap on ppc64le-redhat-linux and survives regression tests. Martin
>From baece18f7986907d9cd7cedea78fea9b1d7ef895 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 28 Jun 2017 07:59:23 +0000 Subject: [PATCH 6/6] Backport r249728 gcc/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR sanitizer/81224 * asan.c (instrument_derefs): Bail out inner references that are hard register variables. gcc/testsuite/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR sanitizer/81224 * gcc.dg/asan/pr81224.c: New test. --- gcc/asan.c | 3 +++ gcc/testsuite/gcc.dg/asan/pr81224.c | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/asan/pr81224.c diff --git a/gcc/asan.c b/gcc/asan.c index 8e359681fc4..3edbdf37612 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1802,6 +1802,9 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, || bitsize != size_in_bytes * BITS_PER_UNIT) return; + if (TREE_CODE (inner) == VAR_DECL && DECL_HARD_REGISTER (inner)) + return; + if (TREE_CODE (inner) == VAR_DECL && offset == NULL_TREE && bitpos >= 0 diff --git a/gcc/testsuite/gcc.dg/asan/pr81224.c b/gcc/testsuite/gcc.dg/asan/pr81224.c new file mode 100644 index 00000000000..def5cb69aec --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr81224.c @@ -0,0 +1,11 @@ +/* PR sanitizer/80659 */ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-msse2" } */ + +int a; +int +b () +{ + register __attribute__ ((__vector_size__ (4 * sizeof (int)))) int c asm("xmm0"); + return c[a]; +} -- 2.14.1
>From 5b3c19d5c81cb1b8ba6686509ffb889295cdebbc Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 30 Aug 2017 12:38:31 +0000 Subject: [PATCH 5/6] Backport r251530 gcc/ChangeLog: 2017-08-30 Martin Liska <mli...@suse.cz> PR inline-asm/82001 * ipa-icf-gimple.c (func_checker::compare_tree_list_operand): Rename to ... (func_checker::compare_asm_inputs_outputs): ... this function. (func_checker::compare_gimple_asm): Use the function to compare also ASM constrains. * ipa-icf-gimple.h: Rename the function. gcc/testsuite/ChangeLog: 2017-08-30 Martin Liska <mli...@suse.cz> PR inline-asm/82001 * gcc.dg/ipa/pr82001.c: New test. --- gcc/ipa-icf-gimple.c | 19 +++++++++++++------ gcc/ipa-icf-gimple.h | 6 +++--- gcc/testsuite/gcc.dg/ipa/pr82001.c | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/pr82001.c diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 6227b7e9579..a97f282a7a2 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -577,11 +577,8 @@ func_checker::compare_operand (tree t1, tree t2) } } -/* Compares two tree list operands T1 and T2 and returns true if these - two trees are semantically equivalent. */ - bool -func_checker::compare_tree_list_operand (tree t1, tree t2) +func_checker::compare_asm_inputs_outputs (tree t1, tree t2) { gcc_assert (TREE_CODE (t1) == TREE_LIST); gcc_assert (TREE_CODE (t2) == TREE_LIST); @@ -594,6 +591,16 @@ func_checker::compare_tree_list_operand (tree t1, tree t2) if (!compare_operand (TREE_VALUE (t1), TREE_VALUE (t2))) return return_false (); + tree p1 = TREE_PURPOSE (t1); + tree p2 = TREE_PURPOSE (t2); + + gcc_assert (TREE_CODE (p1) == TREE_LIST); + gcc_assert (TREE_CODE (p2) == TREE_LIST); + + if (strcmp (TREE_STRING_POINTER (TREE_VALUE (p1)), + TREE_STRING_POINTER (TREE_VALUE (p2))) != 0) + return return_false (); + t2 = TREE_CHAIN (t2); } @@ -1039,7 +1046,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2) tree input1 = gimple_asm_input_op (g1, i); tree input2 = gimple_asm_input_op (g2, i); - if (!compare_tree_list_operand (input1, input2)) + if (!compare_asm_inputs_outputs (input1, input2)) return return_false_with_msg ("ASM input is different"); } @@ -1048,7 +1055,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2) tree output1 = gimple_asm_output_op (g1, i); tree output2 = gimple_asm_output_op (g2, i); - if (!compare_tree_list_operand (output1, output2)) + if (!compare_asm_inputs_outputs (output1, output2)) return return_false_with_msg ("ASM output is different"); } diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h index 6a9cbed5ff4..4d2ec9169b7 100644 --- a/gcc/ipa-icf-gimple.h +++ b/gcc/ipa-icf-gimple.h @@ -215,9 +215,9 @@ public: is returned. */ bool compare_operand (tree t1, tree t2); - /* Compares two tree list operands T1 and T2 and returns true if these - two trees are semantically equivalent. */ - bool compare_tree_list_operand (tree t1, tree t2); + /* Compares GIMPLE ASM inputs (or outputs) where we iterate tree chain + and compare both TREE_PURPOSEs and TREE_VALUEs. */ + bool compare_asm_inputs_outputs (tree t1, tree t2); /* Verifies that trees T1 and T2, representing function declarations are equivalent from perspective of ICF. */ diff --git a/gcc/testsuite/gcc.dg/ipa/pr82001.c b/gcc/testsuite/gcc.dg/ipa/pr82001.c new file mode 100644 index 00000000000..05e32b10ef5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr82001.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +int +mullo (int a, int b) +{ + asm("mul %%edx # %%1 was %1" + : "+" + "a"(a), + "+d"(b)); + return a; +} + +int +mulhi (int a, int b) +{ + asm("mul %%edx # %%1 was %1" : "+d"(a), "+a"(b)); + return a; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ -- 2.14.1
>From aaac30b9a2eb0713baad13cef2d44f04bf050d5f Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu, 10 Aug 2017 07:43:49 +0000 Subject: [PATCH 4/6] Backport r251020 gcc/ChangeLog: 2017-08-10 Martin Liska <mli...@suse.cz> PR c++/81355 * c-attribs.c (handle_target_attribute): Report warning for an empty string argument of target attribute. gcc/testsuite/ChangeLog: 2017-08-10 Martin Liska <mli...@suse.cz> PR c++/81355 * g++.dg/other/pr81355.C: New test. --- gcc/c-family/c-common.c | 13 +++++++++++++ gcc/testsuite/g++.dg/other/pr81355.C | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/other/pr81355.C diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index e3e44518a64..35245703202 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -9308,6 +9308,19 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, flags)) *no_add_attrs = true; + /* Check that there's no empty string in values of the attribute. */ + for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t)) + { + tree value = TREE_VALUE (t); + if (TREE_CODE (value) == STRING_CST + && TREE_STRING_LENGTH (value) == 1 + && TREE_STRING_POINTER (value)[0] == '\0') + { + warning (OPT_Wattributes, "empty string in attribute %<target%>"); + *no_add_attrs = true; + } + } + return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C new file mode 100644 index 00000000000..89d1b419581 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr81355.C @@ -0,0 +1,14 @@ +/* { dg-do compile { target x86_64-*-* } } */ + +__attribute__((target("default"))) +int foo() {return 1;} + +__attribute__((target("arch=core2", ""))) +int foo2() {return 2;} /* { dg-warning "empty string in attribute .target." } */ + +__attribute__((target("sse4.2", "", ""))) +int foo3() {return 2;} /* { dg-warning "empty string in attribute .target." } */ + +int main() { + return foo() + foo2() + foo3(); +} -- 2.14.1
>From 615db534d1d7d70f1a02f153e74332467cae0aad Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue, 8 Aug 2017 11:59:23 +0000 Subject: [PATCH 3/6] Backport r250951 gcc/ChangeLog: 2017-08-08 Martin Liska <mli...@suse.cz> PR tree-opt/81696 * ipa-icf-gimple.c (func_checker::compare_cst_or_decl): Consider LABEL_DECLs that can be from a different function. gcc/testsuite/ChangeLog: 2017-08-08 Martin Liska <mli...@suse.cz> PR tree-opt/81696 * gcc.dg/ipa/pr81696.c: New test. --- gcc/ipa-icf-gimple.c | 6 +++++- gcc/testsuite/gcc.dg/ipa/pr81696.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/pr81696.c diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 9efdea465c2..6227b7e9579 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -395,10 +395,14 @@ func_checker::compare_cst_or_decl (tree t1, tree t2) } case LABEL_DECL: { + if (t1 == t2) + return true; + int *bb1 = m_label_bb_map.get (t1); int *bb2 = m_label_bb_map.get (t2); - return return_with_debug (*bb1 == *bb2); + /* Labels can point to another function (non-local GOTOs). */ + return return_with_debug (bb1 != NULL && bb2 != NULL && *bb1 == *bb2); } case PARM_DECL: case RESULT_DECL: diff --git a/gcc/testsuite/gcc.dg/ipa/pr81696.c b/gcc/testsuite/gcc.dg/ipa/pr81696.c new file mode 100644 index 00000000000..2d3d63ff0bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr81696.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +int +main (int argc, char **argv) +{ + __label__ lab4, lab5, lab6; + + void foo (void) { goto lab4; } + void foo2 (void) { goto lab4; } + void bar (void) { goto lab5; } + void baz (void) { goto lab6; } + + if (argc) + foo (); + else + foo2 (); + + lab4:; + bar (); + lab5:; + baz (); + lab6:; + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */ -- 2.14.1
>From 72f9ed00c64f5b7344cb220b92ed76a216902dfa Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 19 Jul 2017 06:50:34 +0000 Subject: [PATCH 2/6] Backport r250336 gcc/testsuite/ChangeLog: 2017-07-19 Martin Liska <mli...@suse.cz> PR sanitizer/63361 * c-c++-common/ubsan/float-cast-overflow-1.c: Add either -ffloat-store or -mieee for targets that need it. --- gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c index cd6941c9d30..aae88aa3180 100644 --- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c +++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c @@ -1,6 +1,7 @@ /* { dg-do run { target { lp64 || ilp32 } } } */ /* { dg-options "-fsanitize=float-cast-overflow" } */ -/* { dg-additional-options "-msse2 -mfpmath=sse" { target { sse2_runtime && ia32 } } } */ +/* { dg-additional-options "-ffloat-store" { target { ia32 } } } */ +/* { dg-additional-options "-mieee" { target { { alpha*-*-* } || { sh*-*-* } } } } */ #include <limits.h> #include "float-cast.h" -- 2.14.1
>From a7c412fe45346de954c1f8af7ddf4d5c0943d80b Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 28 Jun 2017 12:47:24 +0000 Subject: [PATCH 1/6] Backport r249735 gcc/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR ipa/81128 * ipa-visibility.c (non_local_p): Handle visibility. gcc/c-family/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR ipa/81128 * c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias to a function declaration. gcc/testsuite/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR ipa/81128 * gcc.target/i386/pr81128.c: New test. --- gcc/c-family/c-common.c | 11 ++++-- gcc/ipa-visibility.c | 3 +- gcc/testsuite/gcc.target/i386/pr81128.c | 65 +++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr81128.c diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 4a63c325d05..e3e44518a64 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7940,9 +7940,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, TREE_STATIC (decl) = 1; if (!is_alias) - /* ifuncs are also aliases, so set that attribute too. */ - DECL_ATTRIBUTES (decl) - = tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl)); + { + /* ifuncs are also aliases, so set that attribute too. */ + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("alias"), args, + DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("ifunc"), + NULL, DECL_ATTRIBUTES (decl)); + } } else { diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index 7614cfbee4b..35e7423c431 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -112,7 +112,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) && !DECL_EXTERNAL (node->decl) && !node->externally_visible && !node->used_from_other_partition - && !node->in_other_partition); + && !node->in_other_partition + && node->get_availability () >= AVAIL_AVAILABLE); } /* Return true when function can be marked local. */ diff --git a/gcc/testsuite/gcc.target/i386/pr81128.c b/gcc/testsuite/gcc.target/i386/pr81128.c new file mode 100644 index 00000000000..90a567ad690 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81128.c @@ -0,0 +1,65 @@ +/* PR ipa/81128 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-require-ifunc "" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +int resolver_fn = 0; +int resolved_fn = 0; + +static inline void +do_it_right_at_runtime_A () +{ + resolved_fn++; +} + +static inline void +do_it_right_at_runtime_B () +{ + resolved_fn++; +} + +static inline void do_it_right_at_runtime (void); + +void do_it_right_at_runtime (void) + __attribute__ ((ifunc ("resolve_do_it_right_at_runtime"))); + +static void (*resolve_do_it_right_at_runtime (void)) (void) +{ + srand (time (NULL)); + int r = rand (); + resolver_fn++; + + /* Use intermediate variable to get a warning for non-matching + * prototype. */ + typeof(do_it_right_at_runtime) *func; + if (r & 1) + func = do_it_right_at_runtime_A; + else + func = do_it_right_at_runtime_B; + + return (void *) func; +} + +int +main (void) +{ + const unsigned int ITERS = 10; + + for (int i = ITERS; i > 0; i--) + { + do_it_right_at_runtime (); + } + + if (resolver_fn != 1) + __builtin_abort (); + + if (resolved_fn != 10) + __builtin_abort (); + + return 0; +} -- 2.14.1