On 29 Oct 10:34, Richard Biener wrote: > On Tue, Oct 28, 2014 at 5:14 PM, Ilya Enkovich <enkovich....@gmail.com> wrote: > > Hi, > > > > This patch fixes PR63664 and PR63574. Problem is in NULL types for labels > > not handled by ICF properly. I assume it is OK for labels to have NULL > > type and added check into ICF rather then fixed label generation. > > > > Bootstrapped and checked on linux-x86_64. OK for trunk? > > Instead it shouldn't be called for labels instead. > > Richard. >
Here is a version which doesn't compare types for labels. Is is OK? Bootstrapped and checked on linux-x86_64. Thanks, Ilya -- gcc/ 2014-10-29 Ilya Enkovich <ilya.enkov...@intel.com> PR ipa/63664 PR bootstrap/63574 * ipa-icf-gimple.c (func_checker::compatible_types_p): Assert for null args. (func_checker::compare_operand): Don't compare types for labels. gcc/testsuite/ 2014-10-29 Ilya Enkovich <ilya.enkov...@intel.com> PR ipa/63664 * gcc.dg/ipa/pr63664.C: New. diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 1369b74..094e8ab 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -169,6 +169,9 @@ bool func_checker::compatible_types_p (tree t1, tree t2, bool compare_polymorphic, bool first_argument) { + gcc_assert (t1); + gcc_assert (t2); + if (TREE_CODE (t1) != TREE_CODE (t2)) return return_false_with_msg ("different tree types"); @@ -214,11 +217,15 @@ func_checker::compare_operand (tree t1, tree t2) else if (!t1 || !t2) return false; - tree tt1 = TREE_TYPE (t1); - tree tt2 = TREE_TYPE (t2); + if (TREE_CODE (t1) != LABEL_DECL + && TREE_CODE (t2) != LABEL_DECL) + { + tree tt1 = TREE_TYPE (t1); + tree tt2 = TREE_TYPE (t2); - if (!func_checker::compatible_types_p (tt1, tt2)) - return false; + if (!func_checker::compatible_types_p (tt1, tt2)) + return false; + } base1 = get_addr_base_and_unit_offset (t1, &offset1); base2 = get_addr_base_and_unit_offset (t2, &offset2); diff --git a/gcc/testsuite/gcc.dg/ipa/pr63664.C b/gcc/testsuite/gcc.dg/ipa/pr63664.C new file mode 100644 index 0000000..31d96d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr63664.C @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +class test { + public: + test (int val, int *p) + { + int_val = *p; + bool_val = (val != int_val); + } + + ~test () + { + if (!bool_val) + return; + } + + int get_int_val () const { return int_val; } + + private: + bool bool_val; + int int_val; +}; + +static int __attribute__ ((noinline)) +f1 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +static int __attribute__ ((noinline)) +f2 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +int +f (int i, int *p) +{ + return f1 (i, p) + f2 (i, p); +}