diff options
| author | Teresa Johnson <tejohnson@google.com> | 2019-07-02 19:38:02 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2019-07-02 19:38:02 +0000 |
| commit | a70043632335f697b0cbbb12d5ef0c5fe0fb999a (patch) | |
| tree | 42c34b71aa595f9badd188a77e73160e7f59377d /llvm/lib/IR | |
| parent | 5fe851b6cd90ceaa4cf468d9403b3920e1d0ae15 (diff) | |
| download | bcm5719-llvm-a70043632335f697b0cbbb12d5ef0c5fe0fb999a.tar.gz bcm5719-llvm-a70043632335f697b0cbbb12d5ef0c5fe0fb999a.zip | |
[ThinLTO] Add summary entries for index-based WPD
Summary:
If LTOUnit splitting is disabled, the module summary analysis computes
the summary information necessary to perform single implementation
devirtualization during the thin link with the index and no IR. The
information collected from the regular LTO IR in the current hybrid WPD
algorithm is summarized, including:
1) For vtable definitions, record the function pointers and their offset
within the vtable initializer (subsumes the information collected from
IR by tryFindVirtualCallTargets).
2) A record for each type metadata summarizing the vtable definitions
decorated with that metadata (subsumes the TypeIdentiferMap collected
from IR).
Also added are the necessary bitcode records, and the corresponding
assembly support.
The follow-on index-based WPD patch is D55153.
Depends on D53890.
Reviewers: pcc
Subscribers: mehdi_amini, Prazek, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D54815
llvm-svn: 364960
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index ca7afd0d81a..67344f4a620 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1037,6 +1037,9 @@ void SlotTracker::processIndex() { TidIter != TheIndex->typeIds().end(); TidIter++) CreateTypeIdSlot(TidIter->second.first); + for (auto &TId : TheIndex->typeIdCompatibleVtableMap()) + CreateGUIDSlot(GlobalValue::getGUID(TId.first)); + ST_DEBUG("end processIndex!\n"); } @@ -2410,6 +2413,7 @@ public: void printGlobalVarSummary(const GlobalVarSummary *GS); void printFunctionSummary(const FunctionSummary *FS); void printTypeIdSummary(const TypeIdSummary &TIS); + void printTypeIdCompatibleVtableSummary(const TypeIdCompatibleVtableInfo &TI); void printTypeTestResolution(const TypeTestResolution &TTRes); void printArgs(const std::vector<uint64_t> &Args); void printWPDRes(const WholeProgramDevirtResolution &WPDRes); @@ -2712,6 +2716,15 @@ void AssemblyWriter::printModuleSummaryIndex() { printTypeIdSummary(TidIter->second.second); Out << ") ; guid = " << TidIter->first << "\n"; } + + // Print the TypeIdCompatibleVtableMap entries. + for (auto &TId : TheIndex->typeIdCompatibleVtableMap()) { + auto GUID = GlobalValue::getGUID(TId.first); + Out << "^" << Machine.getGUIDSlot(GUID) + << " = typeidCompatibleVTable: (name: \"" << TId.first << "\""; + printTypeIdCompatibleVtableSummary(TId.second); + Out << ") ; guid = " << GUID << "\n"; + } } static const char * @@ -2794,6 +2807,19 @@ void AssemblyWriter::printTypeIdSummary(const TypeIdSummary &TIS) { Out << ")"; } +void AssemblyWriter::printTypeIdCompatibleVtableSummary( + const TypeIdCompatibleVtableInfo &TI) { + Out << ", summary: ("; + FieldSeparator FS; + for (auto &P : TI) { + Out << FS; + Out << "(offset: " << P.AddressPointOffset << ", "; + Out << "^" << Machine.getGUIDSlot(P.VTableVI.getGUID()); + Out << ")"; + } + Out << ")"; +} + void AssemblyWriter::printArgs(const std::vector<uint64_t> &Args) { Out << "args: ("; FieldSeparator FS; @@ -2863,6 +2889,19 @@ void AssemblyWriter::printAliasSummary(const AliasSummary *AS) { void AssemblyWriter::printGlobalVarSummary(const GlobalVarSummary *GS) { Out << ", varFlags: (readonly: " << GS->VarFlags.ReadOnly << ")"; + + auto VTableFuncs = GS->vTableFuncs(); + if (!VTableFuncs.empty()) { + Out << ", vTableFuncs: ("; + FieldSeparator FS; + for (auto &P : VTableFuncs) { + Out << FS; + Out << "(virtFunc: ^" << Machine.getGUIDSlot(P.FuncVI.getGUID()) + << ", offset: " << P.VTableOffset; + Out << ")"; + } + Out << ")"; + } } static std::string getLinkageName(GlobalValue::LinkageTypes LT) { |

