[PATCH] CodeGenPrep: rewrite a few loops in C++11 style
Quentin Colombet
qcolombet at apple.com
Wed Jan 7 14:58:46 PST 2015
On Jan 7, 2015, at 2:48 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> 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.
>
> 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?
I prefer the BasicBlock & version, which is indeed much clearer!
Q.
More information about the llvm-commits
mailing list