[PATCH] D30835: [DebugInfo][X86] Teach Optimize LEAs pass to handle debug values

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 10:01:40 PDT 2017


On Fri, Mar 17, 2017 at 9:57 AM Andrew Ng via Phabricator <
reviews at reviews.llvm.org> wrote:

> andrewng added a comment.
>
> Thanks for the review.
>
>
>
> ================
> Comment at: lib/Target/X86/X86OptimizeLEAs.cpp:567-568
> +        unsigned LastVReg = Last.getOperand(0).getReg();
> +        for (auto UI = MRI->use_nodbg_begin(LastVReg),
> +                  UE = MRI->use_nodbg_end();
>               UI != UE;) {
> ----------------
> dblaikie wrote:
> > I think you can use:
> >
> >   for (MachineOperand &MO : MRI->use_nodbg_operands(LastVReg))
> >
> > here, probably?
> Yes, at first I thought so too, but inside the loop there is:
> ```
> MO.setReg(First.getOperand(0).getReg());
> ```
> which could affect the use iterator. So the original code which increments
> the use iterator before any changes is safer.
>

Not quite sure how one could be safer than the other - they're the same
code, aren't they? (range-for and the manually written for loop look like
they have identical semantics)


>
>
> https://reviews.llvm.org/D30835
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/626915f1/attachment-0001.html>


More information about the llvm-commits mailing list