[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 10:01:27 PDT 2018


trentxintong created this revision.
trentxintong added reviewers: tejohnson, pcc.
Herald added subscribers: dang, dexonsmith, steven_wu, inglorion, mehdi_amini.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D53294

Files:
  lib/LTO/LTO.cpp


Index: lib/LTO/LTO.cpp
===================================================================
--- lib/LTO/LTO.cpp
+++ lib/LTO/LTO.cpp
@@ -55,6 +55,9 @@
 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"));
+static 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.
@@ -337,7 +340,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 +873,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.169719.patch
Type: text/x-patch
Size: 1388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181015/c3c91469/attachment.bin>


More information about the llvm-commits mailing list