[PATCH] D69173: [clang][ThinLTO][Legacy] Don't add -fsplit-lto-unit for legacy thin LTO builds
Eugene Leviant via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 24 04:18:14 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ae8e8d25fd8: Don't add -fsplit-lto-unit for thin LTO builds with PS4 and Darwin toolchains (authored by evgeny777).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D69173?vs=226049&id=226223#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69173/new/
https://reviews.llvm.org/D69173
Files:
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/PS4CPU.h
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
@@ -3,6 +3,10 @@
// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit 2>&1 | FileCheck --check-prefix=NOUNIT %s
// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-split-lto-unit -fwhole-program-vtables 2>&1 | FileCheck --check-prefix=ERROR1 %s
// 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
// UNIT: "-fsplit-lto-unit"
// NOUNIT-NOT: "-fsplit-lto-unit"
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===================================================================
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -84,6 +84,10 @@
SanitizerMask getSupportedSanitizers() const override;
+ // PS4 toolchain uses legacy thin LTO API, which is not
+ // capable of unit splitting.
+ bool canSplitThinLTOUnit() const override { return false; }
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Darwin.h
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -258,6 +258,9 @@
return "";
}
+ // Darwin toolchain uses legacy thin LTO API, which is not
+ // capable of unit splitting.
+ bool canSplitThinLTOUnit() const override { return false; }
/// }
};
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5395,7 +5395,9 @@
CmdArgs.push_back("-fwhole-program-vtables");
}
- bool DefaultsSplitLTOUnit = WholeProgramVTables || Sanitize.needsLTO();
+ bool DefaultsSplitLTOUnit =
+ (WholeProgramVTables || Sanitize.needsLTO()) &&
+ (D.getLTOMode() == LTOK_Full || TC.canSplitThinLTOUnit());
bool SplitLTOUnit =
Args.hasFlag(options::OPT_fsplit_lto_unit,
options::OPT_fno_split_lto_unit, DefaultsSplitLTOUnit);
Index: clang/include/clang/Driver/ToolChain.h
===================================================================
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -600,6 +600,10 @@
virtual SanitizerMask getDefaultSanitizers() const {
return SanitizerMask();
}
+
+ /// Returns true when it's possible to split LTO unit to use whole
+ /// program devirtualization and CFI santiizers.
+ virtual bool canSplitThinLTOUnit() const { return true; }
};
/// Set a ToolChain's effective triple. Reset it when the registration object
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69173.226223.patch
Type: text/x-patch
Size: 3373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191024/92c9d150/attachment.bin>
More information about the cfe-commits
mailing list