]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix wrong code issues with ipa-sra
authorJan Hubicka <jh@suse.cz>
Mon, 16 Jan 2023 17:14:45 +0000 (18:14 +0100)
committerJan Hubicka <jh@suse.cz>
Mon, 16 Jan 2023 17:14:45 +0000 (18:14 +0100)
commitb1f30bf42d8d47228e52de998f3172b2f5dd7265
tree088f21e88e5d378f5524369caf8744ba6b2432fe
parentd694a3d57535fbb3737dd583b15b69e0845a5846
Fix wrong code issues with ipa-sra

Fix wrong code issues in ipa-sra where we are trying to prove that on every
execution of a given function a call to other function will happen.  The code
uses post dominators and makes a wrong query (which passes only for first BB in
function). Hoever post-dominators are only valid if fake edges for every
possible reason for fuction execution to terminate are added.

Fixing this using postdominators is somewhat costy since one needs to walk
whole body and add a lot of fake edges. I ended up implementing a special
purpose function for this which is also useful in ipa-modref and other places
that does similar analysis.  One does not need to modify CFG to use it and
moreover for complex functions it usually stops on first unanalyzed function
call and ends up being relatively cheap.

Bootstrapped/regtested x86_64-linux, plan to commit it shortly.

gcc/ChangeLog:

2023-01-16  Jan Hubicka  <hubicka@ucw.cz>

PR ipa/106077
* ipa-modref.cc (modref_access_analysis::analyze): Use
find_always_executed_bbs.
* ipa-sra.cc (process_scan_results): Likewise.
* ipa-utils.cc (stmt_may_terminate_function_p): New function.
(find_always_executed_bbs): New function.
* ipa-utils.h (stmt_may_terminate_function_p): Declare.
(find_always_executed_bbs): Declare.

gcc/testsuite/ChangeLog:

2023-01-16  Jan Hubicka  <hubicka@ucw.cz>

* g++.dg/tree-ssa/pr106077.C: New test.
gcc/ipa-modref.cc
gcc/ipa-sra.cc
gcc/ipa-utils.cc
gcc/ipa-utils.h
gcc/testsuite/g++.dg/tree-ssa/pr106077.C [new file with mode: 0644]