[PATCH] CodeGenPrep: rewrite a few loops in C++11 style

Nick Lewycky nicholas at mxc.ca
Mon Jan 12 22:19:28 PST 2015


Duncan P. N. Exon Smith wrote:
>
>> On 2015-Jan-07, at 14:41, Ramkumar Ramachandra<artagnon at gmail.com>  wrote:
>>
>> It depends on what you want to construct from the iteration. You could construct a BasicBlock, like you said; but this is perfectly valid too: you can try it out, and see that tests pass.
>>
>
> This works because of an implementation quirk of `ilist_iterator`,
> which can be constructed from a reference of the node type.

That's really not an implementation quirk, that's part of the intended 
interface and there is code which does this on purpose (admittedly 
rare). It's one of the nice things you can do with intrusive lists, you 
can always go from one node to the prev/next node. This is how we expose 
that.

> While technically valid, this code is misleading, and I don't know
> that we want to propagate dependencies on that conversion.  I think
> this should instead be, e.g.:
>
>      for (BasicBlock&BB : F)
>        EverMadeChange |= bypassSlowDivision(F,&BB, BypassWidths);
>
> Thoughts from anyone else?
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list