Reorganize GlobalValueSummary with a "Flags" bitfield.
Right now it only contains the LinkageType, but will be extended with "hasSection", "isOptSize", "hasInlineAssembly", etc. Differential Revision: http://reviews.llvm.org/D19404 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267319
This commit is contained in:
@@ -195,27 +195,27 @@ enum ModulePathSymtabCodes {
|
||||
// The summary section uses different codes in the per-module
|
||||
// and combined index cases.
|
||||
enum GlobalValueSummarySymtabCodes {
|
||||
// PERMODULE: [valueid, linkage, instcount, numrefs, numrefs x valueid,
|
||||
// PERMODULE: [valueid, flags, instcount, numrefs, numrefs x valueid,
|
||||
// n x (valueid, callsitecount)]
|
||||
FS_PERMODULE = 1,
|
||||
// PERMODULE_PROFILE: [valueid, linkage, instcount, numrefs,
|
||||
// PERMODULE_PROFILE: [valueid, flags, instcount, numrefs,
|
||||
// numrefs x valueid,
|
||||
// n x (valueid, callsitecount, profilecount)]
|
||||
FS_PERMODULE_PROFILE = 2,
|
||||
// PERMODULE_GLOBALVAR_INIT_REFS: [valueid, linkage, n x valueid]
|
||||
// PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, n x valueid]
|
||||
FS_PERMODULE_GLOBALVAR_INIT_REFS = 3,
|
||||
// COMBINED: [modid, linkage, instcount, numrefs, numrefs x valueid,
|
||||
// COMBINED: [modid, flags, instcount, numrefs, numrefs x valueid,
|
||||
// n x (valueid, callsitecount)]
|
||||
FS_COMBINED = 4,
|
||||
// COMBINED_PROFILE: [modid, linkage, instcount, numrefs,
|
||||
// COMBINED_PROFILE: [modid, flags, instcount, numrefs,
|
||||
// numrefs x valueid,
|
||||
// n x (valueid, callsitecount, profilecount)]
|
||||
FS_COMBINED_PROFILE = 5,
|
||||
// COMBINED_GLOBALVAR_INIT_REFS: [modid, linkage, n x valueid]
|
||||
// COMBINED_GLOBALVAR_INIT_REFS: [modid, flags, n x valueid]
|
||||
FS_COMBINED_GLOBALVAR_INIT_REFS = 6,
|
||||
// ALIAS: [valueid, linkage, valueid]
|
||||
// ALIAS: [valueid, flags, valueid]
|
||||
FS_ALIAS = 7,
|
||||
// COMBINED_ALIAS: [modid, linkage, offset]
|
||||
// COMBINED_ALIAS: [modid, flags, offset]
|
||||
FS_COMBINED_ALIAS = 8,
|
||||
// COMBINED_ORIGINAL_NAME: [original_name_hash]
|
||||
FS_COMBINED_ORIGINAL_NAME = 9,
|
||||
|
||||
@@ -92,6 +92,22 @@ public:
|
||||
/// \brief Sububclass discriminator (for dyn_cast<> et al.)
|
||||
enum SummaryKind { AliasKind, FunctionKind, GlobalVarKind };
|
||||
|
||||
/// Group flags (Linkage, hasSection, isOptSize, etc.) as a bitfield.
|
||||
struct GVFlags {
|
||||
/// \brief The linkage type of the associated global value.
|
||||
///
|
||||
/// One use is to flag values that have local linkage types and need to
|
||||
/// have module identifier appended before placing into the combined
|
||||
/// index, to disambiguate from other values with the same name.
|
||||
/// In the future this will be used to update and optimize linkage
|
||||
/// types based on global summary-based analysis.
|
||||
GlobalValue::LinkageTypes Linkage : 4;
|
||||
|
||||
/// Convenience Constructors
|
||||
explicit GVFlags(GlobalValue::LinkageTypes Linkage) : Linkage(Linkage) {}
|
||||
GVFlags(const GlobalValue &GV) : Linkage(GV.getLinkage()) {}
|
||||
};
|
||||
|
||||
private:
|
||||
/// Kind of summary for use in dyn_cast<> et al.
|
||||
SummaryKind Kind;
|
||||
@@ -110,14 +126,7 @@ private:
|
||||
/// module path string table.
|
||||
StringRef ModulePath;
|
||||
|
||||
/// \brief The linkage type of the associated global value.
|
||||
///
|
||||
/// One use is to flag values that have local linkage types and need to
|
||||
/// have module identifier appended before placing into the combined
|
||||
/// index, to disambiguate from other values with the same name.
|
||||
/// In the future this will be used to update and optimize linkage
|
||||
/// types based on global summary-based analysis.
|
||||
GlobalValue::LinkageTypes Linkage;
|
||||
GVFlags Flags;
|
||||
|
||||
/// List of values referenced by this global value's definition
|
||||
/// (either by the initializer of a global variable, or referenced
|
||||
@@ -127,8 +136,7 @@ private:
|
||||
|
||||
protected:
|
||||
/// GlobalValueSummary constructor.
|
||||
GlobalValueSummary(SummaryKind K, GlobalValue::LinkageTypes Linkage)
|
||||
: Kind(K), Linkage(Linkage) {}
|
||||
GlobalValueSummary(SummaryKind K, GVFlags Flags) : Kind(K), Flags(Flags) {}
|
||||
|
||||
public:
|
||||
virtual ~GlobalValueSummary() = default;
|
||||
@@ -150,8 +158,11 @@ public:
|
||||
/// Get the path to the module containing this function.
|
||||
StringRef modulePath() const { return ModulePath; }
|
||||
|
||||
/// Get the flags for this GlobalValue (see \p struct GVFlags).
|
||||
GVFlags flags() { return Flags; }
|
||||
|
||||
/// Return linkage type recorded for this global value.
|
||||
GlobalValue::LinkageTypes linkage() const { return Linkage; }
|
||||
GlobalValue::LinkageTypes linkage() const { return Flags.Linkage; }
|
||||
|
||||
/// Record a reference from this global value to the global value identified
|
||||
/// by \p RefGUID.
|
||||
@@ -179,8 +190,7 @@ class AliasSummary : public GlobalValueSummary {
|
||||
|
||||
public:
|
||||
/// Summary constructors.
|
||||
AliasSummary(GlobalValue::LinkageTypes Linkage)
|
||||
: GlobalValueSummary(AliasKind, Linkage) {}
|
||||
AliasSummary(GVFlags Flags) : GlobalValueSummary(AliasKind, Flags) {}
|
||||
|
||||
/// Check if this is an alias summary.
|
||||
static bool classof(const GlobalValueSummary *GVS) {
|
||||
@@ -216,8 +226,8 @@ private:
|
||||
|
||||
public:
|
||||
/// Summary constructors.
|
||||
FunctionSummary(GlobalValue::LinkageTypes Linkage, unsigned NumInsts)
|
||||
: GlobalValueSummary(FunctionKind, Linkage), InstCount(NumInsts) {}
|
||||
FunctionSummary(GVFlags Flags, unsigned NumInsts)
|
||||
: GlobalValueSummary(FunctionKind, Flags), InstCount(NumInsts) {}
|
||||
|
||||
/// Check if this is a function summary.
|
||||
static bool classof(const GlobalValueSummary *GVS) {
|
||||
@@ -263,8 +273,7 @@ class GlobalVarSummary : public GlobalValueSummary {
|
||||
|
||||
public:
|
||||
/// Summary constructors.
|
||||
GlobalVarSummary(GlobalValue::LinkageTypes Linkage)
|
||||
: GlobalValueSummary(GlobalVarKind, Linkage) {}
|
||||
GlobalVarSummary(GVFlags Flags) : GlobalValueSummary(GlobalVarKind, Flags) {}
|
||||
|
||||
/// Check if this is a global variable summary.
|
||||
static bool classof(const GlobalValueSummary *GVS) {
|
||||
|
||||
@@ -95,8 +95,9 @@ void ModuleSummaryIndexBuilder::computeFunctionInfo(const Function &F,
|
||||
findRefEdges(&*I, RefEdges, Visited);
|
||||
}
|
||||
|
||||
GlobalValueSummary::GVFlags Flags(F);
|
||||
std::unique_ptr<FunctionSummary> FuncSummary =
|
||||
llvm::make_unique<FunctionSummary>(F.getLinkage(), NumInsts);
|
||||
llvm::make_unique<FunctionSummary>(Flags, NumInsts);
|
||||
FuncSummary->addCallGraphEdges(CallGraphEdges);
|
||||
FuncSummary->addRefEdges(RefEdges);
|
||||
std::unique_ptr<GlobalValueInfo> GVInfo =
|
||||
@@ -108,8 +109,9 @@ void ModuleSummaryIndexBuilder::computeVariableInfo(const GlobalVariable &V) {
|
||||
DenseSet<const Value *> RefEdges;
|
||||
SmallPtrSet<const User *, 8> Visited;
|
||||
findRefEdges(&V, RefEdges, Visited);
|
||||
GlobalValueSummary::GVFlags Flags(V);
|
||||
std::unique_ptr<GlobalVarSummary> GVarSummary =
|
||||
llvm::make_unique<GlobalVarSummary>(V.getLinkage());
|
||||
llvm::make_unique<GlobalVarSummary>(Flags);
|
||||
GVarSummary->addRefEdges(RefEdges);
|
||||
std::unique_ptr<GlobalValueInfo> GVInfo =
|
||||
llvm::make_unique<GlobalValueInfo>(0, std::move(GVarSummary));
|
||||
|
||||
@@ -738,6 +738,16 @@ static GlobalValue::LinkageTypes getDecodedLinkage(unsigned Val) {
|
||||
}
|
||||
}
|
||||
|
||||
// Decode the flags for GlobalValue in the summary
|
||||
static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags,
|
||||
uint64_t Version) {
|
||||
// Summary were not emitted before LLVM 3.9, we don't need to upgrade Linkage
|
||||
// like getDecodedLinkage() above. Any future change to the linkage enum and
|
||||
// to getDecodedLinkage() will need to be taken into account here as above.
|
||||
auto Linkage = GlobalValue::LinkageTypes(RawFlags & 0xF); // 4 bits
|
||||
return GlobalValueSummary::GVFlags(Linkage);
|
||||
}
|
||||
|
||||
static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
|
||||
switch (Val) {
|
||||
default: // Map unknown visibilities to default.
|
||||
@@ -6051,19 +6061,20 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
switch (BitCode) {
|
||||
default: // Default behavior: ignore.
|
||||
break;
|
||||
// FS_PERMODULE: [valueid, linkage, instcount, numrefs, numrefs x valueid,
|
||||
// FS_PERMODULE: [valueid, flags, instcount, numrefs, numrefs x valueid,
|
||||
// n x (valueid, callsitecount)]
|
||||
// FS_PERMODULE_PROFILE: [valueid, linkage, instcount, numrefs,
|
||||
// FS_PERMODULE_PROFILE: [valueid, flags, instcount, numrefs,
|
||||
// numrefs x valueid,
|
||||
// n x (valueid, callsitecount, profilecount)]
|
||||
case bitc::FS_PERMODULE:
|
||||
case bitc::FS_PERMODULE_PROFILE: {
|
||||
unsigned ValueID = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
unsigned InstCount = Record[2];
|
||||
unsigned NumRefs = Record[3];
|
||||
std::unique_ptr<FunctionSummary> FS = llvm::make_unique<FunctionSummary>(
|
||||
getDecodedLinkage(RawLinkage), InstCount);
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<FunctionSummary> FS =
|
||||
llvm::make_unique<FunctionSummary>(Flags, InstCount);
|
||||
// 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
|
||||
// string table section in the per-module index, we create a single
|
||||
@@ -6097,15 +6108,15 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
Info->setSummary(std::move(FS));
|
||||
break;
|
||||
}
|
||||
// FS_ALIAS: [valueid, linkage, valueid]
|
||||
// FS_ALIAS: [valueid, flags, valueid]
|
||||
// Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as
|
||||
// they expect all aliasee summaries to be available.
|
||||
case bitc::FS_ALIAS: {
|
||||
unsigned ValueID = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
unsigned AliaseeID = Record[2];
|
||||
std::unique_ptr<AliasSummary> AS =
|
||||
llvm::make_unique<AliasSummary>(getDecodedLinkage(RawLinkage));
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<AliasSummary> AS = llvm::make_unique<AliasSummary>(Flags);
|
||||
// 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
|
||||
// string table section in the per-module index, we create a single
|
||||
@@ -6127,12 +6138,13 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
Info->setSummary(std::move(AS));
|
||||
break;
|
||||
}
|
||||
// FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, linkage, n x valueid]
|
||||
// FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, n x valueid]
|
||||
case bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS: {
|
||||
unsigned ValueID = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<GlobalVarSummary> FS =
|
||||
llvm::make_unique<GlobalVarSummary>(getDecodedLinkage(RawLinkage));
|
||||
llvm::make_unique<GlobalVarSummary>(Flags);
|
||||
FS->setModulePath(
|
||||
TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first());
|
||||
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
||||
@@ -6147,19 +6159,20 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
Info->setSummary(std::move(FS));
|
||||
break;
|
||||
}
|
||||
// FS_COMBINED: [modid, linkage, instcount, numrefs, numrefs x valueid,
|
||||
// FS_COMBINED: [modid, flags, instcount, numrefs, numrefs x valueid,
|
||||
// n x (valueid, callsitecount)]
|
||||
// FS_COMBINED_PROFILE: [modid, linkage, instcount, numrefs,
|
||||
// FS_COMBINED_PROFILE: [modid, flags, instcount, numrefs,
|
||||
// numrefs x valueid,
|
||||
// n x (valueid, callsitecount, profilecount)]
|
||||
case bitc::FS_COMBINED:
|
||||
case bitc::FS_COMBINED_PROFILE: {
|
||||
uint64_t ModuleId = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
unsigned InstCount = Record[2];
|
||||
unsigned NumRefs = Record[3];
|
||||
std::unique_ptr<FunctionSummary> FS = llvm::make_unique<FunctionSummary>(
|
||||
getDecodedLinkage(RawLinkage), InstCount);
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<FunctionSummary> FS =
|
||||
llvm::make_unique<FunctionSummary>(Flags, InstCount);
|
||||
LastSeenSummary = FS.get();
|
||||
FS->setModulePath(ModuleIdMap[ModuleId]);
|
||||
static int RefListStartIndex = 4;
|
||||
@@ -6187,15 +6200,15 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
Combined = true;
|
||||
break;
|
||||
}
|
||||
// FS_COMBINED_ALIAS: [modid, linkage, offset]
|
||||
// FS_COMBINED_ALIAS: [modid, flags, offset]
|
||||
// Aliases must be emitted (and parsed) after all FS_COMBINED entries, as
|
||||
// they expect all aliasee summaries to be available.
|
||||
case bitc::FS_COMBINED_ALIAS: {
|
||||
uint64_t ModuleId = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
uint64_t AliaseeSummaryOffset = Record[2];
|
||||
std::unique_ptr<AliasSummary> AS =
|
||||
llvm::make_unique<AliasSummary>(getDecodedLinkage(RawLinkage));
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<AliasSummary> AS = llvm::make_unique<AliasSummary>(Flags);
|
||||
LastSeenSummary = AS.get();
|
||||
AS->setModulePath(ModuleIdMap[ModuleId]);
|
||||
|
||||
@@ -6210,12 +6223,13 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
Combined = true;
|
||||
break;
|
||||
}
|
||||
// FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, linkage, n x valueid]
|
||||
// FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, flags, n x valueid]
|
||||
case bitc::FS_COMBINED_GLOBALVAR_INIT_REFS: {
|
||||
uint64_t ModuleId = Record[0];
|
||||
uint64_t RawLinkage = Record[1];
|
||||
uint64_t RawFlags = Record[1];
|
||||
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
|
||||
std::unique_ptr<GlobalVarSummary> FS =
|
||||
llvm::make_unique<GlobalVarSummary>(getDecodedLinkage(RawLinkage));
|
||||
llvm::make_unique<GlobalVarSummary>(Flags);
|
||||
LastSeenSummary = FS.get();
|
||||
FS->setModulePath(ModuleIdMap[ModuleId]);
|
||||
for (unsigned I = 2, E = Record.size(); I != E; ++I) {
|
||||
|
||||
@@ -786,6 +786,14 @@ static unsigned getEncodedLinkage(const GlobalValue &GV) {
|
||||
return getEncodedLinkage(GV.getLinkage());
|
||||
}
|
||||
|
||||
// Decode the flags for GlobalValue in the summary
|
||||
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
|
||||
uint64_t RawFlags = 0;
|
||||
// Emit Linkage enum.
|
||||
RawFlags |= Flags.Linkage; // 4 bits
|
||||
return RawFlags;
|
||||
}
|
||||
|
||||
static unsigned getEncodedVisibility(const GlobalValue &GV) {
|
||||
switch (GV.getVisibility()) {
|
||||
case GlobalValue::DefaultVisibility: return 0;
|
||||
@@ -3023,7 +3031,7 @@ void ModuleBitcodeWriter::writePerModuleFunctionSummaryRecord(
|
||||
NameVals.push_back(ValueID);
|
||||
|
||||
FunctionSummary *FS = cast<FunctionSummary>(Info->summary());
|
||||
NameVals.push_back(getEncodedLinkage(FS->linkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
|
||||
NameVals.push_back(FS->instCount());
|
||||
NameVals.push_back(FS->refs().size());
|
||||
|
||||
@@ -3057,7 +3065,7 @@ void ModuleBitcodeWriter::writeModuleLevelReferences(
|
||||
if (V.isDeclaration())
|
||||
return;
|
||||
NameVals.push_back(VE.getValueID(&V));
|
||||
NameVals.push_back(getEncodedLinkage(V.getLinkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(V));
|
||||
auto *Info = Index->getGlobalValueInfo(V);
|
||||
GlobalVarSummary *VS = cast<GlobalVarSummary>(Info->summary());
|
||||
for (auto Ref : VS->refs())
|
||||
@@ -3081,7 +3089,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
if (Index->begin() == Index->end())
|
||||
return;
|
||||
|
||||
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
|
||||
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 4);
|
||||
|
||||
Stream.EmitRecord(bitc::FS_VERSION, ArrayRef<uint64_t>{INDEX_VERSION});
|
||||
|
||||
@@ -3089,7 +3097,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
|
||||
// numrefs x valueid, n x (valueid, callsitecount)
|
||||
@@ -3101,7 +3109,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_PROFILE));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
|
||||
// numrefs x valueid, n x (valueid, callsitecount, profilecount)
|
||||
@@ -3113,7 +3121,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
|
||||
unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
@@ -3122,7 +3130,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_ALIAS));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
|
||||
@@ -3157,7 +3165,7 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
|
||||
auto AliasId = VE.getValueID(&A);
|
||||
auto AliaseeId = VE.getValueID(Aliasee);
|
||||
NameVals.push_back(AliasId);
|
||||
NameVals.push_back(getEncodedLinkage(A.getLinkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(A));
|
||||
NameVals.push_back(AliaseeId);
|
||||
Stream.EmitRecord(bitc::FS_ALIAS, NameVals, FSAliasAbbrev);
|
||||
NameVals.clear();
|
||||
@@ -3175,7 +3183,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
|
||||
// numrefs x valueid, n x (valueid, callsitecount)
|
||||
@@ -3187,7 +3195,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_PROFILE));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
|
||||
// numrefs x valueid, n x (valueid, callsitecount, profilecount)
|
||||
@@ -3199,7 +3207,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
|
||||
unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
@@ -3208,7 +3216,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_ALIAS));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // offset
|
||||
unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
|
||||
@@ -3243,7 +3251,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
|
||||
if (auto *VS = dyn_cast<GlobalVarSummary>(S)) {
|
||||
NameVals.push_back(Index.getModuleId(VS->modulePath()));
|
||||
NameVals.push_back(getEncodedLinkage(VS->linkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(VS->flags()));
|
||||
for (auto &RI : VS->refs()) {
|
||||
NameVals.push_back(getValueId(RI.getGUID()));
|
||||
}
|
||||
@@ -3266,7 +3274,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
|
||||
auto *FS = cast<FunctionSummary>(S);
|
||||
NameVals.push_back(Index.getModuleId(FS->modulePath()));
|
||||
NameVals.push_back(getEncodedLinkage(FS->linkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
|
||||
NameVals.push_back(FS->instCount());
|
||||
NameVals.push_back(FS->refs().size());
|
||||
|
||||
@@ -3315,7 +3323,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
|
||||
for (auto GVI : Aliases) {
|
||||
AliasSummary *AS = cast<AliasSummary>(GVI->summary());
|
||||
NameVals.push_back(Index.getModuleId(AS->modulePath()));
|
||||
NameVals.push_back(getEncodedLinkage(AS->linkage()));
|
||||
NameVals.push_back(getEncodedGVSummaryFlags(AS->flags()));
|
||||
auto AliaseeOffset = SummaryToOffsetMap[&AS->getAliasee()];
|
||||
assert(AliaseeOffset);
|
||||
NameVals.push_back(AliaseeOffset);
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
; Function main contains call to func, as well as address reference to func:
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[MAINID:[0-9]+]] op1=0 {{.*}} op3=1 op4=[[FUNCID:[0-9]+]] op5=[[FUNCID]] op6=1/>
|
||||
; Function W contains a call to func3 as well as a reference to globalvar:
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[WID:[0-9]+]] op1=17 {{.*}} op3=1 op4=[[GLOBALVARID:[0-9]+]] op5=[[FUNC3ID:[0-9]+]] op6=1/>
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[WID:[0-9]+]] op1=5 {{.*}} op3=1 op4=[[GLOBALVARID:[0-9]+]] op5=[[FUNC3ID:[0-9]+]] op6=1/>
|
||||
; Function X contains call to foo, as well as address reference to foo
|
||||
; which is in the same instruction as the call:
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[XID:[0-9]+]] op1=12 {{.*}} op3=1 op4=[[FOOID:[0-9]+]] op5=[[FOOID]] op6=1/>
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[XID:[0-9]+]] op1=1 {{.*}} op3=1 op4=[[FOOID:[0-9]+]] op5=[[FOOID]] op6=1/>
|
||||
; Function Y contains call to func2, and ensures we don't incorrectly add
|
||||
; a reference to it when reached while earlier analyzing the phi using its
|
||||
; return value:
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[YID:[0-9]+]] op1=9 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[YID:[0-9]+]] op1=8 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
|
||||
; Function Z contains call to func2, and ensures we don't incorrectly add
|
||||
; a reference to it when reached while analyzing subsequent use of its return
|
||||
; value:
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[ZID:[0-9]+]] op1=19 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
|
||||
; CHECK-DAG: <PERMODULE {{.*}} op0=[[ZID:[0-9]+]] op1=3 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
|
||||
; Variable bar initialization contains address reference to func:
|
||||
; CHECK-DAG: <PERMODULE_GLOBALVAR_INIT_REFS {{.*}} op0=[[BARID:[0-9]+]] op1=0 op2=[[FUNCID]]/>
|
||||
; CHECK: </GLOBALVAL_SUMMARY_BLOCK>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
; BC-NEXT: <VERSION
|
||||
; BC-NEXT: <PERMODULE {{.*}} op0=1 op1=0
|
||||
; BC-NEXT: <PERMODULE {{.*}} op0=2 op1=0
|
||||
; BC-NEXT: <PERMODULE {{.*}} op0=3 op1=3
|
||||
; BC-NEXT: <PERMODULE {{.*}} op0=3 op1=7
|
||||
; BC-NEXT: <ALIAS {{.*}} op0=4 op1=0 op2=3
|
||||
; BC-NEXT: </GLOBALVAL_SUMMARY_BLOCK
|
||||
; BC-NEXT: <VALUE_SYMTAB
|
||||
|
||||
@@ -5,50 +5,50 @@
|
||||
; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
|
||||
|
||||
define private void @private()
|
||||
; CHECK: <PERMODULE {{.*}} op1=9
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=9
|
||||
; CHECK: <PERMODULE {{.*}} op1=8
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=8
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @internal()
|
||||
; CHECK: <PERMODULE {{.*}} op1=7
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=7
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define available_externally void @available_externally()
|
||||
; CHECK: <PERMODULE {{.*}} op1=1
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=1
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce void @linkonce()
|
||||
; CHECK: <PERMODULE {{.*}} op1=2
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=2
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define weak void @weak()
|
||||
; CHECK: <PERMODULE {{.*}} op1=4
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=4
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce_odr void @linkonce_odr()
|
||||
; CHECK: <PERMODULE {{.*}} op1=3
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=3
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define available_externally void @available_externally()
|
||||
; CHECK: <PERMODULE {{.*}} op1=12
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=12
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce void @linkonce()
|
||||
; CHECK: <PERMODULE {{.*}} op1=18
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=18
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define weak void @weak()
|
||||
; CHECK: <PERMODULE {{.*}} op1=16
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=16
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce_odr void @linkonce_odr()
|
||||
; CHECK: <PERMODULE {{.*}} op1=19
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=19
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
define weak_odr void @weak_odr()
|
||||
; CHECK: <PERMODULE {{.*}} op1=17
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=17
|
||||
; CHECK: <PERMODULE {{.*}} op1=5
|
||||
; COMBINED-DAG: <COMBINED {{.*}} op1=5
|
||||
{
|
||||
ret void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user