diff options
author | Teresa Johnson <tejohnson@google.com> | 2019-08-02 13:10:52 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2019-08-02 13:10:52 +0000 |
commit | d2df54e6a55af509b08afa109fe522cd88ad1c33 (patch) | |
tree | 4d339b3b6a25b26612d1c76e97da2ae43ba44227 /llvm/lib/LTO/LTO.cpp | |
parent | 4cfd015bebb6966227964070c6bea738eaf897ae (diff) | |
download | bcm5719-llvm-d2df54e6a55af509b08afa109fe522cd88ad1c33.tar.gz bcm5719-llvm-d2df54e6a55af509b08afa109fe522cd88ad1c33.zip |
[ThinLTO] Implement index-based WPD
This patch adds support to the WholeProgramDevirt pass to perform
index-based WPD, which is invoked from ThinLTO during the thin link.
The ThinLTO backend (WPD import phase) behaves the same regardless of
whether the WPD decisions were made with the index-based or (the
existing) IR-based analysis.
Depends on D54815.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, dang, llvm-commits
Differential Revision: https://reviews.llvm.org/D55153
llvm-svn: 367679
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 64506890956..8d44ba2029e 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -44,6 +44,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/Transforms/IPO/WholeProgramDevirt.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/SplitModule.h" @@ -1274,15 +1275,28 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache, if (DumpThinCGSCCs) ThinLTO.CombinedIndex.dumpSCCs(outs()); + std::set<GlobalValue::GUID> ExportedGUIDs; + + // Perform index-based WPD. This will return immediately if there are + // no index entries in the typeIdMetadata map (e.g. if we are instead + // performing IR-based WPD in hybrid regular/thin LTO mode). + std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap; + runWholeProgramDevirtOnIndex(ThinLTO.CombinedIndex, ExportedGUIDs, + LocalWPDTargetsMap); + if (Conf.OptLevel > 0) ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries, ImportLists, ExportLists); + // Update local devirtualized targets that were exported by cross-module + // importing + updateIndexWPDForExports(ThinLTO.CombinedIndex, ExportLists, + LocalWPDTargetsMap); + // Figure out which symbols need to be internalized. This also needs to happen // at -O0 because summary-based DCE is implemented using internalization, and // we must apply DCE consistently with the full LTO module in order to avoid // undefined references during the final link. - std::set<GlobalValue::GUID> ExportedGUIDs; for (auto &Res : GlobalResolutions) { // If the symbol does not have external references or it is not prevailing, // then not need to mark it as exported from a ThinLTO partition. |