> Hi, > > IPA-CP contains special logic to create specially marked clones with > constants that come from all callees (that are constant in all > contexts). In the past that was the only case in which the heuristics > tried to assess the effect of multiple constants at once (that is no > longer true since GCC 16) and they are also useful when we realize we > can refine them still further in the case of recursive calls (such as > in testsuite/gcc.dg/ipa/pr93707.c) turn to carry more constants after > the initial "all-context" clone is created. > > Unfortunately, the code creating the clones simply redirects all > incoming call graph edges which may include those which were indirect > in the phase of the algorithm which gathered IPA-CP lattices and the > arguments in these calls might contain different values than all > initially known ones, leading to miscompilations like the one in > PR125207. > > Since GCC 16 already feeds the heuristics with all known constants > that are passed along with the constant the evaluation was initiated > for, the all-context nodes are really only necessary for the recursive > refinement cases described above. It seems appropriate to only create > them when they are what they are called, when there can be no indirect > or unknown calls to them, i.e. when they are local. This has the nice > effect of simplifying decide_whether_version_node somewhat. > > There is some testsuite fallout. First, IPA-CP will now no longer > clone a non-static function to only remove a (non-constant) parameter. > This likely only makes sense with tiny values of param > ipa-cp-eval-threshold or very small functions which are likely going > to be inlined anyway. But gcc.dg/vla-1.c expected that to happen so I > made the function to be cloned static. > > The testcase libgomp.c/ipcp-cb-spec1.c stopped working for the same > reason (the outlined task body has its address taken) but looking into > the dumps the test does not seem to test what it is supposed to, the > test function was completely eliminated before IPA. I have therefore > changed it to really propagate constants. > > Bootstrapped and tested on x86_64-linux. LTO-O3 bootstrap underway. OK > for master and the gcc-16 branch if it passes? > > Thanks, > > Martin > > > gcc/ChangeLog: > > 2026-06-02 Martin Jambor <[email protected]> > > PR ipa/125207 > * ipa-cp.cc (decide_about_value): Add detailed dumping about skipping > a value when there are no edges for it. Make dumping about skipping > because of growth limit violation consistent with other cases. > (decide_whether_version_node): Only create all-context nodes for local > nodes, remove the logic doing it in other cases, allow cloning for > single constant lattices for non-local nodes. Adjust dumping. > > gcc/testsuite/ChangeLog: > > 2026-06-02 Martin Jambor <[email protected]> > > PR ipa/125207 > * gcc.dg/ipa/pr125207.c: New test. > * gcc.dg/vla-1.c (f1): Make function f1 static. > > libgomp/ChangeLog: > > 2026-06-03 Martin Jambor <[email protected]> > > PR ipa/125207 > * testsuite/libgomp.c/ipcp-cb-spec1.c (test): Rework.
OK, thanks! Honza
