[PATCH] D53294: [ThinLTO] Add an option to disable (thin)lto internalization.
Xin Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 15 12:37:10 PDT 2018
trentxintong updated this revision to Diff 169740.
trentxintong added a comment.
Address @tejohnson suggestions. Thanks!
Repository:
rL LLVM
https://reviews.llvm.org/D53294
Files:
lib/LTO/LTO.cpp
lib/LTO/LTOCodeGenerator.cpp
Index: lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -70,6 +70,9 @@
#endif
}
+/// Enable global value internalization in LTO.
+extern cl::opt<bool> EnableLTOInternalization;
+
namespace llvm {
cl::opt<bool> LTODiscardValueNames(
"lto-discard-value-names",
@@ -419,7 +422,7 @@
// Preserve linkonce value on linker request
preserveDiscardableGVs(*MergedModule, mustPreserveGV);
- if (!ShouldInternalize)
+ if (!EnableLTOInternalization || !ShouldInternalize)
return;
if (ShouldRestoreGlobalsLinkage) {
@@ -450,7 +453,8 @@
/// Restore original linkage for symbols that may have been internalized
void LTOCodeGenerator::restoreLinkageForExternals() {
- if (!ShouldInternalize || !ShouldRestoreGlobalsLinkage)
+ if (!EnableLTOInternalization || !ShouldInternalize ||
+ !ShouldRestoreGlobalsLinkage)
return;
assert(ScopeRestrictionsDone &&
Index: lib/LTO/LTO.cpp
===================================================================
--- lib/LTO/LTO.cpp
+++ lib/LTO/LTO.cpp
@@ -56,6 +56,11 @@
DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden,
cl::desc("Dump the SCCs in the ThinLTO index's callgraph"));
+/// Enable global value internalization in LTO.
+cl::opt<bool> EnableLTOInternalization(
+ "enable-lto-internalization", cl::init(true), cl::Hidden,
+ cl::desc("Enable global value internalization in LTO"));
+
// Returns a unique hash for the Module considering the current list of
// export/import and other global analysis results.
// The hash is produced in \p Key.
@@ -337,7 +342,8 @@
if (isExported(S->modulePath(), GUID)) {
if (GlobalValue::isLocalLinkage(S->linkage()))
S->setLinkage(GlobalValue::ExternalLinkage);
- } else if (!GlobalValue::isLocalLinkage(S->linkage()))
+ } else if (EnableLTOInternalization &&
+ !GlobalValue::isLocalLinkage(S->linkage()))
S->setLinkage(GlobalValue::InternalLinkage);
}
}
@@ -869,7 +875,7 @@
continue;
GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global
: GlobalValue::UnnamedAddr::None);
- if (R.second.Partition == 0)
+ if (EnableLTOInternalization && R.second.Partition == 0)
GV->setLinkage(GlobalValue::InternalLinkage);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53294.169740.patch
Type: text/x-patch
Size: 2453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181015/20f54103/attachment.bin>
More information about the llvm-commits
mailing list