]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix find_always_executed_bbs handling of infinite loops
authorJan Hubicka <jh@suse.cz>
Sun, 29 Jan 2023 00:27:26 +0000 (01:27 +0100)
committerJan Hubicka <jh@suse.cz>
Sun, 29 Jan 2023 00:27:26 +0000 (01:27 +0100)
commitda3aca031be736fe4fa8daa57c7efa69dc767160
treecc55eda6e0d584009f8a9a71b1e50ae2a832b912
parentee2c965ee205ae12bc78d8641337380df3b1d3f3
Fix find_always_executed_bbs handling of infinite loops

This patch fixes the stupid typo info find_always_executed_bbs which made
all edges to be considered as ones closing infinite loops.  This fix has
somewhat snowballed as, comparing it to finite_function_p, I noticed a
divergence in handling of volatile asms (find_always_executed_bbs is conservative
and thinks that volatile statement may return or do EH, but it is really
impossible and elsewhere we expects that we dont) and I also noticed
a bug in handling early returns which made some loops to be missed.

I also noticed that function assumes that irreducible loops are marked in CFG
which is not necessarily true and it is easy to detect them during the walk.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

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

* ipa-utils.cc: Include calls.h, cfgloop.h and cfganal.h
(stmt_may_terminate_function_p): If assuming return or EH
volatile asm is safe.
(find_always_executed_bbs): Fix handling of terminating BBS and
infinite loops; add debug output.
* tree-ssa-alias.cc (stmt_kills_ref_p): Fix debug output

gcc/testsuite/ChangeLog:

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

* gcc.dg/ipa/ipa-sra-30.c: New test.
* gcc.dg/ipa/ipa-sra-31.c: New test.
* gcc.dg/tree-ssa/modref-dse-7.c: New test.
gcc/ipa-utils.cc
gcc/testsuite/gcc.dg/ipa/ipa-sra-30.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/ipa/ipa-sra-31.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/modref-dse-7.c [new file with mode: 0644]
gcc/tree-ssa-alias.cc