From 6b0e0695a52d1a7f82b2adfe460c79254c361e14 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 19 Dec 2014 13:40:50 +0100 Subject: [PATCH] re PR ipa/63569 (Wrong code with volatile and ICF) Fix for PR ipa/63569. PR ipa/63569 * gcc.dg/ipa/pr63569.c: New test. PR ipa/63569 * ipa-icf-gimple.c (func_checker::compare_operand): Add missing comparison for volatile flag. From-SVN: r218949 --- gcc/ChangeLog | 6 ++++++ gcc/ipa-icf-gimple.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/ipa/pr63569.c | 32 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/ipa/pr63569.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d27e22e7365..19b33e719cc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-12-19 Martin Liska + + PR ipa/63569 + * ipa-icf-gimple.c (func_checker::compare_operand): Add missing + comparison for volatile flag. + 2014-12-19 Kyrylo Tkachov * doc/invoke.texi (ARM options): Remove mention of Advanced RISC diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index ec0290a4013..fa2c3534d8d 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -230,6 +230,9 @@ func_checker::compare_operand (tree t1, tree t2) tree tt1 = TREE_TYPE (t1); tree tt2 = TREE_TYPE (t2); + if (TREE_THIS_VOLATILE (t1) != TREE_THIS_VOLATILE (t2)) + return return_false_with_msg ("different operand volatility"); + if (!func_checker::compatible_types_p (tt1, tt2)) return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35012180d24..5ba1eff2f2b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-19 Martin Liska + + PR ipa/63569 + * gcc.dg/ipa/pr63569.c: New test. + 2014-12-19 Jakub Jelinek PR preprocessor/63831 diff --git a/gcc/testsuite/gcc.dg/ipa/pr63569.c b/gcc/testsuite/gcc.dg/ipa/pr63569.c new file mode 100644 index 00000000000..8bd5c1f9084 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr63569.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +static int f(int t, int *a) __attribute__((noinline)); + +static int g(int t, volatile int *a) __attribute__((noinline)); +static int g(int t, volatile int *a) +{ + int i; + int tt = 0; + for(i=0;i