aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetPassConfig.cpp
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2021-08-11 10:56:03 -0700
committerRong Xu <xur@google.com>2021-08-11 11:11:04 -0700
commit4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1 (patch)
treeba364af9982f9cb3a9179b62cfc50ff39552b80c /llvm/lib/CodeGen/TargetPassConfig.cpp
parent7de439b2be4a046da541b625812f2fe34c54c4b9 (diff)
downloadllvm-4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1.zip
llvm-4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1.tar.gz
llvm-4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1.tar.bz2
[SampleFDO] Add two passes of MIRAddFSDiscriminatorsPass
This patch adds Pass1 of MIRADDFSDiscriminatorsPass before register allocation, and Pass2 of MIRAddFSDiscriminatorsPass before Block-Placement. This is still under --enable-fs-discrmininator option (default false). This would reduce the turn-around time for FSAFDO transition. Differential Revision: https://reviews.llvm.org/D104579
Diffstat (limited to 'llvm/lib/CodeGen/TargetPassConfig.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetPassConfig.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 4024fd4..c31dece 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -1113,6 +1113,12 @@ void TargetPassConfig::addMachinePasses() {
// where it becomes safe again so stop debugifying here.
DebugifyIsSafe = false;
+ // Add a FSDiscriminator pass right before RA, so that we could get
+ // more precise SampleFDO profile for RA.
+ if (EnableFSDiscriminator)
+ addPass(createMIRAddFSDiscriminatorsPass(
+ sampleprof::FSDiscriminatorPass::Pass1));
+
// Run register allocation and passes that are tightly coupled with it,
// including phi elimination and scheduling.
if (getOptimizeRegAlloc())
@@ -1465,6 +1471,9 @@ bool TargetPassConfig::addGCPasses() {
/// Add standard basic block placement passes.
void TargetPassConfig::addBlockPlacement() {
+ if (EnableFSDiscriminator)
+ addPass(createMIRAddFSDiscriminatorsPass(
+ sampleprof::FSDiscriminatorPass::Pass2));
if (addPass(&MachineBlockPlacementID)) {
// Run a separate pass to collect block placement statistics.
if (EnableBlockPlacementStats)