<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 9, 2020 at 3:57 PM Alina Sbirlea via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>As part of an ongoing work to extend the GraphDiff (this models a CFG view), I came across the need to have a common interface for accessing successors/predecessors in various IR units, such that a type such as `typename NodeT::succ_iterator` could be used in templated code.</div></div></blockquote><div><br>I /think/ this can be achieved with the existing API by using "decltype(succ_begin(std::declval<NodeT>()))" instead of the typename you've got as an example (it looks like succ_begin is the extension point - but the problem you're having is naming its return type? decltype would be one option) - you could make a trait wrapper around that or the like if you need this type name in a bunch of disparate places (where they can't share a typedef).<br><br>Would that suffice? are there other aspects of your use case that don't line up well with the existing non-member/overload API?<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>In particular, the need arose for BasicBlocks, MachineBasicBlocks, VPBlockBase and clang::CFGBlock.</div><div><br></div><div>The least invasive change seemed to be to use the interface already being used in MachineBasicBlock and clang::CFGBlock, and: </div><div>(1) update BasicBlock to use this instead of the "global" `succ_iterator` in IR/CFG.h</div>(2) add the same interfaces in VPBlockBase as simple wrappers over existing Successors/Predecessors vectors.<div><br></div><div>I've been working on a few patches to make this happen, but I'd like the community's thoughts on this before deep-diving into code reviews.</div><div><br></div><div>For some concrete view of what the changes look like, I uploaded two preliminary patches:</div><div>(1) part 1: <a href="https://reviews.llvm.org/D75881" style="text-decoration-line:none" target="_blank"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">D75881</span></a>: Introducing class specific iterators</div><div>(2) <a href="https://reviews.llvm.org/D75882" style="text-decoration-line:none" target="_blank"><span style="font-size:11pt;font-family:Arial;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wrap">D75882</span></a></div><div>(1) part 2: pending: Cleaning up existing usages; example replacement: `succ_begin(BB)` with `BB->succ_begin()`.<br></div><div>(1) part3/4: pending: Add class specific iterators to `Instruction` and clean up existing usages just as for `BasicBlock`.</div><div><br></div><div>I split the above (1) just to clarify what interfaces are added versus the NFC cleanups that follow. But it could be done just as well in a single patch.</div><div><br></div><div>I welcome comments on this, and if there's something I missed explaining please let me know.</div><div><br></div><div>Thank you,</div><div>Alina</div><div><br></div><div><br></div><div><br></div><div><br></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>