This is an archive of the discontinued LLVM Phabricator instance.

[PGO][PGSO] Instrument the code gen / target passes.
ClosedPublic

Authored by hjyamauchi on Dec 6 2019, 2:05 PM.

Details

Summary

Split off of D67120.

Add the profile guided size optimization instrumentation / queries in the code
gen or target passes. This doesn't enable the size optimizations in those passes
yet as they are currently disabled in shouldOptimizeForSize (for non-IR pass
queries).

A second try after reverted D71072.

Diff Detail

Event Timeline

hjyamauchi created this revision.Dec 6 2019, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2019, 2:05 PM
Herald added a subscriber: hiraditya. · View Herald Transcript

The diff from D71072 is MachineOptimizationRemarkEmitter.h and AsmPrinter.cpp around line 1694.

--- a/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
+++ b/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
@@ -182,6 +182,10 @@ public:
     }
   }
 
+  MachineBlockFrequencyInfo *getBFI() {
+    return MBFI;
+  }
+
 private:
   MachineFunction &MF;
 
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1692,7 +1692,10 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
   ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
   PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
   MBFI = (PSI && PSI->hasProfileSummary()) ?
-         &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() :
+         // ORE conditionally computes MBFI. If available, use it, otherwise
+         // request it.
+         (ORE->getBFI() ? ORE->getBFI() :
+          &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI()) :
          nullptr;
 }
davidxl accepted this revision.Dec 6 2019, 4:03 PM

lgtm

This revision is now accepted and ready to land.Dec 6 2019, 4:03 PM
This revision was automatically updated to reflect the committed changes.