This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Generic BFS graph iterator
ClosedPublic

Authored by davide on Apr 4 2017, 6:34 PM.

Details

Summary

As we discussed on IRC a couple of days ago, we want to speed up some skip checks in LCSSA, and we need to walk the BB of a loop in BFS order to do so.
I decided to make this a piece of ADT, just in case we need for something else. I'll add some other tests and give some testing, but I want to make sure we agree it's fine having this being a generic iterator.

Diff Detail

Event Timeline

davide created this revision.Apr 4 2017, 6:34 PM
dberlin edited edge metadata.Apr 4 2017, 10:59 PM

I'm trying to understand how you are level numbering.
The level numbering can't be done on a cyclic graph without help (or, at the very least, if it is defined as "the minimum depth from root we ever saw this node as" or sometihng, so you would use min(current, last level)".
It works fine for free.

I'm trying to understand how you are level numbering.
The level numbering can't be done on a cyclic graph without help (or, at the very least, if it is defined as "the minimum depth from root we ever saw this node as" or sometihng, so you would use min(current, last level)".
It works fine for free.

Forget it, i'm being dumb.
It's unweighted bfs, so if there was a shorter path, we would have already hit it, so if we revisit something, it can't change the lowest level.

davide updated this revision to Diff 94272.Apr 5 2017, 1:18 PM
  • Updated test to be more comprehensive
  • Add a test with a cyclic graph
  • Fixed a bug in the marker logic where we were looping indefinitely (now covered by testing).

I think this is ready to be used in LCSSA now.

davide added a comment.Apr 5 2017, 2:08 PM

Also, I added some comments to explain how we put the markers, but please let me know if I'm missing something

dberlin accepted this revision.Apr 5 2017, 3:33 PM

This looks correct to me.

This revision is now accepted and ready to land.Apr 5 2017, 3:33 PM
This revision was automatically updated to reflect the committed changes.