[llvm] 4c5909b - [SampleFDO] Add two passes of MIRAddFSDiscriminatorsPass
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 11 11:11:38 PDT 2021
Author: Rong Xu
Date: 2021-08-11T11:11:04-07:00
New Revision: 4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1
URL: https://github.com/llvm/llvm-project/commit/4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1
DIFF: https://github.com/llvm/llvm-project/commit/4c5909ba83036ed74f2ddd76f69b3b1bf15bd5f1.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/X86/fsafdo_test1.ll
llvm/test/CodeGen/X86/fsafdo_test2.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 4024fd452fc45..c31deceb9ae35 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)
diff --git a/llvm/test/CodeGen/X86/fsafdo_test1.ll b/llvm/test/CodeGen/X86/fsafdo_test1.ll
index 99c65c917f69e..ca7120461481b 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test1.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test1.ll
@@ -3,8 +3,8 @@
; Check that fs-afdo discriminators are generated.
; CHECK: .loc 1 7 3 is_stmt 0 discriminator 2 # foo.c:7:3
; Check: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
-; CHECK: .loc 1 9 5 is_stmt 0 discriminator 268435458 # foo.c:9:5
-; CHECK: .loc 1 7 3 is_stmt 1 discriminator 3892314114 # foo.c:7:3
+; CHECK: .loc 1 9 5 is_stmt 0 discriminator 11266 # foo.c:9:5
+; CHECK: .loc 1 7 3 is_stmt 1 discriminator 11266 # foo.c:7:3
; Check that variable __llvm_fs_discriminator__ is generated.
; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
; CHECK: .section .rodata,"a", at progbits
diff --git a/llvm/test/CodeGen/X86/fsafdo_test2.ll b/llvm/test/CodeGen/X86/fsafdo_test2.ll
index ca26f307b08be..7695f3e373dc6 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test2.ll
@@ -38,9 +38,9 @@
;;
;; Check that fs-afdo discriminators are generated.
; CHECK: .loc 1 23 9 is_stmt 0 discriminator 1 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3892314113 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 2818572289 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3623878657 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3585 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 8705 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 4097 # unroll.c:23:9
;;
;; Check that variable __llvm_fs_discriminator__ is generated.
; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
More information about the llvm-commits
mailing list