Skip to content

Commit 4ef49b0

Browse files
author
Nuri Amari
committed
[dthin-lto][cs-irpgo] Avoid assertion with unset profile output path
When using -fcs-generate-profile with distributed thin-lto without setting a profile output path, we hit an assertion constructing PGOOptions: https://github.com/llvm/llvm-project/blob/6041c745f32e8fd60ed24e29e7d919d8d1c87ca6/llvm/lib/Support/PGOOptions.cpp#L36 In non distributed thin-lto settings (local thin-lto for example), this profile output path is automatically set to a default value if -fcs-generate-profile is passed. This patch follows suit, using the default output path if one isn't set.
1 parent 5e2b061 commit 4ef49b0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,10 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex,
13341334
// Context sensitive profile.
13351335
if (CGOpts.hasProfileCSIRInstr()) {
13361336
Conf.RunCSIRInstr = true;
1337-
Conf.CSIRProfile = std::move(CGOpts.InstrProfileOutput);
1337+
Conf.CSIRProfile = CGOpts.InstrProfileOutput.empty()
1338+
? getDefaultProfileGenName()
1339+
: std::move(CGOpts.InstrProfileOutput);
1340+
13381341
} else if (CGOpts.hasProfileCSIRUse()) {
13391342
Conf.RunCSIRInstr = false;
13401343
Conf.CSIRProfile = std::move(CGOpts.ProfileInstrumentUsePath);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: mkdir -p %t
2+
// RUN: %clang -target x86_64-apple-darwin -flto=thin %s -fcs-profile-generate -c -o %t/main.bc
3+
// RUN: llvm-lto2 run --thinlto-distributed-indexes %t/main.bc -r=%t/main.bc,_main,px -o %t/index
4+
// RUN: %clang -target x86_64-apple-darwin -fcs-profile-generate -fthinlto-index=%t/main.bc.thinlto.bc %t/main.bc -c -o main.o
5+
6+
int main() {
7+
return 0;
8+
}

0 commit comments

Comments
 (0)