ipa-fnsummary: Fix ICE with switch predicates [PR96130]
The following testcase ICEs since r10-3199.
There is a switch with default label, where the controlling expression has
range just 0..7 and there are case labels for all those 8 values, but
nothing has yet optimized away the default.
Since r10-3199, set_switch_stmt_execution_predicate sets the switch to
default label's edge's predicate to a false predicate and then
compute_bb_predicates propagates the predicates through the cfg, but false
predicates aren't really added. The caller of compute_bb_predicates
in one place handles NULL bb->aux as false predicate:
if (fbi.info)
{
if (bb->aux) bb_predicate = *(predicate *) bb->aux;
else bb_predicate = false;
}
else bb_predicate = true;
but then in two further spots that the patch below is changing
it assumes bb->aux must be non-NULL. Those two spots are guarded by a
condition that is only true if fbi.info is non-NULL, so I think the right
fix is to treat NULL aux as false predicate in those spots too.
The releases/gcc-10 branch has been updated by Jakub Jelinek <email address hidden>:
https:/ /gcc.gnu. org/g:0d03c0ee5 213703ec6d9ffa6 32fa5298d83adaa a
commit r10-8472- g0d03c0ee521370 3ec6d9ffa632fa5 298d83adaaa
Author: Jakub Jelinek <email address hidden>
Date: Mon Jul 13 18:25:53 2020 +0200
ipa-fnsummary: Fix ICE with switch predicates [PR96130]
The following testcase ICEs since r10-3199. stmt_execution_ predicate sets the switch to bb_predicates propagates the predicates through the cfg, but false bb_predicates
bb_predicate = *(predicate *) bb->aux;
bb_predicate = false;
bb_ predicate = true;
There is a switch with default label, where the controlling expression has
range just 0..7 and there are case labels for all those 8 values, but
nothing has yet optimized away the default.
Since r10-3199, set_switch_
default label's edge's predicate to a false predicate and then
compute_
predicates aren't really added. The caller of compute_
in one place handles NULL bb->aux as false predicate:
if (fbi.info)
{
if (bb->aux)
else
}
else
but then in two further spots that the patch below is changing
it assumes bb->aux must be non-NULL. Those two spots are guarded by a
condition that is only true if fbi.info is non-NULL, so I think the right
fix is to treat NULL aux as false predicate in those spots too.
2020-07-13 Jakub Jelinek <email address hidden>
PR ipa/96130 function_ body): Treat NULL bb->aux
* ipa-fnsummary.c (analyze_
as false predicate.
* gcc.dg/ torture/ pr96130. c: New test.
(cherry picked from commit 776e48e0931db69 f158f40e5cb8e15 463d879a42)