IR: Function summary extensions for whole-program devirtualization pass.
The summary information includes all uses of llvm.type.test and llvm.type.checked.load intrinsics that can be used to devirtualize calls, including any constant arguments for virtual constant propagation. Differential Revision: https://reviews.llvm.org/D29734 llvm-svn: 294795
This commit is contained in:
@@ -4848,6 +4848,10 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(
|
||||
GlobalValueSummary *LastSeenSummary = nullptr;
|
||||
bool Combined = false;
|
||||
std::vector<GlobalValue::GUID> PendingTypeTests;
|
||||
std::vector<FunctionSummary::VFuncId> PendingTypeTestAssumeVCalls,
|
||||
PendingTypeCheckedLoadVCalls;
|
||||
std::vector<FunctionSummary::ConstVCall> PendingTypeTestAssumeConstVCalls,
|
||||
PendingTypeCheckedLoadConstVCalls;
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
@@ -4914,8 +4918,15 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(
|
||||
IsOldProfileFormat, HasProfile);
|
||||
auto FS = llvm::make_unique<FunctionSummary>(
|
||||
Flags, InstCount, std::move(Refs), std::move(Calls),
|
||||
std::move(PendingTypeTests));
|
||||
std::move(PendingTypeTests), std::move(PendingTypeTestAssumeVCalls),
|
||||
std::move(PendingTypeCheckedLoadVCalls),
|
||||
std::move(PendingTypeTestAssumeConstVCalls),
|
||||
std::move(PendingTypeCheckedLoadConstVCalls));
|
||||
PendingTypeTests.clear();
|
||||
PendingTypeTestAssumeVCalls.clear();
|
||||
PendingTypeCheckedLoadVCalls.clear();
|
||||
PendingTypeTestAssumeConstVCalls.clear();
|
||||
PendingTypeCheckedLoadConstVCalls.clear();
|
||||
auto GUID = getGUIDFromValueId(ValueID);
|
||||
FS->setModulePath(TheIndex.addModulePath(ModulePath, 0)->first());
|
||||
FS->setOriginalName(GUID.second);
|
||||
@@ -4989,8 +5000,15 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(
|
||||
GlobalValue::GUID GUID = getGUIDFromValueId(ValueID).first;
|
||||
auto FS = llvm::make_unique<FunctionSummary>(
|
||||
Flags, InstCount, std::move(Refs), std::move(Edges),
|
||||
std::move(PendingTypeTests));
|
||||
std::move(PendingTypeTests), std::move(PendingTypeTestAssumeVCalls),
|
||||
std::move(PendingTypeCheckedLoadVCalls),
|
||||
std::move(PendingTypeTestAssumeConstVCalls),
|
||||
std::move(PendingTypeCheckedLoadConstVCalls));
|
||||
PendingTypeTests.clear();
|
||||
PendingTypeTestAssumeVCalls.clear();
|
||||
PendingTypeCheckedLoadVCalls.clear();
|
||||
PendingTypeTestAssumeConstVCalls.clear();
|
||||
PendingTypeCheckedLoadConstVCalls.clear();
|
||||
LastSeenSummary = FS.get();
|
||||
FS->setModulePath(ModuleIdMap[ModuleId]);
|
||||
TheIndex.addGlobalValueSummary(GUID, std::move(FS));
|
||||
@@ -5054,6 +5072,28 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(
|
||||
Record.end());
|
||||
break;
|
||||
}
|
||||
case bitc::FS_TYPE_TEST_ASSUME_VCALLS: {
|
||||
assert(PendingTypeTestAssumeVCalls.empty());
|
||||
for (unsigned I = 0; I != Record.size(); I += 2)
|
||||
PendingTypeTestAssumeVCalls.push_back({Record[I], Record[I+1]});
|
||||
break;
|
||||
}
|
||||
case bitc::FS_TYPE_CHECKED_LOAD_VCALLS: {
|
||||
assert(PendingTypeCheckedLoadVCalls.empty());
|
||||
for (unsigned I = 0; I != Record.size(); I += 2)
|
||||
PendingTypeCheckedLoadVCalls.push_back({Record[I], Record[I+1]});
|
||||
break;
|
||||
}
|
||||
case bitc::FS_TYPE_TEST_ASSUME_CONST_VCALL: {
|
||||
PendingTypeTestAssumeConstVCalls.push_back(
|
||||
{{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
|
||||
break;
|
||||
}
|
||||
case bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL: {
|
||||
PendingTypeCheckedLoadConstVCalls.push_back(
|
||||
{{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
llvm_unreachable("Exit infinite loop");
|
||||
|
||||
Reference in New Issue
Block a user