[PATCH] D60715: [ISEL] Collect argument's forwarding regs when lowering calls
Nikola Prica via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 23 07:08:54 PDT 2019
NikolaPrica added a comment.
Thanks for the comments! I've addressed most of them. This patch will be split on 3 parts once we decide how to address comment about updating call site in `TargetInstrInfo`.
================
Comment at: lib/CodeGen/TargetInstrInfo.cpp:145
+ ++Tail;
+ MBB->erase(MI);
+ }
----------------
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?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60715/new/
https://reviews.llvm.org/D60715
More information about the llvm-commits
mailing list