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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user