Hi, On Mon, Jul 18 2022, Jan Hubicka wrote: >> Hi, >> >> with -fno-toplevel-reorder (and -fwhole-program), there apparently can >> be local functions without any callers. This is something that IPA-CP > > If there is possibility to trigger a local function without callers, I > think one can also make two local functions calling each other but with > no other callers.
I am not sure I understand. The above can happen only with -fno-toplevel-reorder, right? > > So I think you need to wait until dataflow solution stabilizes and > then then find such isolated cases and do something sensible (as of > not crashing since the code is dead anyway). After dataflow stabilizes, it crashes only because a verifier does not like the result. Perhaps the solution is simply not verify nodes built with -fno-toplevel-reorder? But the assert was useful in the past in the general case so I'd like to keep it. I can now see that the proposed patch could also pessimize the lattices of functions that the dead functions call a bit, although arguably it might be the right thing to do, since we cannot say anything about these calls. But I do not care much. > > -fno-toplevel-reorder was kind of meant to get close to what > -fno-unit-at-a-time > did to make legacy code (kernel) happy. Without unit-at-a-time we did > not remove local functions unless we decided to inline them since they > were output before we had chance to realize that they were unused. I understand that it is legacy stuff but actually I wonder what the option means for IPA in general. Is IPA run after we might have output something already? (If not then why do we see any differences? If yes, can all IPA optimizations work, especially with -fwhole-program?) > > Since we document that only about static variables, perhaps we could > simply start removing functions to avoid these side cases? Well, the funny thing is that we eventually do remove the function, just at IPA-CP stage it is there and not even local yet (I have not noticed this last week). Removing it earlier would definitely make life simpler for me :-) Anyway, I'm happy to work in whichever direction you prefer, just now I am not sure which one it is. Thanks, Martin > >> does not like because its propagation verifier checks that local >> functions do not end up with TOP in their lattices. Therefore there >> is an assert checking that all call-less unreachable functions have >> been removed, which triggers in PR 106260 with these two options. >> >> This patch detects the situation and marks the lattices as variable, >> thus avoiding both the assert trigger and the verification failure. >> >> Bootstrapped and tested on x86_64-linux. OK for master and then all >> active release branches? >> >> Thanks, >> >> Martin >> >> >> gcc/ChangeLog: >> >> 2022-07-13 Martin Jambor <mjam...@suse.cz> >> >> PR ipa/106260 >> * ipa-cp.cc (initialize_node_lattices): Replace assert that there are >> callers with handling that situation when -fno-toplevel_reorder. >>