//===- CtxProfAnalysis.h - maintain contextual profile info -*- C++ ---*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // #ifndef LLVM_ANALYSIS_CTXPROFANALYSIS_H #define LLVM_ANALYSIS_CTXPROFANALYSIS_H #include "llvm/IR/GlobalValue.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/PassManager.h" #include "llvm/ProfileData/PGOCtxProfReader.h" #include <optional> namespace llvm { class CtxProfAnalysis; // Setting initial capacity to 1 because all contexts must have at least 1 // counter, and then, because all contexts belonging to a function have the same // size, there'll be at most one other heap allocation. CtxProfFlatProfile; /// The instrumented contextual profile, produced by the CtxProfAnalysis. class PGOContextualProfile { … }; class CtxProfAnalysis : public AnalysisInfoMixin<CtxProfAnalysis> { … }; class CtxProfAnalysisPrinterPass : public PassInfoMixin<CtxProfAnalysisPrinterPass> { … }; /// Assign a GUID to functions as metadata. GUID calculation takes linkage into /// account, which may change especially through and after thinlto. By /// pre-computing and assigning as metadata, this mechanism is resilient to such /// changes (as well as name changes e.g. suffix ".llvm." additions). // FIXME(mtrofin): we can generalize this mechanism to calculate a GUID early in // the pass pipeline, associate it with any Global Value, and then use it for // PGO and ThinLTO. // At that point, this should be moved elsewhere. class AssignGUIDPass : public PassInfoMixin<AssignGUIDPass> { … }; } // namespace llvm #endif // LLVM_ANALYSIS_CTXPROFANALYSIS_H