This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Tidy up the code a bit, NFC.
ClosedPublic

Authored by lattner on Apr 25 2021, 4:15 PM.

Details

Summary

This tidies up the code a bit:

  • Eliminate the ctx member, which doesn't need to be stored.
  • Rename verify(Operation) to make it more clear that it is doing more than verifyOperation and that the dominance check isn't being done multiple times.
  • Rename mayNotHaveTerminator which was confusing about whether it wasn't known whether it had a terminator, when it is really about whether it is legal to have a terminator.
  • Some minor optimizations: don't check for RegionKindInterface if there are no regions. Don't do two passes over the operations in a block in OperationVerifier::verifyDominance when one will do.

The optimizations are actually a measurable (but minor) win in some
CIRCT cases.

Diff Detail

Event Timeline

lattner created this revision.Apr 25 2021, 4:15 PM
lattner requested review of this revision.Apr 25 2021, 4:15 PM

A more aggressive optimization would be to use a custom dominance check instead of standard dominance. This would be more efficient given the bulk nature of what verify is doing here, particularly when run on something big like a ModuleOp. Right now, dominance is really set up for sparse queries, e.g. it devolves into isBeforeInBlock vs doing a simple top-down pass keeping track of live values in a scoped hash table.

This revision is now accepted and ready to land.Apr 26 2021, 10:52 AM
This revision was automatically updated to reflect the committed changes.

Thx for the review!