On 11 July 2022 08:20, Richard Biener wrote: > On Sun, 10 Jul 2022, Roger Sayle wrote: > > > This patch builds upon Richard Biener's suggestion of avoiding global > > variables to track state/identify which passes have already been run. > > In the early middle-end, the tree-ssa passes use the curr_properties > > field in cfun to track this. This patch uses a new rtl_pass_progress > > int field in crtl to do something similar. > > Why not simply add PROP_rtl_... and use the existing curr_properties for this? > RTL passes are also passes and this has the advantage you can add things like > reload_completed to the passes properties_set field hand have the flag setting > handled by the pass manager as it was intended? >
Great question, and I did initially consider simply adding more RTL fields to curr_properties. My hesitation was from the comments/documentation that the curr_properties field is used by the pass manager as a way to track (and verify) the properties/invariants that are required, provided and destroyed by each pass. This semantically makes sense for properties such as accurate data flow, ssa form, cfg_layout, nonzero_bits etc, where hypothetically the pass manager can dynamically schedule a pass/analysis to ensure the next pass has the pre-requisite information it needs. This seems semantically slightly different from tracking time/progress, where we really want something more like DEBUG_COUNTER that simply provides the "tick-tock" of a pass clock. Alas, the "pass number", as used in the suffix of dump-files (where 302 currently means reload) isn't particularly useful as these change/evolve continually. Perhaps the most obvious indication of this (subtle) difference is the curr_properties field (PROP_rtl_split_insns) which tracks whether instructions have been split, where at a finer granularity rtl_pass_progress may wish to distinguish split1 (after combine before reload), split2 (after reload before peephole2) and split3 (after peephole2). It's conceptually not a simple property, whether all insns have been split or not, as in practice this is more subtle with backends choosing which instructions get split at which "times". There's also the concern that we've a large number of passes (currently 62 RTL passes), and only a finite number of bits (in curr_properties), so having two integers reduces the risk of running out of bits and needing to use a "wider" data structure. To be honest, I just didn't want to hijack curr_properties to abuse it for a use that didn't quite match the original intention, without checking with you and the other maintainers first. If the above reasoning isn't convincing, I can try spinning an alternate patch using curr_properties (but I'd expect even more churn as backend source files would now need to #include tree-passes.h and function.h to get reload_completed). And of course, a volunteer is welcome to contribute that re-refactoring after this one. I've no strong feelings either way. It was an almost arbitrary engineering decision (but hopefully the above explains the balance of my reasoning). Roger --