This is an archive of the discontinued LLVM Phabricator instance.

Cleanup some GraphTraits iteration code
ClosedPublic

Authored by yabash on Apr 16 2017, 2:29 AM.

Details

Summary

Use children<> and nodes<> in appropriate places to cleanup the code.

Also, as part of the cleanup,
change the signature of DominatorTreeBase's Split.
It is a protected non-virtual member function called only twice,
both from within the class,
and the removed passed argument in both cases is '*this'.
The reason for the existence of that argument seems to be that
back before r43115 Split was a free function,
so an argument to get '*this' was needed - but now that is no longer the case.

Diff Detail

Repository
rL LLVM

Event Timeline

yabash created this revision.Apr 16 2017, 2:29 AM
alexfh added inline comments.Apr 16 2017, 3:38 AM
include/llvm/Support/GenericDomTree.h
659 ↗(On Diff #95401)

Will it work without this?

include/llvm/Support/GraphWriter.h
146 ↗(On Diff #95401)

Iterator-based loops excuse the use of I, It, and similar short variable names, since loop variable is repeated multiple times and refers to an iterator anyway. With range-for I'd generally prefer more meaningful loop variable names (Node, Child, Pred, Succ, etc.) as they tend to be involved in less boilerplate code compared to regular for loops and shorter name doesn't buy much in terms of code cleanliness.

yabash updated this revision to Diff 95408.Apr 16 2017, 7:17 AM

Updated according to alexfh's comments.

A lot of "this->" in the code could be removed,
however the specific one you mentioned (and some others) couldn't,
since they are members of a templated base class,
and need to be qualified.

timshen edited edge metadata.Apr 16 2017, 10:11 PM

LGTM for GraphTraits-related changes (thought I also see an interface change on Split, which I know nothing about).

alexfh accepted this revision.Apr 17 2017, 7:22 AM

LG with one more comment.

include/llvm/Analysis/LoopInfoImpl.h
89 ↗(On Diff #95408)

Change to emplace_back?

This revision is now accepted and ready to land.Apr 17 2017, 7:22 AM
yabash updated this revision to Diff 95439.Apr 17 2017, 8:23 AM

Thanks, fixed.

I don't have commit rights yet,
can someone please help with committing?

yabash marked 3 inline comments as done.Apr 17 2017, 8:42 AM

LGTM for GraphTraits-related changes (thought I also see an interface change on Split, which I know nothing about).

I suppose, this change needs at least to be mentioned in the patch description along with a short explanation of why it is a no-op (I hope, it is? ;).

LGTM for GraphTraits-related changes (thought I also see an interface change on Split, which I know nothing about).

I suppose, this change needs at least to be mentioned in the patch description along with a short explanation of why it is a no-op (I hope, it is? ;).

(full disclosure: I also don't know anything about Split, neither about the rest of the code here, and was reviewing mostly for coding style and overall sanity of the change.)

yabash edited the summary of this revision. (Show Details)Apr 18 2017, 11:41 AM

Thank you again for your comments,
I have edited the summary to explain the changes in Split -
I hope it makes sense now :)

Thank you! I'll let Tim commit this patch, if he has no more concerns.

This revision was automatically updated to reflect the committed changes.

Yes, taken a closer look, the Split() change is an obvious cleanup. Committed.

Thanks!