Author: Matthew Voss
Date: 2023-07-12T15:32:40-07:00
New Revision: 5007c78ce0936824972ec6ba3cfa598192087ee1

URL: 
https://github.com/llvm/llvm-project/commit/5007c78ce0936824972ec6ba3cfa598192087ee1
DIFF: 
https://github.com/llvm/llvm-project/commit/5007c78ce0936824972ec6ba3cfa598192087ee1.diff

LOG: [PS4][clang] Fix -funified-lto/-flto-unit default on PS4

If -funified-lto was specified but -flto was not, we would end up with a
situation where the driver thought that Unified LTO was enabled, but the
flag was not passed to the frontend. The check disabling -flto-unit for
PS4 should use the correct method to check for the target. This only
effects PS targets.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/lto-unit.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7abd03ab87be8d..ce0e3aa2b3d325 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4776,10 +4776,10 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 
-  bool UnifiedLTO =  Triple.isPS();;
+  bool UnifiedLTO = false;
   if (IsUsingLTO) {
     UnifiedLTO = Args.hasFlag(options::OPT_funified_lto,
-                              options::OPT_fno_unified_lto, false);
+                              options::OPT_fno_unified_lto, Triple.isPS());
     if (UnifiedLTO)
       CmdArgs.push_back("-funified-lto");
   }
@@ -4930,7 +4930,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
             Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
         // PS4 uses the legacy LTO API, which does not support some of the
         // features enabled by -flto-unit.
-        if ((RawTriple.getOS() != llvm::Triple::PS4) ||
+        if (!RawTriple.isPS4() ||
             (D.getLTOMode() == LTOK_Full) || !UnifiedLTO)
           CmdArgs.push_back("-flto-unit");
       }

diff  --git a/clang/test/Driver/lto-unit.c b/clang/test/Driver/lto-unit.c
index 14eadaf8ad4d26..b2edb5eab079e8 100644
--- a/clang/test/Driver/lto-unit.c
+++ b/clang/test/Driver/lto-unit.c
@@ -2,8 +2,8 @@
 // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang --target=x86_64-apple-darwin13.3.0 -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // 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 -fno-unified-lto 
2>&1 | FileCheck --check-prefix=UNIT %s
+// RUN: %clang --target=x86_64-scei-ps4 -### %s -flto=thin -fno-unified-lto 
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


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

Reply via email to