aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-icf-gimple.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-03-11 10:59:18 +0100
committerJakub Jelinek <jakub@redhat.com>2021-03-11 10:59:18 +0100
commit070ab283d16d8e8e8bb70f9801aca347f008cbd0 (patch)
treea5c04f1c66814c685331894991a0e9676491b400 /gcc/ipa-icf-gimple.c
parentaa27696b798b34730f5266cac2adba9178ebc3ae (diff)
downloadgcc-070ab283d16d8e8e8bb70f9801aca347f008cbd0.zip
gcc-070ab283d16d8e8e8bb70f9801aca347f008cbd0.tar.gz
gcc-070ab283d16d8e8e8bb70f9801aca347f008cbd0.tar.bz2
icf: Check return type of internal fn calls [PR99517]
The following testcase is miscompiled, because IPA-ICF considers the two functions identical. They aren't, the types of the .VEC_CONVERT call lhs is different. But for calls to internal functions, there is no fntype nor callee with a function type to compare, so all we compare is just the ifn, arguments and some call flags. The following patch fixes it by checking the internal fn calls like e.g. gimple assignments where the type of the lhs is checked too. 2021-03-11 Jakub Jelinek <jakub@redhat.com> PR ipa/99517 * ipa-icf-gimple.c (func_checker::compare_gimple_call): For internal function calls with lhs fail if the lhs don't have compatible types. * gcc.target/i386/avx2-pr99517-1.c: New test. * gcc.target/i386/avx2-pr99517-2.c: New test.
Diffstat (limited to 'gcc/ipa-icf-gimple.c')
-rw-r--r--gcc/ipa-icf-gimple.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 3bc168d..edf5f02 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -667,7 +667,7 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2)
tree fntype1 = gimple_call_fntype (s1);
tree fntype2 = gimple_call_fntype (s2);
- /* For direct calls we verify that types are comopatible so if we matced
+ /* For direct calls we verify that types are compatible so if we matched
callees, callers must match, too. For indirect calls however verify
function type. */
if (!gimple_call_fndecl (s1))
@@ -703,6 +703,14 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2)
t1 = gimple_get_lhs (s1);
t2 = gimple_get_lhs (s2);
+ /* For internal calls, lhs types need to be verified, as neither fntype nor
+ callee comparisons can catch that. */
+ if (gimple_call_internal_p (s1)
+ && t1
+ && t2
+ && !compatible_types_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return return_false_with_msg ("GIMPLE internal call LHS type mismatch");
+
return compare_operand (t1, t2, get_operand_access_type (&map, t1));
}