Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Show First 20 Lines • Show All 6,193 Lines • ▼ Show 20 Lines | while (true) { | ||||
// numrefs x valueid, n x (valueid)] | // numrefs x valueid, n x (valueid)] | ||||
// FS_PERMODULE_PROFILE: [valueid, flags, instcount, fflags, numrefs, | // FS_PERMODULE_PROFILE: [valueid, flags, instcount, fflags, numrefs, | ||||
// numrefs x valueid, | // numrefs x valueid, | ||||
// n x (valueid, hotness)] | // n x (valueid, hotness)] | ||||
// FS_PERMODULE_RELBF: [valueid, flags, instcount, fflags, numrefs, | // FS_PERMODULE_RELBF: [valueid, flags, instcount, fflags, numrefs, | ||||
// numrefs x valueid, | // numrefs x valueid, | ||||
// n x (valueid, relblockfreq)] | // n x (valueid, relblockfreq)] | ||||
case bitc::FS_PERMODULE: | case bitc::FS_PERMODULE: | ||||
dbgs() << "Mingming FS_PERMODULE\n"; | |||||
[[clang::fallthrough]]; | |||||
case bitc::FS_PERMODULE_RELBF: | case bitc::FS_PERMODULE_RELBF: | ||||
dbgs() << "Mingming FS_PERMODULE_RELBF\n"; | |||||
[[clang::fallthrough]]; | |||||
case bitc::FS_PERMODULE_PROFILE: { | case bitc::FS_PERMODULE_PROFILE: { | ||||
dbgs() << "Mingming FS_PERMODULE_PROFILE\n"; | |||||
unsigned ValueID = Record[0]; | unsigned ValueID = Record[0]; | ||||
uint64_t RawFlags = Record[1]; | uint64_t RawFlags = Record[1]; | ||||
unsigned InstCount = Record[2]; | unsigned InstCount = Record[2]; | ||||
uint64_t RawFunFlags = 0; | uint64_t RawFunFlags = 0; | ||||
unsigned NumRefs = Record[3]; | unsigned NumRefs = Record[3]; | ||||
unsigned NumRORefs = 0, NumWORefs = 0; | unsigned NumRORefs = 0, NumWORefs = 0; | ||||
bool isUnreachableFunc = false; | |||||
int RefListStartIndex = 4; | int RefListStartIndex = 4; | ||||
if (Version >= 4) { | if (Version >= 4) { | ||||
RawFunFlags = Record[3]; | RawFunFlags = Record[3]; | ||||
NumRefs = Record[4]; | NumRefs = Record[4]; | ||||
RefListStartIndex = 5; | RefListStartIndex = 5; | ||||
if (Version >= 5) { | if (Version >= 5) { | ||||
NumRORefs = Record[5]; | NumRORefs = Record[5]; | ||||
RefListStartIndex = 6; | RefListStartIndex = 6; | ||||
if (Version >= 7) { | if (Version >= 7) { | ||||
NumWORefs = Record[6]; | NumWORefs = Record[6]; | ||||
RefListStartIndex = 7; | isUnreachableFunc = (Record[7] == 1) ? true : false; | ||||
RefListStartIndex = 8; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | ||||
// The module path string ref set in the summary must be owned by the | // The module path string ref set in the summary must be owned by the | ||||
// index's module string table. Since we don't have a module path | // index's module string table. Since we don't have a module path | ||||
// string table section in the per-module index, we create a single | // string table section in the per-module index, we create a single | ||||
Show All 12 Lines | case bitc::FS_PERMODULE_PROFILE: { | ||||
setSpecialRefs(Refs, NumRORefs, NumWORefs); | setSpecialRefs(Refs, NumRORefs, NumWORefs); | ||||
auto FS = std::make_unique<FunctionSummary>( | auto FS = std::make_unique<FunctionSummary>( | ||||
Flags, InstCount, getDecodedFFlags(RawFunFlags), /*EntryCount=*/0, | Flags, InstCount, getDecodedFFlags(RawFunFlags), /*EntryCount=*/0, | ||||
std::move(Refs), std::move(Calls), std::move(PendingTypeTests), | std::move(Refs), std::move(Calls), std::move(PendingTypeTests), | ||||
std::move(PendingTypeTestAssumeVCalls), | std::move(PendingTypeTestAssumeVCalls), | ||||
std::move(PendingTypeCheckedLoadVCalls), | std::move(PendingTypeCheckedLoadVCalls), | ||||
std::move(PendingTypeTestAssumeConstVCalls), | std::move(PendingTypeTestAssumeConstVCalls), | ||||
std::move(PendingTypeCheckedLoadConstVCalls), | std::move(PendingTypeCheckedLoadConstVCalls), | ||||
std::move(PendingParamAccesses)); | std::move(PendingParamAccesses), isUnreachableFunc); | ||||
auto VIAndOriginalGUID = getValueInfoFromValueId(ValueID); | auto VIAndOriginalGUID = getValueInfoFromValueId(ValueID); | ||||
FS->setModulePath(getThisModule()->first()); | FS->setModulePath(getThisModule()->first()); | ||||
FS->setOriginalName(VIAndOriginalGUID.second); | FS->setOriginalName(VIAndOriginalGUID.second); | ||||
TheIndex.addGlobalValueSummary(VIAndOriginalGUID.first, std::move(FS)); | TheIndex.addGlobalValueSummary(VIAndOriginalGUID.first, std::move(FS)); | ||||
break; | break; | ||||
} | } | ||||
// FS_ALIAS: [valueid, flags, valueid] | // FS_ALIAS: [valueid, flags, valueid] | ||||
// Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as | // Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | case bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS: { | ||||
FS->setOriginalName(GUID.second); | FS->setOriginalName(GUID.second); | ||||
TheIndex.addGlobalValueSummary(GUID.first, std::move(FS)); | TheIndex.addGlobalValueSummary(GUID.first, std::move(FS)); | ||||
break; | break; | ||||
} | } | ||||
// FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: [valueid, flags, varflags, | // FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: [valueid, flags, varflags, | ||||
// numrefs, numrefs x valueid, | // numrefs, numrefs x valueid, | ||||
// n x (valueid, offset)] | // n x (valueid, offset)] | ||||
case bitc::FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: { | case bitc::FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: { | ||||
dbgs() << "Mingming FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS" | |||||
<< "\n"; | |||||
unsigned ValueID = Record[0]; | unsigned ValueID = Record[0]; | ||||
uint64_t RawFlags = Record[1]; | uint64_t RawFlags = Record[1]; | ||||
GlobalVarSummary::GVarFlags GVF = getDecodedGVarFlags(Record[2]); | GlobalVarSummary::GVarFlags GVF = getDecodedGVarFlags(Record[2]); | ||||
unsigned NumRefs = Record[3]; | unsigned NumRefs = Record[3]; | ||||
unsigned RefListStartIndex = 4; | unsigned RefListStartIndex = 4; | ||||
unsigned VTableListStartIndex = RefListStartIndex + NumRefs; | unsigned VTableListStartIndex = RefListStartIndex + NumRefs; | ||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | ||||
std::vector<ValueInfo> Refs = makeRefList( | std::vector<ValueInfo> Refs = makeRefList( | ||||
Show All 23 Lines | case bitc::FS_COMBINED_PROFILE: { | ||||
uint64_t ModuleId = Record[1]; | uint64_t ModuleId = Record[1]; | ||||
uint64_t RawFlags = Record[2]; | uint64_t RawFlags = Record[2]; | ||||
unsigned InstCount = Record[3]; | unsigned InstCount = Record[3]; | ||||
uint64_t RawFunFlags = 0; | uint64_t RawFunFlags = 0; | ||||
uint64_t EntryCount = 0; | uint64_t EntryCount = 0; | ||||
unsigned NumRefs = Record[4]; | unsigned NumRefs = Record[4]; | ||||
unsigned NumRORefs = 0, NumWORefs = 0; | unsigned NumRORefs = 0, NumWORefs = 0; | ||||
int RefListStartIndex = 5; | int RefListStartIndex = 5; | ||||
bool isUnreachableFunction = false; | |||||
dbgs() << "Mingming Version is " << Version << "\n"; | |||||
if (Version >= 4) { | if (Version >= 4) { | ||||
RawFunFlags = Record[4]; | RawFunFlags = Record[4]; | ||||
RefListStartIndex = 6; | RefListStartIndex = 6; | ||||
size_t NumRefsIndex = 5; | size_t NumRefsIndex = 5; | ||||
if (Version >= 5) { | if (Version >= 5) { | ||||
unsigned NumRORefsOffset = 1; | unsigned NumRORefsOffset = 1; | ||||
RefListStartIndex = 7; | RefListStartIndex = 7; | ||||
if (Version >= 6) { | if (Version >= 6) { | ||||
NumRefsIndex = 6; | NumRefsIndex = 6; | ||||
EntryCount = Record[5]; | EntryCount = Record[5]; | ||||
RefListStartIndex = 8; | RefListStartIndex = 8; | ||||
if (Version >= 7) { | if (Version >= 7) { | ||||
RefListStartIndex = 9; | RefListStartIndex = 10; | ||||
NumWORefs = Record[8]; | NumWORefs = Record[8]; | ||||
NumRORefsOffset = 2; | isUnreachableFunction = (Record[9] == 1) ? true : false; | ||||
NumRORefsOffset = 3; | |||||
} | } | ||||
} | } | ||||
NumRORefs = Record[RefListStartIndex - NumRORefsOffset]; | NumRORefs = Record[RefListStartIndex - NumRORefsOffset]; | ||||
} | } | ||||
NumRefs = Record[NumRefsIndex]; | NumRefs = Record[NumRefsIndex]; | ||||
} | } | ||||
dbgs() << "Mingming func is unreachable function " | |||||
<< isUnreachableFunction << "\n"; | |||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | auto Flags = getDecodedGVSummaryFlags(RawFlags, Version); | ||||
int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs; | int CallGraphEdgeStartIndex = RefListStartIndex + NumRefs; | ||||
assert(Record.size() >= RefListStartIndex + NumRefs && | assert(Record.size() >= RefListStartIndex + NumRefs && | ||||
"Record size inconsistent with number of references"); | "Record size inconsistent with number of references"); | ||||
std::vector<ValueInfo> Refs = makeRefList( | std::vector<ValueInfo> Refs = makeRefList( | ||||
ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs)); | ArrayRef<uint64_t>(Record).slice(RefListStartIndex, NumRefs)); | ||||
bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE); | bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE); | ||||
std::vector<FunctionSummary::EdgeTy> Edges = makeCallList( | std::vector<FunctionSummary::EdgeTy> Edges = makeCallList( | ||||
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex), | ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex), | ||||
IsOldProfileFormat, HasProfile, false); | IsOldProfileFormat, HasProfile, false); | ||||
ValueInfo VI = getValueInfoFromValueId(ValueID).first; | ValueInfo VI = getValueInfoFromValueId(ValueID).first; | ||||
setSpecialRefs(Refs, NumRORefs, NumWORefs); | setSpecialRefs(Refs, NumRORefs, NumWORefs); | ||||
auto FS = std::make_unique<FunctionSummary>( | auto FS = std::make_unique<FunctionSummary>( | ||||
Flags, InstCount, getDecodedFFlags(RawFunFlags), EntryCount, | Flags, InstCount, getDecodedFFlags(RawFunFlags), EntryCount, | ||||
std::move(Refs), std::move(Edges), std::move(PendingTypeTests), | std::move(Refs), std::move(Edges), std::move(PendingTypeTests), | ||||
std::move(PendingTypeTestAssumeVCalls), | std::move(PendingTypeTestAssumeVCalls), | ||||
std::move(PendingTypeCheckedLoadVCalls), | std::move(PendingTypeCheckedLoadVCalls), | ||||
std::move(PendingTypeTestAssumeConstVCalls), | std::move(PendingTypeTestAssumeConstVCalls), | ||||
std::move(PendingTypeCheckedLoadConstVCalls), | std::move(PendingTypeCheckedLoadConstVCalls), | ||||
std::move(PendingParamAccesses)); | std::move(PendingParamAccesses), isUnreachableFunction); | ||||
LastSeenSummary = FS.get(); | LastSeenSummary = FS.get(); | ||||
LastSeenGUID = VI.getGUID(); | LastSeenGUID = VI.getGUID(); | ||||
FS->setModulePath(ModuleIdMap[ModuleId]); | FS->setModulePath(ModuleIdMap[ModuleId]); | ||||
TheIndex.addGlobalValueSummary(VI, std::move(FS)); | TheIndex.addGlobalValueSummary(VI, std::move(FS)); | ||||
break; | break; | ||||
} | } | ||||
// FS_COMBINED_ALIAS: [valueid, modid, flags, valueid] | // FS_COMBINED_ALIAS: [valueid, modid, flags, valueid] | ||||
// Aliases must be emitted (and parsed) after all FS_COMBINED entries, as | // Aliases must be emitted (and parsed) after all FS_COMBINED entries, as | ||||
▲ Show 20 Lines • Show All 673 Lines • Show Last 20 Lines |