[PATCH] D123971: [clang][PS4] Enable SplitLTOUnits by default
Matthew Voss via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 16:16:21 PDT 2023
ormris updated this revision to Diff 523213.
ormris retitled this revision from "[clang] Enable SplitLTOUnits by default for SIE targets" to "[clang][PS4] Enable SplitLTOUnits by default".
ormris edited the summary of this revision.
ormris added a comment.
Herald added subscribers: steven_wu, hiraditya.
Changelog:
- Rebased
- Add tests
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123971/new/
https://reviews.llvm.org/D123971
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/split-lto-unit.c
clang/test/Driver/split-lto-unit.c
Index: clang/test/Driver/split-lto-unit.c
===================================================================
--- clang/test/Driver/split-lto-unit.c
+++ clang/test/Driver/split-lto-unit.c
@@ -5,8 +5,10 @@
// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit -fsanitize=cfi 2>&1 | FileCheck --check-prefix=ERROR2 %s
// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -fwhole-program-vtables -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -fwhole-program-vtables -flto=thin 2>&1 | FileCheck --check-prefix=NOUNIT %s
-// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
-// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=thin 2>&1 | FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=full -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -fwhole-program-vtables -flto=thin -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -fwhole-program-vtables -flto=full -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -fwhole-program-vtables -flto=thin -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
// UNIT: "-fsplit-lto-unit"
// NOUNIT-NOT: "-fsplit-lto-unit"
Index: clang/test/CodeGen/split-lto-unit.c
===================================================================
--- clang/test/CodeGen/split-lto-unit.c
+++ clang/test/CodeGen/split-lto-unit.c
@@ -1,6 +1,7 @@
// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -flto=thin -funified-lto -triple=x86_64-scei-ps4 -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
//
// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
@@ -12,4 +13,9 @@
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// ; Check that regular LTO has EnableSplitLTOUnit = 1, if using distinct pipelines. For unified pipelines, use EnableSplitLTOUnit = 0.
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// RUN: %clang_cc1 -flto -funified-lto -triple x86_64-scei-ps4 -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit"
+// RUN: %clang_cc1 -flto=thin -funified-lto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+
int main(void) {}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1782,6 +1782,13 @@
Opts.PrepareForLTO = false;
}
+ if (Opts.UnifiedLTO) {
+ if (T.getOS() == llvm::Triple::PS4)
+ Opts.EnableSplitLTOUnit = false;
+ else
+ Opts.EnableSplitLTOUnit = true;
+ }
+
if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
if (IK.getLanguage() != Language::LLVM_IR)
Diags.Report(diag::err_drv_argument_only_allowed_with)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4683,9 +4683,11 @@
// Select the appropriate action.
RewriteKind rewriteKind = RK_None;
+ bool DefaultUnified = Triple.isPS4();
bool UnifiedLTO =
Args.hasFlag(options::OPT_funified_lto,
- options::OPT_fno_unified_lto, false);
+ options::OPT_fno_unified_lto,
+ DefaultUnified);
if (UnifiedLTO)
CmdArgs.push_back("-funified-lto");
@@ -7243,7 +7245,8 @@
bool DefaultsSplitLTOUnit =
(WholeProgramVTables || SanitizeArgs.needsLTO()) &&
- (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit());
+ (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit()) ||
+ UnifiedLTO;
bool SplitLTOUnit =
Args.hasFlag(options::OPT_fsplit_lto_unit,
options::OPT_fno_split_lto_unit, DefaultsSplitLTOUnit);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123971.523213.patch
Type: text/x-patch
Size: 4803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230517/2bde2e3b/attachment.bin>
More information about the llvm-commits
mailing list