Skip to content

[nfc][ctx_prof] Use one flag for the "use" scenario #103377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions llvm/lib/Transforms/IPO/FunctionImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/ThinLTO/X86/ctxprof.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading