[PATCH] D100013: [GreedyRA ORE] Extract computeNumberOfSplillsReloads to use in different places. NFC.
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 00:53:18 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b64c662c795: [GreedyRA ORE] Extract computeNumberOfSplillsReloads to use in different places. (authored by skatkov).
Changed prior to commit:
https://reviews.llvm.org/D100013?vs=335714&id=336023#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100013/new/
https://reviews.llvm.org/D100013
Files:
llvm/lib/CodeGen/RegAllocGreedy.cpp
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -567,7 +567,10 @@
void report(MachineOptimizationRemarkMissed &R);
};
- /// Compute and report the number of spills and reloads for a loop.
+ /// Compute the number of spills and reloads for a basic block.
+ RAGreedyStats computeNumberOfSplillsReloads(MachineBasicBlock &MBB);
+
+ /// Compute and report the number of spills through a remark.
RAGreedyStats reportNumberOfSplillsReloads(MachineLoop *L);
/// Report the number of spills and reloads for each loop.
@@ -3137,6 +3140,33 @@
R << NV("NumFoldedReloads", FoldedReloads) << " folded reloads ";
}
+RAGreedy::RAGreedyStats
+RAGreedy::computeNumberOfSplillsReloads(MachineBasicBlock &MBB) {
+ RAGreedyStats Stats;
+ const MachineFrameInfo &MFI = MF->getFrameInfo();
+ int FI;
+
+ for (MachineInstr &MI : MBB) {
+ SmallVector<const MachineMemOperand *, 2> Accesses;
+ auto isSpillSlotAccess = [&MFI](const MachineMemOperand *A) {
+ return MFI.isSpillSlotObjectIndex(cast<FixedStackPseudoSourceValue>(
+ A->getPseudoValue())->getFrameIndex());
+ };
+
+ if (TII->isLoadFromStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI))
+ ++Stats.Reloads;
+ else if (TII->hasLoadFromStackSlot(MI, Accesses) &&
+ llvm::any_of(Accesses, isSpillSlotAccess))
+ ++Stats.FoldedReloads;
+ else if (TII->isStoreToStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI))
+ ++Stats.Spills;
+ else if (TII->hasStoreToStackSlot(MI, Accesses) &&
+ llvm::any_of(Accesses, isSpillSlotAccess))
+ ++Stats.FoldedSpills;
+ }
+ return Stats;
+}
+
RAGreedy::RAGreedyStats RAGreedy::reportNumberOfSplillsReloads(MachineLoop *L) {
RAGreedyStats Stats;
@@ -3144,32 +3174,10 @@
for (MachineLoop *SubLoop : *L)
Stats.add(reportNumberOfSplillsReloads(SubLoop));
- const MachineFrameInfo &MFI = MF->getFrameInfo();
- int FI;
-
for (MachineBasicBlock *MBB : L->getBlocks())
// Handle blocks that were not included in subloops.
if (Loops->getLoopFor(MBB) == L)
- for (MachineInstr &MI : *MBB) {
- SmallVector<const MachineMemOperand *, 2> Accesses;
- auto isSpillSlotAccess = [&MFI](const MachineMemOperand *A) {
- return MFI.isSpillSlotObjectIndex(
- cast<FixedStackPseudoSourceValue>(A->getPseudoValue())
- ->getFrameIndex());
- };
-
- if (TII->isLoadFromStackSlot(MI, FI) && MFI.isSpillSlotObjectIndex(FI))
- ++Stats.Reloads;
- else if (TII->hasLoadFromStackSlot(MI, Accesses) &&
- llvm::any_of(Accesses, isSpillSlotAccess))
- ++Stats.FoldedReloads;
- else if (TII->isStoreToStackSlot(MI, FI) &&
- MFI.isSpillSlotObjectIndex(FI))
- ++Stats.Spills;
- else if (TII->hasStoreToStackSlot(MI, Accesses) &&
- llvm::any_of(Accesses, isSpillSlotAccess))
- ++Stats.FoldedSpills;
- }
+ Stats.add(computeNumberOfSplillsReloads(*MBB));
if (!Stats.isEmpty()) {
using namespace ore;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100013.336023.patch
Type: text/x-patch
Size: 3215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/794ce82a/attachment.bin>
More information about the llvm-commits
mailing list