[llvm] 6807ca8 - [nfc][ctx_prof] Use one flag for the "use" scenario (#103377)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 11:00:54 PDT 2024


Author: Mircea Trofin
Date: 2024-08-13T11:00:51-07:00
New Revision: 6807ca8e937e6949af838995964613fab2fbe0dc

URL: https://github.com/llvm/llvm-project/commit/6807ca8e937e6949af838995964613fab2fbe0dc
DIFF: https://github.com/llvm/llvm-project/commit/6807ca8e937e6949af838995964613fab2fbe0dc.diff

LOG: [nfc][ctx_prof] Use one flag for the "use" scenario (#103377)

No need to have two flags, one for the thinlink and one for compilation.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/FunctionImport.cpp
    llvm/test/ThinLTO/X86/ctxprof.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 3364628be841e3..6ae89a49b6b9a3 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -174,9 +174,7 @@ static cl::opt<std::string> WorkloadDefinitions(
              "}"),
     cl::Hidden);
 
-static cl::opt<std::string>
-    ContextualProfile("thinlto-pgo-ctx-prof",
-                      cl::desc("Path to a contextual profile."), cl::Hidden);
+extern cl::opt<std::string> UseCtxProfile;
 
 namespace llvm {
 extern cl::opt<bool> EnableMemProfContextDisambiguation;
@@ -671,7 +669,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
 
   void loadFromCtxProf() {
     std::error_code EC;
-    auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(ContextualProfile);
+    auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(UseCtxProfile);
     if (std::error_code EC = BufferOrErr.getError()) {
       report_fatal_error("Failed to open contextual profile file");
       return;
@@ -722,12 +720,12 @@ class WorkloadImportsManager : public ModuleImportsManager {
       const ModuleSummaryIndex &Index,
       DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists)
       : ModuleImportsManager(IsPrevailing, Index, ExportLists) {
-    if (ContextualProfile.empty() == WorkloadDefinitions.empty()) {
+    if (UseCtxProfile.empty() == WorkloadDefinitions.empty()) {
       report_fatal_error(
           "Pass only one of: -thinlto-pgo-ctx-prof or -thinlto-workload-def");
       return;
     }
-    if (!ContextualProfile.empty())
+    if (!UseCtxProfile.empty())
       loadFromCtxProf();
     else
       loadFromJson();
@@ -749,7 +747,7 @@ std::unique_ptr<ModuleImportsManager> ModuleImportsManager::create(
         IsPrevailing,
     const ModuleSummaryIndex &Index,
     DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists) {
-  if (WorkloadDefinitions.empty() && ContextualProfile.empty()) {
+  if (WorkloadDefinitions.empty() && UseCtxProfile.empty()) {
     LLVM_DEBUG(dbgs() << "[Workload] Using the regular imports manager.\n");
     return std::unique_ptr<ModuleImportsManager>(
         new ModuleImportsManager(IsPrevailing, Index, ExportLists));

diff  --git a/llvm/test/ThinLTO/X86/ctxprof.ll b/llvm/test/ThinLTO/X86/ctxprof.ll
index 4c86ec9f4c4790..5c1f5f99daa161 100644
--- a/llvm/test/ThinLTO/X86/ctxprof.ll
+++ b/llvm/test/ThinLTO/X86/ctxprof.ll
@@ -46,7 +46,7 @@
 ; RUN: llvm-ctxprof-util fromJSON --input %t_exp/ctxprof.json --output %t_exp/ctxprof.bitstream
 ; RUN: llvm-lto2 run %t/m1.bc %t/m2.bc \
 ; RUN:  -o %t_exp/result.o -save-temps \
-; RUN:  -thinlto-pgo-ctx-prof=%t_exp/ctxprof.bitstream \
+; RUN:  -use-ctx-profile=%t_exp/ctxprof.bitstream \
 ; RUN:  -r %t/m1.bc,m1_f1,plx \
 ; RUN:  -r %t/m2.bc,m2_f1,plx
 ; RUN: llvm-dis %t_exp/result.o.1.3.import.bc -o - | FileCheck %s --check-prefix=FIRST


        


More information about the llvm-commits mailing list