[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 13:23:26 PDT 2018
trentxintong updated this revision to Diff 169746.
trentxintong added a comment.
Address @tejohnson suggesions. Thanks!
Repository:
rL LLVM
https://reviews.llvm.org/D53294
Files:
include/llvm/LTO/legacy/LTOCodeGenerator.h
lib/LTO/LTO.cpp
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);
}
Index: include/llvm/LTO/legacy/LTOCodeGenerator.h
===================================================================
--- include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -48,6 +48,9 @@
#include <string>
#include <vector>
+/// Enable global value internalization in LTO.
+extern llvm::cl::opt<bool> EnableLTOInternalization;
+
namespace llvm {
template <typename T> class ArrayRef;
class LLVMContext;
@@ -233,7 +236,7 @@
unsigned OptLevel = 2;
lto_diagnostic_handler_t DiagHandler = nullptr;
void *DiagContext = nullptr;
- bool ShouldInternalize = true;
+ bool ShouldInternalize = EnableLTOInternalization;
bool ShouldEmbedUselists = false;
bool ShouldRestoreGlobalsLinkage = false;
TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53294.169746.patch
Type: text/x-patch
Size: 2277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181015/8c6781f2/attachment.bin>
More information about the llvm-commits
mailing list