Skip to content

Commit 347186b

Browse files
NuriAmariNuri Amari
andauthored
Avoid Assertion Failure Using -fcs-profile-generate with distributed thin-lto (#129736)
When using `-fcs-generate-profile` with distributed thin-lto in the same fashion we do for local thin-lto, we hit the following assertion: https://github.com/llvm/llvm-project/blob/6041c745f32e8fd60ed24e29e7d919d8d1c87ca6/llvm/lib/Support/PGOOptions.cpp#L36 Using local thin-lto with LLD for MachO, we set the missing path automatically to a default value: https://reviews.llvm.org/D151589. In this fix we add the same behavior. --------- Co-authored-by: Nuri Amari <[email protected]>
1 parent 3695d6c commit 347186b

File tree

9 files changed

+12
-4
lines changed

9 files changed

+12
-4
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex,
13521352
// Context sensitive profile.
13531353
if (CGOpts.hasProfileCSIRInstr()) {
13541354
Conf.RunCSIRInstr = true;
1355-
Conf.CSIRProfile = std::move(CGOpts.InstrProfileOutput);
1355+
Conf.CSIRProfile = getProfileGenName(CGOpts);
13561356
} else if (CGOpts.hasProfileCSIRUse()) {
13571357
Conf.RunCSIRInstr = false;
13581358
Conf.CSIRProfile = std::move(CGOpts.ProfileInstrumentUsePath);

clang/test/CodeGen/thinlto-distributed-backend-skip.ll renamed to clang/test/CodeGen/distributed-thin-lto/backend-skip.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
; RUN: opt -thinlto-bc -o %t.o %s
77

88
; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
9-
; RUN: -fthinlto-index=%S/Inputs/thinlto-distributed-backend-skip.bc \
9+
; RUN: -fthinlto-index=%S/../Inputs/thinlto-distributed-backend-skip.bc \
1010
; RUN: -emit-llvm -o - -x ir %t.o | FileCheck %s
1111

1212
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll renamed to clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=CHECK-DIS
3434
; Round trip it through llvm-as
3535
; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-DIS
36-
; CHECK-DIS: ^0 = module: (path: "{{.*}}thinlto-distributed-cfi-devirt.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
36+
; CHECK-DIS: ^0 = module: (path: "{{.*}}cfi-devirt.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
3737
; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 18, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 1, mustBeUnreachable: 0), typeIdInfo: (typeTests: (^2), typeCheckedLoadVCalls: (vFuncId: (^2, offset: 8), vFuncId: (^2, offset: 0))))))
3838
; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi"))))) ; guid = 7004155349499253778
3939

clang/test/CodeGen/thinlto-distributed-cfi.ll renamed to clang/test/CodeGen/distributed-thin-lto/cfi.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=CHECK-DIS
2424
; Round trip it through llvm-as
2525
; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-DIS
26-
; CHECK-DIS: ^0 = module: (path: "{{.*}}thinlto-distributed-cfi.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
26+
; CHECK-DIS: ^0 = module: (path: "{{.*}}cfi.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
2727
; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 7, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), typeIdInfo: (typeTests: (^2)))))
2828
; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: single, sizeM1BitWidth: 0))) ; guid = 7004155349499253778
2929

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 -fcs-profile-generate -flto=thin -c -o %t/main.bc %s
3+
// RUN: llvm-lto2 run --thinlto-distributed-indexes %t/main.bc -o %t/index -r=%t/main.bc,_main,px
4+
// RUN: %clang -target x86_64-apple-darwin -fcs-profile-generate -c -o %t/main.o -fthinlto-index=%t/main.bc.thinlto.bc %t/main.bc
5+
6+
int main() {
7+
return 0;
8+
}

0 commit comments

Comments
 (0)