This is an archive of the discontinued LLVM Phabricator instance.

[SmallPtrSet] Introduce a find primitive and rewrite count/erase in terms of it
ClosedPublic

Authored by reames on Dec 30 2016, 12:14 PM.

Details

Summary

This was originally motivated by a compile time problem I've since figured out how to solve differently, but the cleanup seemed useful. We had the same logic - which essentially implemented find - in several places. By commoning them out, I can implement find and allow erase to be inlined at the call sites if profitable.

Diff Detail

Repository
rL LLVM

Event Timeline

reames updated this revision to Diff 82739.Dec 30 2016, 12:14 PM
reames retitled this revision from to [SmallPtrSet] Introduce a find primitive and rewrite count/erase in terms of it.
reames updated this object.
reames added reviewers: sanjoy, chandlerc.
reames added a subscriber: llvm-commits.
chandlerc accepted this revision.Dec 30 2016, 5:07 PM
chandlerc edited edge metadata.

LGTM, minor formatting tweaks.

include/llvm/ADT/SmallPtrSet.h
197–198 ↗(On Diff #82739)

extraneous blank lines?

This revision is now accepted and ready to land.Dec 30 2016, 5:07 PM
sanjoy edited edge metadata.Dec 30 2016, 5:30 PM

Please also add some tests.

include/llvm/ADT/SmallPtrSet.h
167 ↗(On Diff #82739)

Early return here if P == EndPointer()?

169 ↗(On Diff #82739)

I'd add an assert here that *Loc is Ptr.

389 ↗(On Diff #82739)

What is endPtr? Is this patch based on some other patch?

reames added inline comments.Dec 30 2016, 6:05 PM
include/llvm/ADT/SmallPtrSet.h
389 ↗(On Diff #82739)

endPtr is already in tree. This is almost "end()", but it can't be because of the breaking API check logic. Honestly, the breaking API check logic looks broken to me. :( It doesn't seem to cover anything other than begin/end, whereas we return other forms of iterators and might reasonable compare them against end.

sanjoy added inline comments.Dec 30 2016, 6:12 PM
include/llvm/ADT/SmallPtrSet.h
389 ↗(On Diff #82739)

Yeah, this part looks fine. I was looking at a stale version of SmallPtrSet.

This revision was automatically updated to reflect the committed changes.