This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Pass AggressiveInsts to DominatesMergePoint by reference. Remove null check.
ClosedPublic

Authored by craig.topper on Sep 26 2018, 1:59 PM.

Details

Summary

At some point in the past the recursion in DominatesMergePoint used to pass null for AggressiveInsts as part of the recursion. It no longer does this. So there is no way for AggressiveInsts to be null.

This passes it by reference and removes the null check to make this explicit.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Sep 26 2018, 1:59 PM
efriedma accepted this revision.Oct 4 2018, 3:48 PM

LGTM

This revision is now accepted and ready to land.Oct 4 2018, 3:48 PM
xbolva00 added inline comments.
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

AggressiveInsts.find(I) != AggressiveInsts.end()

craig.topper added inline comments.Oct 4 2018, 4:06 PM
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

Why?

xbolva00 added inline comments.Oct 4 2018, 4:11 PM
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

Count() counts them all, useless iterations after first occurance..

This condition just checks if there is any occurence of I in the AgressiveInst, so “find” is better choice I think

craig.topper added inline comments.Oct 4 2018, 4:23 PM
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

It's a set, it can't have more than one. The implementation of count knows this and in fact it is implemented as just find() != end(). std::map, std::set, SmallPtrSet all have good implentations of count. Only things like std::multiset/multimap would have an implementation that really has to count.

xbolva00 added inline comments.Oct 4 2018, 4:24 PM
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

Ok, sorry then, I didn't check the declaration :)

craig.topper added inline comments.Oct 4 2018, 4:32 PM
lib/Transforms/Utils/SimplifyCFG.cpp
353 ↗(On Diff #167199)

FWIW, C++20 adds contains() to all of the associative containers which provides the equivalent of find() != end() for multiset/multimap. And makes set/map/unordered_set/unordered_map read better than using count().

This revision was automatically updated to reflect the committed changes.