[PATCH] D104579: [SampleFDO] Add two passes of MIRAddFSDiscriminatorsPass

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 10 10:52:07 PDT 2021


xur updated this revision to Diff 365539.
xur retitled this revision from "[SampleFDO] Add Pass1 of MIRAddFSDiscriminatorsPass before Block-Placement" to "[SampleFDO] Add two passes of MIRAddFSDiscriminatorsPass".
xur edited the summary of this revision.
xur added a comment.

Add another pass berfore RA (as suggested by WenLei).
I tested the performance for FSAFDO Loader using one google benchmark.
This extra pass turns to be positive in performance -- I'm seeing additional 0.6% - 0.8% improvement.

BTW, sorry for the delay. I was off work last month.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104579/new/

https://reviews.llvm.org/D104579

Files:
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/X86/fsafdo_test1.ll
  llvm/test/CodeGen/X86/fsafdo_test2.ll


Index: llvm/test/CodeGen/X86/fsafdo_test2.ll
===================================================================
--- llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ 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__
Index: llvm/test/CodeGen/X86/fsafdo_test1.ll
===================================================================
--- llvm/test/CodeGen/X86/fsafdo_test1.ll
+++ 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
Index: llvm/lib/CodeGen/TargetPassConfig.cpp
===================================================================
--- llvm/lib/CodeGen/TargetPassConfig.cpp
+++ llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -1113,6 +1113,10 @@
   // where it becomes safe again so stop debugifying here.
   DebugifyIsSafe = false;
 
+  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 +1469,9 @@
 
 /// 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104579.365539.patch
Type: text/x-patch
Size: 2765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210810/d7570422/attachment.bin>


More information about the llvm-commits mailing list