This is an archive of the discontinued LLVM Phabricator instance.

[IR] Add PHINode::removeIncomingValueIf() (NFC)
ClosedPublic

Authored by nikic on Aug 16 2023, 2:58 AM.

Details

Summary

Add an API that allows removing multiple incoming phi values based on a predicate callback, as suggested on D157621.

This makes sure that the removal is linear time rather than quadratic, and avoids subtleties around iterator invalidation.

I have replaced some of the more straightforward users with the new API, though there's a couple more places that should be able to use it.

Diff Detail

Event Timeline

nikic created this revision.Aug 16 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 2:58 AM
nikic requested review of this revision.Aug 16 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 2:58 AM
efriedma accepted this revision.Aug 16 2023, 10:31 AM

LGTM

llvm/lib/IR/Instructions.cpp
150

This isn't the most efficient implementation... instead of using a set, you could iterate over the value operands and the blocks at the same time. But I guess we can improve it later if it matters.

This revision is now accepted and ready to land.Aug 16 2023, 10:31 AM
This revision was automatically updated to reflect the committed changes.