https://github.com/NuriAmari updated 
https://github.com/llvm/llvm-project/pull/129736

>From fc06ad49b1b166dd1ef09c8babe65c337487ee65 Mon Sep 17 00:00:00 2001
From: Nuri Amari <nuriam...@fb.com>
Date: Mon, 3 Mar 2025 16:10:54 -0800
Subject: [PATCH 1/2] Move Clang distributd thin-lto codegen tests into their
 own directory

clang/test/CodeGen includes many tests, some of which pretain to
distributed thin-lto. While they have similar names, it is easier to
find them all in a common directory.
---
 .../backend-skip.ll}                                            | 2 +-
 .../{thinlto-distributed.ll => distributed-thin-lto/basic.ll}   | 0
 .../cfi-devirt.ll}                                              | 2 +-
 .../{thinlto-distributed-cfi.ll => distributed-thin-lto/cfi.ll} | 2 +-
 .../newpm.ll}                                                   | 0
 .../objc-contract-pass.ll}                                      | 0
 .../supports-hot-cold-new.ll}                                   | 0
 7 files changed, 3 insertions(+), 3 deletions(-)
 rename clang/test/CodeGen/{thinlto-distributed-backend-skip.ll => 
distributed-thin-lto/backend-skip.ll} (87%)
 rename clang/test/CodeGen/{thinlto-distributed.ll => 
distributed-thin-lto/basic.ll} (100%)
 rename clang/test/CodeGen/{thinlto-distributed-cfi-devirt.ll => 
distributed-thin-lto/cfi-devirt.ll} (97%)
 rename clang/test/CodeGen/{thinlto-distributed-cfi.ll => 
distributed-thin-lto/cfi.ll} (95%)
 rename clang/test/CodeGen/{thinlto-distributed-newpm.ll => 
distributed-thin-lto/newpm.ll} (100%)
 rename clang/test/CodeGen/{thinlto-distributed-objc-contract-pass.ll => 
distributed-thin-lto/objc-contract-pass.ll} (100%)
 rename clang/test/CodeGen/{thinlto-distributed-supports-hot-cold-new.ll => 
distributed-thin-lto/supports-hot-cold-new.ll} (100%)

diff --git a/clang/test/CodeGen/thinlto-distributed-backend-skip.ll 
b/clang/test/CodeGen/distributed-thin-lto/backend-skip.ll
similarity index 87%
rename from clang/test/CodeGen/thinlto-distributed-backend-skip.ll
rename to clang/test/CodeGen/distributed-thin-lto/backend-skip.ll
index d7b8225ee2693..62aa8aa8e7dc4 100644
--- a/clang/test/CodeGen/thinlto-distributed-backend-skip.ll
+++ b/clang/test/CodeGen/distributed-thin-lto/backend-skip.ll
@@ -6,7 +6,7 @@
 ; RUN: opt -thinlto-bc -o %t.o %s
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
-; RUN:   -fthinlto-index=%S/Inputs/thinlto-distributed-backend-skip.bc \
+; RUN:   -fthinlto-index=%S/../Inputs/thinlto-distributed-backend-skip.bc \
 ; RUN:   -emit-llvm -o - -x ir %t.o | FileCheck %s
 
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/clang/test/CodeGen/thinlto-distributed.ll 
b/clang/test/CodeGen/distributed-thin-lto/basic.ll
similarity index 100%
rename from clang/test/CodeGen/thinlto-distributed.ll
rename to clang/test/CodeGen/distributed-thin-lto/basic.ll
diff --git a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll 
b/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
similarity index 97%
rename from clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
rename to clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
index acbcdcdb4fd02..a5792eee8abfb 100644
--- a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ b/clang/test/CodeGen/distributed-thin-lto/cfi-devirt.ll
@@ -33,7 +33,7 @@
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=CHECK-DIS
 ; Round trip it through llvm-as
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | 
FileCheck %s --check-prefix=CHECK-DIS
-; CHECK-DIS: ^0 = module: (path: 
"{{.*}}thinlto-distributed-cfi-devirt.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, 
{{.*}}, {{.*}}))
+; CHECK-DIS: ^0 = module: (path: "{{.*}}cfi-devirt.ll.tmp.o", hash: ({{.*}}, 
{{.*}}, {{.*}}, {{.*}}, {{.*}}))
 ; 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))))))
 ; 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
 
diff --git a/clang/test/CodeGen/thinlto-distributed-cfi.ll 
b/clang/test/CodeGen/distributed-thin-lto/cfi.ll
similarity index 95%
rename from clang/test/CodeGen/thinlto-distributed-cfi.ll
rename to clang/test/CodeGen/distributed-thin-lto/cfi.ll
index 6023ba8f32df9..696f2dc4ea634 100644
--- a/clang/test/CodeGen/thinlto-distributed-cfi.ll
+++ b/clang/test/CodeGen/distributed-thin-lto/cfi.ll
@@ -23,7 +23,7 @@
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=CHECK-DIS
 ; Round trip it through llvm-as
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | 
FileCheck %s --check-prefix=CHECK-DIS
-; CHECK-DIS: ^0 = module: (path: "{{.*}}thinlto-distributed-cfi.ll.tmp.o", 
hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
+; CHECK-DIS: ^0 = module: (path: "{{.*}}cfi.ll.tmp.o", hash: ({{.*}}, {{.*}}, 
{{.*}}, {{.*}}, {{.*}}))
 ; 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)))))
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: 
single, sizeM1BitWidth: 0))) ; guid = 7004155349499253778
 
diff --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/distributed-thin-lto/newpm.ll
similarity index 100%
rename from clang/test/CodeGen/thinlto-distributed-newpm.ll
rename to clang/test/CodeGen/distributed-thin-lto/newpm.ll
diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll 
b/clang/test/CodeGen/distributed-thin-lto/objc-contract-pass.ll
similarity index 100%
rename from clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll
rename to clang/test/CodeGen/distributed-thin-lto/objc-contract-pass.ll
diff --git a/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll 
b/clang/test/CodeGen/distributed-thin-lto/supports-hot-cold-new.ll
similarity index 100%
rename from clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
rename to clang/test/CodeGen/distributed-thin-lto/supports-hot-cold-new.ll

>From 242defe2f23f8a00df5cd8ea68e40c3e31b0fdc2 Mon Sep 17 00:00:00 2001
From: Nuri Amari <nuriam...@fb.com>
Date: Mon, 3 Mar 2025 17:00:25 -0800
Subject: [PATCH 2/2] Provide default --cs-profile-path= for distributed
 thin-lto builds

When -fcs-profile-generate is used with a distributed compile without
specifying a profile output path somehow, we fail the following
assertion:

https://github.com/llvm/llvm-project/blob/6041c745f32e8fd60ed24e29e7d919d8d1c87ca6/llvm/lib/Support/PGOOptions.cpp#L36

Avoid the assertion by choosing a default output path as other LTO mechanisms
(ie. local thin-lto) do.
---
 clang/lib/CodeGen/BackendUtil.cpp                  | 2 +-
 clang/test/CodeGen/distributed-thin-lto/cs-irpgo.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/distributed-thin-lto/cs-irpgo.c

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 1750719e17670..2f3985591cdde 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1334,7 +1334,7 @@ runThinLTOBackend(CompilerInstance &CI, 
ModuleSummaryIndex *CombinedIndex,
   // Context sensitive profile.
   if (CGOpts.hasProfileCSIRInstr()) {
     Conf.RunCSIRInstr = true;
-    Conf.CSIRProfile = std::move(CGOpts.InstrProfileOutput);
+    Conf.CSIRProfile = getProfileGenName(CGOpts);
   } else if (CGOpts.hasProfileCSIRUse()) {
     Conf.RunCSIRInstr = false;
     Conf.CSIRProfile = std::move(CGOpts.ProfileInstrumentUsePath);
diff --git a/clang/test/CodeGen/distributed-thin-lto/cs-irpgo.c 
b/clang/test/CodeGen/distributed-thin-lto/cs-irpgo.c
new file mode 100644
index 0000000000000..4d66723c21625
--- /dev/null
+++ b/clang/test/CodeGen/distributed-thin-lto/cs-irpgo.c
@@ -0,0 +1,8 @@
+// RUN: mkdir -p %t
+// RUN: %clang -target x86_64-apple-darwin -fcs-profile-generate -flto=thin -c 
-o %t/main.bc %s
+// RUN: llvm-lto2 run --thinlto-distributed-indexes %t/main.bc -o %t/index 
-r=%t/main.bc,_main,px
+// RUN: %clang -target x86_64-apple-darwin -fcs-profile-generate -c %t/main.o 
-fthinlto-index=%t/main.bc.thinlto.bc %t/main.bc
+
+int main() {
+    return 0;
+}

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to