Path: blob/main/contrib/llvm-project/llvm/lib/Transforms/Utils/CountVisits.cpp
35271 views
//===- CountVisits.cpp ----------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/Transforms/Utils/CountVisits.h"9#include "llvm/ADT/Statistic.h"10#include "llvm/IR/Function.h"11#include "llvm/IR/PassManager.h"1213using namespace llvm;1415#define DEBUG_TYPE "count-visits"1617STATISTIC(MaxVisited, "Max number of times we visited a function");1819PreservedAnalyses CountVisitsPass::run(Function &F, FunctionAnalysisManager &) {20uint32_t Count = Counts[F.getName()] + 1;21Counts[F.getName()] = Count;22if (Count > MaxVisited)23MaxVisited = Count;24return PreservedAnalyses::all();25}262728