[PATCH] D74511: [BFI] Fix missed BFI updates in MachineSink.
Hiroshi Yamauchi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 21 09:56:11 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e3e242209c7: [BFI] Fix missed BFI updates in MachineSink. (authored by yamauchi).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74511/new/
https://reviews.llvm.org/D74511
Files:
llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
llvm/lib/CodeGen/MachineSink.cpp
llvm/test/CodeGen/X86/machine-sink.ll
Index: llvm/test/CodeGen/X86/machine-sink.ll
===================================================================
--- llvm/test/CodeGen/X86/machine-sink.ll
+++ llvm/test/CodeGen/X86/machine-sink.ll
@@ -1,4 +1,5 @@
; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-pc-linux -check-bfi-unknown-block-queries=true | FileCheck %s
; Checks if movl $1 is sinked to critical edge.
; CHECK-NOT: movl $1
Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/lib/CodeGen/MachineSink.cpp
@@ -91,7 +91,7 @@
MachineDominatorTree *DT; // Machine dominator tree
MachinePostDominatorTree *PDT; // Machine post dominator tree
MachineLoopInfo *LI;
- const MachineBlockFrequencyInfo *MBFI;
+ MachineBlockFrequencyInfo *MBFI;
const MachineBranchProbabilityInfo *MBPI;
AliasAnalysis *AA;
@@ -351,6 +351,11 @@
<< printMBBReference(*Pair.first) << " -- "
<< printMBBReference(*NewSucc) << " -- "
<< printMBBReference(*Pair.second) << '\n');
+ if (MBFI) {
+ auto NewSuccFreq = MBFI->getBlockFreq(Pair.first) *
+ MBPI->getEdgeProbability(Pair.first, NewSucc);
+ MBFI->setBlockFreq(NewSucc, NewSuccFreq.getFrequency());
+ }
MadeChange = true;
++NumSplit;
} else
Index: llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -247,6 +247,12 @@
return MBFI->isIrrLoopHeader(MBB);
}
+void MachineBlockFrequencyInfo::setBlockFreq(const MachineBasicBlock *MBB,
+ uint64_t Freq) {
+ assert(MBFI && "Expected analysis to be available");
+ MBFI->setBlockFreq(MBB, Freq);
+}
+
const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
return MBFI ? MBFI->getFunction() : nullptr;
}
Index: llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -66,6 +66,8 @@
bool isIrrLoopHeader(const MachineBasicBlock *MBB);
+ void setBlockFreq(const MachineBasicBlock *MBB, uint64_t Freq);
+
const MachineFunction *getFunction() const;
const MachineBranchProbabilityInfo *getMBPI() const;
void view(const Twine &Name, bool isSimple = true) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74511.245902.patch
Type: text/x-patch
Size: 2684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200221/4ed3d998/attachment-0001.bin>
More information about the llvm-commits
mailing list