[clang] 392b306 - [clang][PS4] Enable SplitLTOUnits and Unified LTO by default

Matthew Voss via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 16:25:17 PDT 2023


Author: Matthew Voss
Date: 2023-07-11T16:25:07-07:00
New Revision: 392b3068075279c7e321583c4d426edf15c935ca

URL: https://github.com/llvm/llvm-project/commit/392b3068075279c7e321583c4d426edf15c935ca
DIFF: https://github.com/llvm/llvm-project/commit/392b3068075279c7e321583c4d426edf15c935ca.diff

LOG: [clang][PS4] Enable SplitLTOUnits and Unified LTO by default

  - Unified LTO default for all PlayStation targets
  - Add default case to tests
  - SplitLTOUnit not default for PS4
  - Remove ignorelist requirement to address buildbot failures

Differential Revision: https://reviews.llvm.org/D123971

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/CodeGen/split-lto-unit.c
    clang/test/CodeGenCXX/unified-cfi-lto.cpp
    clang/test/Driver/lto-unit.c
    clang/test/Driver/split-lto-unit.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 890b99d916f116..796c60f0739285 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4776,7 +4776,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 
-  bool UnifiedLTO = false;
+  bool UnifiedLTO =  Triple.isPS();;
   if (IsUsingLTO) {
     UnifiedLTO = Args.hasFlag(options::OPT_funified_lto,
                               options::OPT_fno_unified_lto, false);
@@ -7343,7 +7343,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   bool DefaultsSplitLTOUnit =
       (WholeProgramVTables || SanitizeArgs.needsLTO()) &&
-      (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit());
+          (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit()) ||
+      (!Triple.isPS4() && UnifiedLTO);
   bool SplitLTOUnit =
       Args.hasFlag(options::OPT_fsplit_lto_unit,
                    options::OPT_fno_split_lto_unit, DefaultsSplitLTOUnit);

diff  --git a/clang/test/CodeGen/split-lto-unit.c b/clang/test/CodeGen/split-lto-unit.c
index b1560b61f3e30b..aaa3511d183bcf 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/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
+// RUN: %clang_cc1 -flto=thin -funified-lto -fsplit-lto-unit -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) {}

diff  --git a/clang/test/CodeGenCXX/unified-cfi-lto.cpp b/clang/test/CodeGenCXX/unified-cfi-lto.cpp
index cc3f594533ae1b..2c518e8e014c44 100644
--- a/clang/test/CodeGenCXX/unified-cfi-lto.cpp
+++ b/clang/test/CodeGenCXX/unified-cfi-lto.cpp
@@ -1,6 +1,6 @@
 // Ensure that the frontend adds the proper metadata when CFI is
 // enabled.
-// RUN: %clang --target=x86_64-scei-ps4 -funified-lto -flto -fsanitize=cfi -fvisibility=hidden -c %s -o %t.o
+// RUN: %clang --target=x86_64-scei-ps4 -funified-lto -flto -fsanitize=cfi -fvisibility=hidden -fno-sanitize-ignorelist -c %s -o %t.o
 // RUN: llvm-dis %t.o -o %t1
 // RUN: FileCheck <%t1.0 %s
 

diff  --git a/clang/test/Driver/lto-unit.c b/clang/test/Driver/lto-unit.c
index 43a9c24088ed11..14eadaf8ad4d26 100644
--- a/clang/test/Driver/lto-unit.c
+++ b/clang/test/Driver/lto-unit.c
@@ -4,5 +4,10 @@
 // RUN: %clang --target=x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | FileCheck --check-prefix=UNIT %s
 // RUN: %clang --target=x86_64-scei-ps4 -### %s -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
 // RUN: %clang --target=x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang --target=x86_64-scei-ps4 -### %s -flto=full -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang --target=x86_64-scei-ps4 -### %s -flto=thin -funified-lto 2>&1 | FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang --target=x86_64-unknown-linux -### %s -flto=full -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -funified-lto 2>&1 | FileCheck --check-prefix=UNIT %s
 
 // UNIT: "-flto-unit"
+// NOUNIT-NOT: "-flto-unit"

diff  --git a/clang/test/Driver/split-lto-unit.c b/clang/test/Driver/split-lto-unit.c
index 4f0a4ccf49032b..769ea4aa09c053 100644
--- a/clang/test/Driver/split-lto-unit.c
+++ b/clang/test/Driver/split-lto-unit.c
@@ -7,6 +7,10 @@
 // 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-sie-ps5 -### %s -fwhole-program-vtables -flto=full 2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang --target=x86_64-sie-ps5 -### %s -fwhole-program-vtables -flto=thin 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"


        


More information about the cfe-commits mailing list