> Hi!
>
> As the following two testcases shows, there are lots of issues in
> ICF compare_gimple_call, in particular, it doesn't handle indirect calls
> properly (see the ipa-icf-31.c testcase), doesn't handle internal calls
> properly (see ubsan/ipa-icf-1.c), didn't check gimple_call flags at all.
>
> As discussed with Honza, the call chain test (from Martin) is probably
> insufficient, I'm open with leaving it out from the patch, but perhaps
> what the patch has is better than nothing at all for now.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2014-11-10 Jakub Jelinek <[email protected]>
> Martin Liska <[email protected]>
>
> * ipa-icf-gimple.c (func_checker::compare_bb): Fix comment typo.
> (func_checker::compare_gimple_call): Compare gimple_call_fn,
> gimple_call_chain, gimple_call_fntype and call flags.
> testsuite/
> * gcc.dg/ubsan/ipa-icf-1.c: New test.
> * gcc.dg/ipa/ipa-icf-31.c: New test.
OK.
> +
> + tree chain1 = gimple_call_chain (s1);
> + tree chain2 = gimple_call_chain (s2);
> +
> + if ((chain1 && !chain2) || (!chain1 && chain2))
> + return return_false_with_msg ("Tree call chains are different");
Since gimple_call_chain is actually gimple_val, I think it needs to be compared
as operand.
Honza