llvm/llvm/lib/Transforms/IPO/SampleContextTracker.cpp

//===- SampleContextTracker.cpp - Context-sensitive Profile Tracker -------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements the SampleContextTracker used by CSSPGO.
//
//===----------------------------------------------------------------------===//

#include "llvm/Transforms/IPO/SampleContextTracker.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/ProfileData/SampleProf.h"
#include <map>
#include <queue>
#include <vector>

usingnamespacellvm;
usingnamespacesampleprof;

#define DEBUG_TYPE

namespace llvm {

ContextTrieNode *ContextTrieNode::getChildContext(const LineLocation &CallSite,
                                                  FunctionId CalleeName) {}

ContextTrieNode *
ContextTrieNode::getHottestChildContext(const LineLocation &CallSite) {}

ContextTrieNode &
SampleContextTracker::moveContextSamples(ContextTrieNode &ToNodeParent,
                                         const LineLocation &CallSite,
                                         ContextTrieNode &&NodeToMove) {}

void ContextTrieNode::removeChildContext(const LineLocation &CallSite,
                                         FunctionId CalleeName) {}

std::map<uint64_t, ContextTrieNode> &ContextTrieNode::getAllChildContext() {}

FunctionId ContextTrieNode::getFuncName() const {}

FunctionSamples *ContextTrieNode::getFunctionSamples() const {}

void ContextTrieNode::setFunctionSamples(FunctionSamples *FSamples) {}

std::optional<uint32_t> ContextTrieNode::getFunctionSize() const {}

void ContextTrieNode::addFunctionSize(uint32_t FSize) {}

LineLocation ContextTrieNode::getCallSiteLoc() const {}

ContextTrieNode *ContextTrieNode::getParentContext() const {}

void ContextTrieNode::setParentContext(ContextTrieNode *Parent) {}

void ContextTrieNode::setCallSiteLoc(const LineLocation &Loc) {}

void ContextTrieNode::dumpNode() {}

void ContextTrieNode::dumpTree() {}

ContextTrieNode *ContextTrieNode::getOrCreateChildContext(
    const LineLocation &CallSite, FunctionId CalleeName, bool AllowCreate) {}

// Profiler tracker than manages profiles and its associated context
SampleContextTracker::SampleContextTracker(
    SampleProfileMap &Profiles,
    const DenseMap<uint64_t, StringRef> *GUIDToFuncNameMap)
    :{}

void SampleContextTracker::populateFuncToCtxtMap() {}

FunctionSamples *
SampleContextTracker::getCalleeContextSamplesFor(const CallBase &Inst,
                                                 StringRef CalleeName) {}

std::vector<const FunctionSamples *>
SampleContextTracker::getIndirectCalleeContextSamplesFor(
    const DILocation *DIL) {}

FunctionSamples *
SampleContextTracker::getContextSamplesFor(const DILocation *DIL) {}

FunctionSamples *
SampleContextTracker::getContextSamplesFor(const SampleContext &Context) {}

SampleContextTracker::ContextSamplesTy &
SampleContextTracker::getAllContextSamplesFor(const Function &Func) {}

SampleContextTracker::ContextSamplesTy &
SampleContextTracker::getAllContextSamplesFor(StringRef Name) {}

FunctionSamples *SampleContextTracker::getBaseSamplesFor(const Function &Func,
                                                         bool MergeContext) {}

FunctionSamples *SampleContextTracker::getBaseSamplesFor(FunctionId Name,
                                                         bool MergeContext) {}

void SampleContextTracker::markContextSamplesInlined(
    const FunctionSamples *InlinedSamples) {}

ContextTrieNode &SampleContextTracker::getRootContext() {}

void SampleContextTracker::promoteMergeContextSamplesTree(
    const Instruction &Inst, FunctionId CalleeName) {}

ContextTrieNode &SampleContextTracker::promoteMergeContextSamplesTree(
    ContextTrieNode &NodeToPromo) {}

#ifndef NDEBUG
std::string
SampleContextTracker::getContextString(const FunctionSamples &FSamples) const {
  return getContextString(getContextNodeForProfile(&FSamples));
}

std::string
SampleContextTracker::getContextString(ContextTrieNode *Node) const {
  SampleContextFrameVector Res;
  if (Node == &RootContext)
    return std::string();
  Res.emplace_back(Node->getFuncName(), LineLocation(0, 0));

  ContextTrieNode *PreNode = Node;
  Node = Node->getParentContext();
  while (Node && Node != &RootContext) {
    Res.emplace_back(Node->getFuncName(), PreNode->getCallSiteLoc());
    PreNode = Node;
    Node = Node->getParentContext();
  }

  std::reverse(Res.begin(), Res.end());

  return SampleContext::getContextString(Res);
}
#endif

void SampleContextTracker::dump() {}

StringRef SampleContextTracker::getFuncNameFor(ContextTrieNode *Node) const {}

ContextTrieNode *
SampleContextTracker::getContextFor(const SampleContext &Context) {}

ContextTrieNode *
SampleContextTracker::getCalleeContextFor(const DILocation *DIL,
                                          FunctionId CalleeName) {}

ContextTrieNode *SampleContextTracker::getContextFor(const DILocation *DIL) {}

ContextTrieNode *
SampleContextTracker::getOrCreateContextPath(const SampleContext &Context,
                                             bool AllowCreate) {}

ContextTrieNode *
SampleContextTracker::getTopLevelContextNode(FunctionId FName) {}

ContextTrieNode &
SampleContextTracker::addTopLevelContextNode(FunctionId FName) {}

void SampleContextTracker::mergeContextNode(ContextTrieNode &FromNode,
                                            ContextTrieNode &ToNode) {}

ContextTrieNode &SampleContextTracker::promoteMergeContextSamplesTree(
    ContextTrieNode &FromNode, ContextTrieNode &ToNodeParent) {}

void SampleContextTracker::createContextLessProfileMap(
    SampleProfileMap &ContextLessProfiles) {}
} // namespace llvm