[PATCH] D94981: [LiveDebugVariables] Add cache for SkipPHIsLabelsAndDebug to prevent iterating the same set of PHI/LABEL/Debug instructions repeatedly.
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 28 13:51:17 PST 2021
dblaikie added inline comments.
================
Comment at: llvm/lib/CodeGen/LiveDebugVariables.cpp:1309-1315
+ if (MachineInstr *BI = BBSkipInstsMap[MBB])
+ BeginIt = std::next(MachineBasicBlock::iterator(BI));
+ else
+ BeginIt = MBB->begin();
+ MachineBasicBlock::iterator I = MBB->SkipPHIsLabelsAndDebug(BeginIt);
+ if (I != MBB->begin())
+ BBSkipInstsMap[MBB] = &*std::prev(I);
----------------
Could you store iterators in the map instead of pointers? Would save having to do the `&*` dance on the way in and the `MachineBasicBlock::iterator` dance on the way out?
Also, it'd be good to avoid the extra BBSkipInstsMap lookup, if possible. Would this work?
```
auto& I = BBSkipInstsMap.insert(MBB, MBB->begin()).first->second;
I = MBB->SkipPHIsLabelsAndDebug(I);
return I;
```
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94981/new/
https://reviews.llvm.org/D94981
More information about the llvm-commits
mailing list