This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Simplify block and node printing
ClosedPublic

Authored by kuhar on Jul 11 2017, 6:39 PM.

Details

Summary

This patch adds BlockPrinter-- a small wrapper for printing CFG nodes and DomTree nodes to raw_ostream. It is meant to be only used internally, for debugging and printing errors.

Diff Detail

Repository
rL LLVM

Event Timeline

kuhar created this revision.Jul 11 2017, 6:39 PM
dberlin added inline comments.Jul 11 2017, 8:35 PM
include/llvm/Support/GenericDomTreeConstruction.h
103 ↗(On Diff #106132)

This doesn't print blocks, it print block names.
I'd go with BlockNamePrinter.

298 ↗(On Diff #106132)

typo: discovereed->discovered

kuhar updated this revision to Diff 106332.Jul 12 2017, 3:56 PM

Address the comments.

kuhar marked 2 inline comments as done.Jul 12 2017, 3:57 PM
davide edited edge metadata.Jul 12 2017, 4:20 PM

This is not your fault but it would be awesome if we introduced a common error handling for the dom, so that we can just call that routine which also calls flush.
(that way we don't have to repeat flush all over the place). Maybe in a separate patch.

kuhar added a comment.Jul 12 2017, 4:23 PM

This is not your fault but it would be awesome if we introduced a common error handling for the dom, so that we can just call that routine which also calls flush.

Is there something similar in LLVM that I could use as an example?

This is not your fault but it would be awesome if we introduced a common error handling for the dom, so that we can just call that routine which also calls flush.

Is there something similar in LLVM that I could use as an example?

it just needs to be a static helper, nothing fancy, just to reduce the amount of os.flush() typing :)
see, e.g. r299551 (except that you need to call os.flush() and this routine actually returns.

Makes sense. I'll add this error printing helper in a separate patch.

grosser accepted this revision.Jul 13 2017, 11:34 PM

This looks good from my perspective. Thanks for cleaning up the code!

This revision is now accepted and ready to land.Jul 13 2017, 11:34 PM
davide accepted this revision.Jul 14 2017, 8:31 AM

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.