@@ -37,35 +37,6 @@ static cl::opt<CtxProfAnalysisPrinterPass::PrintMode> PrintLevel(
3737 " just the yaml representation of the profile" )),
3838 cl::desc(" Verbosity level of the contextual profile printer pass." ));
3939
40- const char *AssignGUIDPass::GUIDMetadataName = " guid" ;
41-
42- PreservedAnalyses AssignGUIDPass::run (Module &M, ModuleAnalysisManager &MAM) {
43- for (auto &F : M.functions ()) {
44- if (F.isDeclaration ())
45- continue ;
46- if (F.getMetadata (GUIDMetadataName))
47- continue ;
48- const GlobalValue::GUID GUID = F.getGUID ();
49- F.setMetadata (GUIDMetadataName,
50- MDNode::get (M.getContext (),
51- {ConstantAsMetadata::get (ConstantInt::get (
52- Type::getInt64Ty (M.getContext ()), GUID))}));
53- }
54- return PreservedAnalyses::none ();
55- }
56-
57- GlobalValue::GUID AssignGUIDPass::getGUID (const Function &F) {
58- if (F.isDeclaration ()) {
59- assert (GlobalValue::isExternalLinkage (F.getLinkage ()));
60- return F.getGUID ();
61- }
62- auto *MD = F.getMetadata (GUIDMetadataName);
63- assert (MD && " guid not found for defined function" );
64- return cast<ConstantInt>(cast<ConstantAsMetadata>(MD->getOperand (0 ))
65- ->getValue ()
66- ->stripPointerCasts ())
67- ->getZExtValue ();
68- }
6940AnalysisKey CtxProfAnalysis::Key;
7041
7142CtxProfAnalysis::CtxProfAnalysis (std::optional<StringRef> Profile)
@@ -98,7 +69,7 @@ PGOContextualProfile CtxProfAnalysis::run(Module &M,
9869 DenseSet<GlobalValue::GUID> ProfileRootsInModule;
9970 for (const auto &F : M)
10071 if (!F.isDeclaration ())
101- if (auto GUID = AssignGUIDPass:: getGUID (F );
72+ if (auto GUID = F. getGUID ();
10273 MaybeProfiles->Contexts .find (GUID) != MaybeProfiles->Contexts .end ())
10374 ProfileRootsInModule.insert (GUID);
10475
@@ -118,7 +89,7 @@ PGOContextualProfile CtxProfAnalysis::run(Module &M,
11889 for (const auto &F : M) {
11990 if (F.isDeclaration ())
12091 continue ;
121- auto GUID = AssignGUIDPass:: getGUID (F );
92+ auto GUID = F. getGUID ();
12293 assert (GUID && " guid not found for defined function" );
12394 const auto &Entry = F.begin ();
12495 uint32_t MaxCounters = 0 ; // we expect at least a counter.
@@ -152,13 +123,6 @@ PGOContextualProfile CtxProfAnalysis::run(Module &M,
152123 return Result;
153124}
154125
155- GlobalValue::GUID
156- PGOContextualProfile::getDefinedFunctionGUID (const Function &F) const {
157- if (auto It = FuncInfo.find (AssignGUIDPass::getGUID (F)); It != FuncInfo.end ())
158- return It->first ;
159- return 0 ;
160- }
161-
162126CtxProfAnalysisPrinterPass::CtxProfAnalysisPrinterPass (raw_ostream &OS)
163127 : OS(OS), Mode(PrintLevel) {}
164128
@@ -262,7 +226,7 @@ void PGOContextualProfile::initIndex() {
262226
263227void PGOContextualProfile::update (Visitor V, const Function &F) {
264228 assert (isFunctionKnown (F));
265- GlobalValue::GUID G = getDefinedFunctionGUID (F );
229+ GlobalValue::GUID G = F. getGUID ( );
266230 for (auto *Node = FuncInfo.find (G)->second .Index .Next ; Node;
267231 Node = Node->Next )
268232 V (*reinterpret_cast <PGOCtxProfContext *>(Node));
@@ -273,7 +237,7 @@ void PGOContextualProfile::visit(ConstVisitor V, const Function *F) const {
273237 return preorderVisit<const PGOCtxProfContext::CallTargetMapTy,
274238 const PGOCtxProfContext>(Profiles.Contexts , V);
275239 assert (isFunctionKnown (*F));
276- GlobalValue::GUID G = getDefinedFunctionGUID (*F );
240+ GlobalValue::GUID G = F-> getGUID ( );
277241 for (const auto *Node = FuncInfo.find (G)->second .Index .Next ; Node;
278242 Node = Node->Next )
279243 V (*reinterpret_cast <const PGOCtxProfContext *>(Node));
0 commit comments