]> git.ipfire.org Git - thirdparty/gcc.git/commit
ipa: Avoid another ICE when dealing with type-incompatibilities (PR 108959)
authorMartin Jambor <mjambor@suse.cz>
Wed, 5 Apr 2023 14:36:49 +0000 (16:36 +0200)
committerMartin Jambor <mjambor@suse.cz>
Wed, 5 Apr 2023 14:37:26 +0000 (16:37 +0200)
commitf0f372fab3e70622a4ea6fe4073991e1bb506e4e
treeef2fb32d8c46949b7489cec394076c408c6851b1
parentce1e682ca21400d9b59f08f0416d96e0bac369d8
ipa: Avoid another ICE when dealing with type-incompatibilities (PR 108959)

PR 108959 shows one more example where undefined code with type
incompatible accesses to stuff passed in parameters can cause an ICE
because we try to create a VIEW_CONVERT_EXPR of mismatching sizes:

1. IPA-CP tries to push one type from above,

2. IPA-SRA (correctly) decides the parameter is useless because it is
   only used to construct an argument to another function which does not
   use it and so the formal parameter should be removed,

3. but the code reconciling IPA-CP and IPA-SRA transformations still
   wants to perform the IPA-CP and overrides the built-in DCE of
   useless statements and tries to stuff constants into them
   instead, constants of a type with mismatching type and size.

This patch avoids the situation in IPA-SRA by purging the IPA-CP
results from any "aggregate" constants that are passed in parameters
which are detected to be useless.  It also removes IPA value range and
bits information associated with removed parameters stored in the same
structure so that the useless information is not streamed later on.

gcc/ChangeLog:

2023-03-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/108959
* ipa-sra.cc (zap_useless_ipcp_results): New function.
(process_isra_node_results): Call it.

gcc/testsuite/ChangeLog:

2023-03-17  Martin Jambor  <mjambor@suse.cz>

PR ipa/108959
* gcc.dg/ipa/pr108959.c: New test.
gcc/ipa-sra.cc
gcc/testsuite/gcc.dg/ipa/pr108959.c [new file with mode: 0644]