[llvm] [nfc][ctx_prof] Use one flag for the "use" scenario (PR #103377)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 10:54:20 PDT 2024
https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/103377
No need to have two flags, one for the thinlink and one for compilation.
>From 53968bbaf5ef7a723cc1779fba22f745bc5d9cc6 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Tue, 13 Aug 2024 10:52:56 -0700
Subject: [PATCH] [nfc][ctx_prof] Use one flag for the "use" scenario
No need to have two flags, one for the thinlink and one for compilation.
---
llvm/lib/Transforms/IPO/FunctionImport.cpp | 12 +++++-------
llvm/test/ThinLTO/X86/ctxprof.ll | 2 +-
2 files changed, 6 insertions(+), 8 deletions(-)
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