This is an archive of the discontinued LLVM Phabricator instance.

Misc cleanups and simplifications for NewGVN. Mostly use a bit more idiomatic C++ where we can, so we can combine some things later.
ClosedPublic

Authored by dberlin on Dec 25 2016, 2:43 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

dberlin retitled this revision from to Misc cleanups and simplifications for NewGVN. Mostly use a bit more idiomatic C++ where we can, so we can combine some things later..
dberlin updated this object.
dberlin added a reviewer: davide.
dberlin added a subscriber: llvm-commits.
davide added inline comments.Dec 26 2016, 3:04 AM
include/llvm/Transforms/Scalar/GVNExpression.h
232–233 ↗(On Diff #82482)

hmm, this is a quite peculiar implementation of operator preincrement/postincrement as they actually don't increment anything.

438–453 ↗(On Diff #82482)

op_inserter and int_op_inserter are nearly identical. Is there any chance you can templatize to reduce the duplication?

lib/Transforms/Scalar/NewGVN.cpp
418–425 ↗(On Diff #82482)

Very nice use of std::transform.

1475–1482 ↗(On Diff #82482)

This is a very minor nit, but (almost) everywhere else in llvm we use BB for a BasicBlock variable. Here we had B to distinguish between it and BB, but I think it makes sense to use BB instead.

1753–1770 ↗(On Diff #82482)

Thanks for expanding the comment. You can consider committing this separately to reduce the diff (as it's fairly independent change).

davide edited edge metadata.Dec 26 2016, 3:26 AM

Side note, there are some spurious whitespace changes so you may want to clang-format the patch while you're there.

dberlin marked 2 inline comments as done.Dec 26 2016, 9:52 AM
dberlin added inline comments.
include/llvm/Transforms/Scalar/GVNExpression.h
232–233 ↗(On Diff #82482)

This is standard for inserters.
See https://gcc.gnu.org/onlinedocs/gcc-4.6.2/libstdc++/api/a01052_source.html#l00408
and
http://en.cppreference.com/w/cpp/iterator/back_insert_iterator
" Incrementing the std::back_insert_iterator is a no-op."

438–453 ↗(On Diff #82482)

yeah, i'll try to fix this.

lib/Transforms/Scalar/NewGVN.cpp
1475–1482 ↗(On Diff #82482)

Fixed

davide added inline comments.Dec 26 2016, 9:55 AM
include/llvm/Transforms/Scalar/GVNExpression.h
232–233 ↗(On Diff #82482)

yeah, makes sense, maybe adding a comment (up to you, not feeling strong about it).

dberlin marked 2 inline comments as done.Dec 26 2016, 11:34 AM
dberlin added inline comments.
include/llvm/Transforms/Scalar/GVNExpression.h
438–453 ↗(On Diff #82482)

This is pretty much beyond my C++ knowledge to fix sanely :)
The problem is that we want both to work.
IE we don't want op_inserter to call int_op_push_back on aggregatevalues, because aggregatevalues have both ops and int_ops.

Even sharing the base functions is non-trivial

davide accepted this revision.Dec 26 2016, 11:37 AM
davide edited edge metadata.

LGTM

include/llvm/Transforms/Scalar/GVNExpression.h
438–453 ↗(On Diff #82482)

Don't worry then =)

This revision is now accepted and ready to land.Dec 26 2016, 11:37 AM
This revision was automatically updated to reflect the committed changes.