[win/asan] GetInstructionSize: Fix `83 E4 XX` to return 3. (#119644)
[llvm-project.git] / llvm / lib / Transforms / Utils / CountVisits.cpp
blobf22880bc9a6619529b188b9afba17e35d30fce93
1 //===- CountVisits.cpp ----------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Transforms/Utils/CountVisits.h"
10 #include "llvm/ADT/Statistic.h"
11 #include "llvm/IR/Function.h"
12 #include "llvm/IR/PassManager.h"
14 using namespace llvm;
16 #define DEBUG_TYPE "count-visits"
18 STATISTIC(MaxVisited, "Max number of times we visited a function");
20 PreservedAnalyses CountVisitsPass::run(Function &F, FunctionAnalysisManager &) {
21 uint32_t Count = Counts[F.getName()] + 1;
22 Counts[F.getName()] = Count;
23 if (Count > MaxVisited)
24 MaxVisited = Count;
25 return PreservedAnalyses::all();