Skip to content
Snippets Groups Projects
Commit a2a60dd6 authored by Xinliang David Li's avatar Xinliang David Li
Browse files

[PGO] code simplification: use existing VP annotation API /NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259819 91177308-0d34-0410-b5e6-96231b3b80d8
parent bf1d31e8
No related branches found
No related tags found
No related merge requests found
...@@ -780,35 +780,11 @@ void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, ...@@ -780,35 +780,11 @@ void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind,
// pairs for each function. // pairs for each function.
if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind)) if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind))
return; return;
uint32_t NV = ProfRecord->getNumValueDataForSite(ValueKind,
NumValueSites[ValueKind]);
std::unique_ptr<InstrProfValueData[]> VD =
ProfRecord->getValueForSite(ValueKind, NumValueSites[ValueKind]);
uint64_t Sum = 0; llvm::annotateValueSite(CGM.getModule(), *ValueSite, *ProfRecord,
for (uint32_t I = 0; I < NV; ++I) (llvm::InstrProfValueKind)ValueKind,
Sum += VD[I].Count; NumValueSites[ValueKind]);
llvm::LLVMContext &Ctx = CGM.getLLVMContext();
llvm::MDBuilder MDHelper(Ctx);
SmallVector<llvm::Metadata*, 3> Vals;
Vals.push_back(MDHelper.createString("VP"));
Vals.push_back(MDHelper.createConstant(
llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), ValueKind)));
Vals.push_back(MDHelper.createConstant(
llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), Sum)));
uint32_t MDCount = 3;
for (uint32_t I = 0; I < NV; ++I) {
Vals.push_back(MDHelper.createConstant(
llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Value)));
Vals.push_back(MDHelper.createConstant(
llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Count)));
if (--MDCount == 0)
break;
}
ValueSite->setMetadata(
llvm::LLVMContext::MD_prof, llvm::MDNode::get(Ctx, Vals));
NumValueSites[ValueKind]++; NumValueSites[ValueKind]++;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment