This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Provide an edge-based interface in AAIsDead
ClosedPublic

Authored by okura on Aug 7 2020, 12:23 PM.

Details

Summary

This patch produces an edge-based interface in AAIsDead.
By this, we can query a set of basic blocks that are directly reachable from a given basic block.
This is specifically useful for implementation of AAReachability.

Diff Detail

Event Timeline

okura created this revision.Aug 7 2020, 12:23 PM
Herald added a reviewer: homerdin. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
okura requested review of this revision.Aug 7 2020, 12:23 PM
jdoerfert added inline comments.Aug 7 2020, 12:30 PM
llvm/include/llvm/Transforms/IPO/Attributor.h
2654

This will create (and below copy) these vectors all the time, that should be avoided. Can we instead make this a wrapper around succ_begin, e.g., you ask for a successor iterator only for live edges, and you can use it with succ_end. Basically, return an iterator that skips dead edges.

okura updated this revision to Diff 284077.Aug 7 2020, 3:52 PM
  • change interface to return an iterator corresponds to the next live successor
  • make cache for edges in AAIsDeadFunction
okura updated this revision to Diff 284459.Aug 10 2020, 11:40 AM
  • check state validity in getNextAssumedLiveSuccessor
jdoerfert added inline comments.Aug 11 2020, 5:36 AM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
3183

Given that a block has usually 1 or 2 successors we should consider a different data structure here. I would initially think a Set<std::pair<BasicBlock*,BasicBlock*>> is adequate, so we collect edges that are assumed live in there.

okura updated this revision to Diff 287495.Aug 24 2020, 2:19 PM
  • change whole interface
jdoerfert accepted this revision.Aug 25 2020, 2:11 PM

LGTM, one nit

llvm/lib/Transforms/IPO/AttributorAttributes.cpp
3386

Move this into the else case below. Only if I is a terminator we need to do this and then we know it is an edge. This actually doesn't catch self loops, so move the insert into the else and remove the condition.

This revision is now accepted and ready to land.Aug 25 2020, 2:11 PM
okura updated this revision to Diff 287788.Aug 25 2020, 3:52 PM
  • fix nit
This revision was automatically updated to reflect the committed changes.