[ThinLTO] Include linkage type in function summary
Summary: Adds the linkage type to both the per-module and combined function summaries, which subsumes the current islocal bit. This will eventually be used to optimized linkage types based on global summary-based analysis. Reviewers: joker.eph Subscribers: joker.eph, davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D16943 llvm-svn: 259993
This commit is contained in:
@@ -496,8 +496,8 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
|
||||
Stream.ExitBlock();
|
||||
}
|
||||
|
||||
static unsigned getEncodedLinkage(const GlobalValue &GV) {
|
||||
switch (GV.getLinkage()) {
|
||||
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage) {
|
||||
switch (Linkage) {
|
||||
case GlobalValue::ExternalLinkage:
|
||||
return 0;
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
@@ -524,6 +524,10 @@ static unsigned getEncodedLinkage(const GlobalValue &GV) {
|
||||
llvm_unreachable("Invalid linkage");
|
||||
}
|
||||
|
||||
static unsigned getEncodedLinkage(const GlobalValue &GV) {
|
||||
return getEncodedLinkage(GV.getLinkage());
|
||||
}
|
||||
|
||||
static unsigned getEncodedVisibility(const GlobalValue &GV) {
|
||||
switch (GV.getVisibility()) {
|
||||
case GlobalValue::DefaultVisibility: return 0;
|
||||
@@ -2449,7 +2453,7 @@ static void SaveFunctionInfo(
|
||||
std::unique_ptr<FunctionSummary> FuncSummary;
|
||||
if (EmitFunctionSummary) {
|
||||
FuncSummary = llvm::make_unique<FunctionSummary>(NumInsts);
|
||||
FuncSummary->setLocalFunction(F.hasLocalLinkage());
|
||||
FuncSummary->setFunctionLinkage(F.getLinkage());
|
||||
}
|
||||
FunctionIndex[&F] =
|
||||
llvm::make_unique<FunctionInfo>(BitcodeIndex, std::move(FuncSummary));
|
||||
@@ -2776,7 +2780,7 @@ static void WritePerModuleFunctionSummaryRecord(
|
||||
unsigned FSAbbrev, BitstreamWriter &Stream) {
|
||||
assert(FS);
|
||||
NameVals.push_back(ValueID);
|
||||
NameVals.push_back(FS->isLocalFunction());
|
||||
NameVals.push_back(getEncodedLinkage(FS->getFunctionLinkage()));
|
||||
NameVals.push_back(FS->instCount());
|
||||
|
||||
// Emit the finished record.
|
||||
@@ -2795,7 +2799,7 @@ static void WritePerModuleFunctionSummary(
|
||||
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_PERMODULE_ENTRY));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // islocal
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
unsigned FSAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
|
||||
@@ -2845,6 +2849,7 @@ static void WriteCombinedFunctionSummary(const FunctionInfoIndex &I,
|
||||
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_COMBINED_ENTRY));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
|
||||
unsigned FSAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
|
||||
@@ -2855,6 +2860,7 @@ static void WriteCombinedFunctionSummary(const FunctionInfoIndex &I,
|
||||
assert(FS);
|
||||
|
||||
NameVals.push_back(I.getModuleId(FS->modulePath()));
|
||||
NameVals.push_back(getEncodedLinkage(FS->getFunctionLinkage()));
|
||||
NameVals.push_back(FS->instCount());
|
||||
|
||||
// Record the starting offset of this summary entry for use
|
||||
|
||||
Reference in New Issue
Block a user