diff options
author | Xin Tong <trent.xin.tong@gmail.com> | 2018-11-05 15:49:46 +0000 |
---|---|---|
committer | Xin Tong <trent.xin.tong@gmail.com> | 2018-11-05 15:49:46 +0000 |
commit | 7ca744488fa4c8e2b7d0fc88c63840d7f9000f54 (patch) | |
tree | 499e14d7281dab901cc68b12f972d1451fa6ca84 /llvm/lib/LTO/LTO.cpp | |
parent | 6bd468bd8b1faeee33483c494135357c9a297fd8 (diff) | |
download | llvm-7ca744488fa4c8e2b7d0fc88c63840d7f9000f54.zip llvm-7ca744488fa4c8e2b7d0fc88c63840d7f9000f54.tar.gz llvm-7ca744488fa4c8e2b7d0fc88c63840d7f9000f54.tar.bz2 |
[ThinLTO] Add an option to disable (thin)lto internalization.
Summary:
LTO and ThinLTO optimizes the IR differently.
One source of differences is the amount of internalizations that
can happen.
Add an option to enable/disable internalization so that other
differences can be studied in isolation. e.g. inlining.
There are other things lto and thinlto do differently, I will add
flags to enable/disable them as needed.
Reviewers: tejohnson, pcc, steven_wu
Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits
Differential Revision: https://reviews.llvm.org/D53294
llvm-svn: 346140
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 6942cb2..2726b67 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -56,6 +56,11 @@ static cl::opt<bool> 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. @@ -344,7 +349,8 @@ static void thinLTOInternalizeAndPromoteGUID( 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); } } @@ -876,7 +882,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) { 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); } |