[PATCH] D60715: [ISEL] Collect argument's forwarding regs when lowering calls

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 13:37:52 PDT 2019


bjope added inline comments.


================
Comment at: lib/CodeGen/TargetInstrInfo.cpp:145
+    ++Tail;
+    MBB->erase(MI);
+  }
----------------
NikolaPrica wrote:
> aprantl wrote:
> > I'd prefer writing two loops (or even better two std::algorithms) for updating and erasing and let the optimizer merge them.
> I've tried with std::remove_if and llvm::remove_if but they require deleted MachineInstr copy assignment operator. So I came up with two solutions:
> 
> `Solution 1`
> ```
> // Update call site info and remove all the dead instructions
>  // from the end of MBB.
>  while (Tail != MBB->end()) {
>    auto MI = Tail++;
>    if (MI->isCall())
>      MBB->getParent()->updateCallSiteInfo(&*MI);
>    MBB->erase(MI);
>  }
> ```
> 
> Or 
> 
>  `Solution 2`
> ```
> // Update call site info.
>  for (auto It = Tail; It != MBB->end(); ++It)
>    if (It->isCall())
>      MBB->getParent()->updateCallSiteInfo(&*It)
> 
>  // Remove all the dead instructions from the end of MBB.
>  for (auto It = Tail; It != MBB->end();) {
>    auto MI = It++;
>    MBB->erase(MI);
>  }
> ```
> 
> @aprantl First example seams better than existing one. I'm wondering whether second with two loops is what you aimed to?
The second loop in "solution 2" can be reduced to `MBB->erase(Tail, MBB->end());` (that is what it used to look like). No need to complicate that part ;-)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60715/new/

https://reviews.llvm.org/D60715





More information about the llvm-commits mailing list