]> git.ipfire.org Git - thirdparty/gcc.git/commit
ipa: Force args obtined through pass-through maps to the expected type (PR 113964)
authorMartin Jambor <mjambor@suse.cz>
Fri, 19 Apr 2024 14:48:12 +0000 (16:48 +0200)
committerMartin Jambor <mjambor@suse.cz>
Fri, 19 Apr 2024 14:57:22 +0000 (16:57 +0200)
commit5c3238b0d55ec13a2430aa606e2bfed9432e97ac
treefdb6fedea193d86bded6ba7e6ce37290d5701bad
parent8a3784adf5cd873ca295a5a011d8623338ff3976
ipa: Force args obtined through pass-through maps to the expected type (PR 113964)

Interactions of IPA-CP and IPA-SRA on the same data is a rather big
source of issues, I'm afraid.  PR 113964 is a situation where IPA-CP
propagates an unsigned short in a union parameter into a function
which itself calls a different function which has a same union
parameter and both these union parameters are split with IPA-SRA.  The
leaf function however uses a signed short member of the union.

In the calling function, we get the unsigned constant as the
replacement for the union and it is then passed in the call without
any type compatibility checks.  Apparently on riscv64 it matters
whether the parameter is signed or unsigned short and so the leaf
function can see different values.

Fixed by using useless_type_conversion_p at the appropriate place and
if it fails, use force_value_to type as elsewhere in similar
situations.

gcc/ChangeLog:

2024-04-04  Martin Jambor  <mjambor@suse.cz>

PR ipa/113964
* ipa-param-manipulation.cc (ipa_param_adjustments::modify_call):
Force values obtined through pass-through maps to the expected
split type.

gcc/testsuite/ChangeLog:

2024-04-04  Patrick O'Neill  <patrick@rivosinc.com>
    Martin Jambor  <mjambor@suse.cz>

PR ipa/113964
* gcc.dg/ipa/pr114247.c: New test.

(cherry picked from commit 8cd0d29270d4ed86c69b80c08de66dcb6c1e22fe)
gcc/ipa-param-manipulation.cc
gcc/testsuite/gcc.dg/ipa/pr114247.c [new file with mode: 0644]