diff options
Diffstat (limited to 'llvm/lib/Analysis/CtxProfAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/CtxProfAnalysis.cpp | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/llvm/lib/Analysis/CtxProfAnalysis.cpp b/llvm/lib/Analysis/CtxProfAnalysis.cpp index a363bce..7e8cb8e 100644 --- a/llvm/lib/Analysis/CtxProfAnalysis.cpp +++ b/llvm/lib/Analysis/CtxProfAnalysis.cpp @@ -48,8 +48,6 @@ static cl::opt<bool> ForceIsInSpecializedModule( cl::desc("Treat the given module as-if it were containing the " "post-thinlink module containing the root")); -const char *AssignGUIDPass::GUIDMetadataName = "guid"; - namespace llvm { class ProfileAnnotatorImpl final { friend class ProfileAnnotator; @@ -418,33 +416,6 @@ bool ProfileAnnotator::getOutgoingBranchWeights( return MaxCount > 0; } -PreservedAnalyses AssignGUIDPass::run(Module &M, ModuleAnalysisManager &MAM) { - for (auto &F : M.functions()) { - if (F.isDeclaration()) - continue; - if (F.getMetadata(GUIDMetadataName)) - continue; - const GlobalValue::GUID GUID = F.getGUID(); - F.setMetadata(GUIDMetadataName, - MDNode::get(M.getContext(), - {ConstantAsMetadata::get(ConstantInt::get( - Type::getInt64Ty(M.getContext()), GUID))})); - } - return PreservedAnalyses::none(); -} - -GlobalValue::GUID AssignGUIDPass::getGUID(const Function &F) { - if (F.isDeclaration()) { - assert(GlobalValue::isExternalLinkage(F.getLinkage())); - return F.getGUID(); - } - auto *MD = F.getMetadata(GUIDMetadataName); - assert(MD && "guid not found for defined function"); - return cast<ConstantInt>(cast<ConstantAsMetadata>(MD->getOperand(0)) - ->getValue() - ->stripPointerCasts()) - ->getZExtValue(); -} AnalysisKey CtxProfAnalysis::Key; CtxProfAnalysis::CtxProfAnalysis(std::optional<StringRef> Profile) @@ -513,7 +484,7 @@ PGOContextualProfile CtxProfAnalysis::run(Module &M, for (const auto &F : M) { if (F.isDeclaration()) continue; - auto GUID = AssignGUIDPass::getGUID(F); + auto GUID = F.getGUID(); assert(GUID && "guid not found for defined function"); const auto &Entry = F.begin(); uint32_t MaxCounters = 0; // we expect at least a counter. @@ -547,13 +518,6 @@ PGOContextualProfile CtxProfAnalysis::run(Module &M, return Result; } -GlobalValue::GUID -PGOContextualProfile::getDefinedFunctionGUID(const Function &F) const { - if (auto It = FuncInfo.find(AssignGUIDPass::getGUID(F)); It != FuncInfo.end()) - return It->first; - return 0; -} - CtxProfAnalysisPrinterPass::CtxProfAnalysisPrinterPass(raw_ostream &OS) : OS(OS), Mode(PrintLevel) {} @@ -669,7 +633,7 @@ bool PGOContextualProfile::isInSpecializedModule() const { void PGOContextualProfile::update(Visitor V, const Function &F) { assert(isFunctionKnown(F)); - GlobalValue::GUID G = getDefinedFunctionGUID(F); + GlobalValue::GUID G = F.getGUID(); for (auto *Node = FuncInfo.find(G)->second.Index.Next; Node; Node = Node->Next) V(*reinterpret_cast<PGOCtxProfContext *>(Node)); @@ -680,7 +644,7 @@ void PGOContextualProfile::visit(ConstVisitor V, const Function *F) const { return preorderVisit<const PGOCtxProfContext::CallTargetMapTy, const PGOCtxProfContext>(Profiles.Contexts, V); assert(isFunctionKnown(*F)); - GlobalValue::GUID G = getDefinedFunctionGUID(*F); + GlobalValue::GUID G = F->getGUID(); for (const auto *Node = FuncInfo.find(G)->second.Index.Next; Node; Node = Node->Next) V(*reinterpret_cast<const PGOCtxProfContext *>(Node)); |