A new option exec-on-ir-changed is defined that allows one to specify an
exe that is called after each pass in the opt pipeline that changes the IR.
I recently was investigating a situation where some IR was being
mis-optimized in the IR pipeline and I needed to determine after
which pass the IR was no longer producing the correct results.
In order to determine this, I created the following option which calls
to an external exe (or script) each time the IR changes in the opt pipeline.
In my case, the exe was a script that called llc to compile the IR and ran
the result so that I could determine when it became incorrect. This is
a generally useful technique for debugging optimization bugs.
The exec-on-ir-change=exe option saves the IR in a temporary file and calls exe
with the name of the file and the name of the pass that just changed it after
each pass alters the IR. exe is also called with the initial IR. This
can be used, for example, to determine which pass corrupts the IR by having
exe as a script that calls llc and runs a test to see after which pass the
results change. The print-changed filtering options are respected.
this (and below) should use ErrorOr