LLVM 24.0.0git
LastRunTrackingAnalysis.cpp
Go to the documentation of this file.
1//===- LastRunTrackingAnalysis.cpp - Avoid running redundant pass -*- C++ -*-=//
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//===----------------------------------------------------------------------===//
8//
9// This is an analysis pass to track a set of passes that have been run, so that
10// we can avoid running a pass again if there is no change since the last run of
11// the pass.
12//
13//===----------------------------------------------------------------------===//
14
16#include "AnalysisOptions.h"
17#include "llvm/ADT/Statistic.h"
18
19using namespace llvm;
20
21#define DEBUG_TYPE "last-run-tracking"
22STATISTIC(NumSkippedPasses, "Number of skipped passes");
23STATISTIC(NumLRTQueries, "Number of LastRunTracking queries");
24
25bool LastRunTrackingInfo::shouldSkipImpl(PassID ID, OptionPtr Ptr) const {
26 if (!Opts.enable_last_run_tracking)
27 return false;
28 ++NumLRTQueries;
29 auto Iter = TrackedPasses.find(ID);
30 if (Iter == TrackedPasses.end())
31 return false;
32 if (!Iter->second || Iter->second(Ptr)) {
33 ++NumSkippedPasses;
34 return true;
35 }
36 return false;
37}
38
39void LastRunTrackingInfo::updateImpl(PassID ID, bool Changed,
40 CompatibilityCheckFn CheckFn) {
41 if (Changed)
42 TrackedPasses.clear();
43 TrackedPasses[ID] = std::move(CheckFn);
44}
45
46AnalysisKey LastRunTrackingAnalysis::Key;
47
52
#define F(x, y, z)
Definition MD5.cpp:54
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:766
iterator end()
Definition DenseMap.h:686
LLVM_ABI LastRunTrackingInfo run(Function &F, FunctionAnalysisManager &)
This class is used to track the last run of a set of module/function passes.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
This is an optimization pass for GlobalISel generic memory operations.
const AnalysisOptions & getAnalysisOptions(const LLVMContext &C)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29