This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Add VPBlockUtils::basicBlocksOnly helper.
ClosedPublic

Authored by fhahn on Apr 22 2021, 11:06 AM.

Details

Summary

This patch adds basicBlocksOnly and constBasicBlocksOnly helpers which
take an iterator range over VPBlockBase * and const VPBlockBase *
respectively, and return an iterator range that only includes
VPBasicBlocks.

Unfortunately I could not think of a way to have a single version of
basicBlocksOnly that can take arbitrary iterators and also handle
filtering/mapping of both VPBlockBase * and const VPBlockBase *.
Unfortunately, filter_range does not work with iterators over pointers,
so we need to map it to a reference and back. Mapping back to a pointer
is optional, but more convenient when using the iterator range to
populate containers.

Diff Detail

Event Timeline

fhahn created this revision.Apr 22 2021, 11:06 AM
fhahn requested review of this revision.Apr 22 2021, 11:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 11:06 AM
Herald added a subscriber: vkmr. · View Herald Transcript
a.elovikov accepted this revision.Apr 22 2021, 12:21 PM

VPlan part looks good to me. I'm not familiar with implementation details of the filtered_iterator to discuss the to_reference->filter->to_pointer approach though. Regardless of that, it's an improvement in interfaces, so LGTM unless someone has a way to make filtering work with pointer directly.

This revision is now accepted and ready to land.Apr 22 2021, 12:21 PM

VPlan part looks good to me. I'm not familiar with implementation details of the filtered_iterator to discuss the to_reference->filter->to_pointer approach though. Regardless of that, it's an improvement in interfaces, so LGTM unless someone has a way to make filtering work with pointer directly.

Thanks for taking a look! If it turns out there's a better way to implement the interface I'm move than happy to adjust this, even after it goes in :)

This revision was landed with ongoing or failed builds.Apr 25 2021, 9:39 AM
This revision was automatically updated to reflect the committed changes.