summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AsmWriter.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-01-17 15:49:03 +0000
committerTeresa Johnson <tejohnson@google.com>2019-01-17 15:49:03 +0000
commit4fcf3b16212481f7debebb1f35681cff8cdf81ea (patch)
treee783c9fe4ee7c2682b4d6f77a854b3494442c95b /llvm/lib/IR/AsmWriter.cpp
parente50d9cb3649bdf6521f92fd1e4cee3a690638159 (diff)
downloadbcm5719-llvm-4fcf3b16212481f7debebb1f35681cff8cdf81ea.tar.gz
bcm5719-llvm-4fcf3b16212481f7debebb1f35681cff8cdf81ea.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 index-based WPD will be sent as a follow-on. 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: 351453
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index a5dc623e1a3..e431deb86f4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1038,6 +1038,9 @@ void SlotTracker::processIndex() {
TidIter != TheIndex->typeIds().end(); TidIter++)
CreateTypeIdSlot(TidIter->second.first);
+ for (auto &TId : TheIndex->typeIdMetadataMap())
+ CreateGUIDSlot(GlobalValue::getGUID(TId.first));
+
ST_DEBUG("end processIndex!\n");
}
@@ -2393,6 +2396,7 @@ public:
void printGlobalVarSummary(const GlobalVarSummary *GS);
void printFunctionSummary(const FunctionSummary *FS);
void printTypeIdSummary(const TypeIdSummary &TIS);
+ void printTypeIdMetadataSummary(const TypeIdGVInfo &TI);
void printTypeTestResolution(const TypeTestResolution &TTRes);
void printArgs(const std::vector<uint64_t> &Args);
void printWPDRes(const WholeProgramDevirtResolution &WPDRes);
@@ -2695,6 +2699,15 @@ void AssemblyWriter::printModuleSummaryIndex() {
printTypeIdSummary(TidIter->second.second);
Out << ") ; guid = " << TidIter->first << "\n";
}
+
+ // Print the TypeIdMetadataMap entries.
+ for (auto &TId : TheIndex->typeIdMetadataMap()) {
+ auto GUID = GlobalValue::getGUID(TId.first);
+ Out << "^" << Machine.getGUIDSlot(GUID) << " = typeidMetadata: (name: \""
+ << TId.first << "\"";
+ printTypeIdMetadataSummary(TId.second);
+ Out << ") ; guid = " << GUID << "\n";
+ }
}
static const char *
@@ -2777,6 +2790,18 @@ void AssemblyWriter::printTypeIdSummary(const TypeIdSummary &TIS) {
Out << ")";
}
+void AssemblyWriter::printTypeIdMetadataSummary(const TypeIdGVInfo &TI) {
+ Out << ", summary: (";
+ FieldSeparator FS;
+ for (auto &P : TI) {
+ Out << FS;
+ Out << "(offset: " << P.first << ", ";
+ Out << "^" << Machine.getGUIDSlot(P.second.getGUID());
+ Out << ")";
+ }
+ Out << ")";
+}
+
void AssemblyWriter::printArgs(const std::vector<uint64_t> &Args) {
Out << "args: (";
FieldSeparator FS;
@@ -2846,6 +2871,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.first.getGUID())
+ << ", offset: " << P.second;
+ Out << ")";
+ }
+ Out << ")";
+ }
}
static std::string getLinkageName(GlobalValue::LinkageTypes LT) {
OpenPOWER on IntegriCloud