intel/compiler: IR analysis pass framework
While working on a separate project, I realized that @currojerez's i965-ir-analysis series from 2016 would make my life easier.
Since I neglected to review it in 2016, I rebased it in 2020 and gave it just some very minor updates. I'm very pleased with the result.
Curro's original cover letter said:
The purpose of this series is to introduce some lightweight infrastructure intended to make room for additional analysis passes in the i965 back-end without increasing the clutter of the visitor objects, to reduce duplication of logic between analysis passes, and to prevent some mistakes that are fairly difficult to avoid under the current (rather informal) approach.
Patches 1-3 of this series fix some long-standing bugs that were uncovered by the additional validation done by the analysis pass framework. The bugs could be hit during either shader-db or piglit runs. All the three caused us to use inconsistent live interval metadata in some cases and could potentially lead to program miscompilation. I don't know whether there are any real-life workloads where it actually caused corruption, in doubt it seems sensible to back-port them to stable branches.
Patches 5-10 is mostly trivial header file churn intended to clean things up and prevent circular header dependencies in cases where the header inclusion order was the opposite of their logical dependency order.
Patches 11-13 is the core of this series. They introduce the general framework that will be put to use in the following patches.
Patch 14 instruments the whole back-end with analysis metadata invalidation and might be one of the more difficult to review. On the bright side it's no longer a particularly critical thing to get right, because any mistake in the invalidation instrumentation will eventually trigger an assertion failure if it leads to a situation where we attempt to use analysis metadata that has become inconsistent with the program, as demonstrated in patches 1-3.
The rest of the series is mainly about converting existing analysis passes to the new framework. Patches 16-25 port the VEC4 and FS liveness analysis passes, patches 26-27 port the dominance analysis pass and patch 29 ports the register pressure calculation in the FS back-end.
A few patches that added #ifndef guards to header files have been committed separately, so the patch numbers don't line up exactly, but you get the idea.