Completeness of -print-after-all

Hi,

I recently worked on an issue where I realized that -print-after-all does not
cover all passes run by the pass manager. E.g. it seems that loop passes are
not fully covered and I could find that loop transformations showed up in the
dump of the next non-loop pass (which happened to be 'Combine redundant
instructions' and that was rather confusing).

Specifying both -print-before-all and -print-after-all and doing some grepping
gives me the following where we see two back-to-back 'Before' dumps which
should not be possible.

*** IR Dump Before LCSSA Verifier ***
*** IR Dump After LCSSA Verifier ***
*** IR Dump Before Loop-Closed SSA Form Pass ***
*** IR Dump After Loop-Closed SSA Form Pass ***
*** IR Dump Before Unroll loops ***
*** IR Dump Before Combine redundant instructions ***
*** IR Dump After Combine redundant instructions ***

Maybe there are good reasons for making this hard to fix but to me it seems
like a rather severe deficiency so I wonder if this is widely known and if there
are any plans to improve it?

-Markus

Markus,

Loop passes are kinda unique compared to func/module passes in that they could destroy the loop they worked on. And there might be no loop to print after that (btw, there is a known bug in new pass manager where it tries to print deleted loop in this situation - nothing good happens!).

In your case loop unroll can fully uroll the loop, essentially removing the Loop.

If you have suggestions on how to improve behavior in such cases I would be happy to discuss this further.

regards,
Fedor

Fedor,

Yes that is what happens in my case that the loop is fully unrolled and hence ‘removed’.

My objection though is that there is still IR that could be dumped (i.e. the function containing the loop that was removed or the entire module) and that is what I want to have dumped after each pass when I specify -print-after-all. Of course there may be certain implementation details that could make this hard to achieve but ideally I would like to have a reliable option that dumps the entire IR (complete enough to import into opt and run additional passes on) after each individual pass (module, function, loop or whatever).

Doesn’t that make sense?

Regards,

Markus

чт, 8 нояб. 2018 г., 14:45 Markus Lavin markus.lavin@ericsson.com:

Fedor,

Yes that is what happens in my case that the loop is fully unrolled and hence ‘removed’.

My objection though is that there is still IR that could be dumped (i.e. the function containing the loop that was removed or the entire module) and that is what I want to have dumped after each pass when I specify -print-after-all. Of course there may be certain implementation details that could make this hard to achieve but ideally I would like to have a reliable option that dumps the entire IR (complete enough to import into opt and run additional passes on) after each individual pass (module, function, loop or whatever).

Doesn’t that make sense?

It does not agree with the semantics of plain - print-before-all, which intends to prints only the IRunit pass works on.

It does however makes perfect sense for the combo with -print-module-scope.
In fact I was going to try doing that for new-pass-manager implementation.

Legacy one is technically doable as well, though there is a catch that you can’t get module out of invalidated Loop, so there needs to be some hackstery employed…

Patches welcome! :slight_smile:

regards,
Fedor.

On a side note: The printing is also disabled when the runOnXXX() functions return false, as passes indicate that they did not do any changes that way.
I certainly have seen some passes getting this wrong and reporting false even though they did some small changes to the MIR, but because the return value only affects the debug printing it’s no really an important bug and we may still have some around…

  • Matthias