LLVM 20.0.0git
PassInstrumentation.cpp
Go to the documentation of this file.
1//===- PassInstrumentation.cpp - Pass Instrumentation interface -*- 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/// \file
9///
10/// This file provides the implementation of PassInstrumentation class.
11///
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/STLExtras.h"
16#include "llvm/IR/PassManager.h"
17
18namespace llvm {
19
22 ClassToPassName.try_emplace(ClassName, PassName.str());
23}
24
27 if (!ClassToPassNameCallbacks.empty()) {
28 for (auto &Fn : ClassToPassNameCallbacks)
29 Fn();
30 ClassToPassNameCallbacks.clear();
31 }
32 return ClassToPassName[ClassName];
33}
34
35AnalysisKey PassInstrumentationAnalysis::Key;
36
37bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
38 size_t Pos = PassID.find('<');
39 StringRef Prefix = PassID;
40 if (Pos != StringRef::npos)
41 Prefix = PassID.substr(0, Pos);
42 return any_of(Specials,
43 [Prefix](StringRef S) { return Prefix.ends_with(S); });
44}
45
46} // namespace llvm
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
This header defines various interfaces for pass management in LLVM.
This file contains some templates that are useful if you are working with the STL at all.
static const char PassName[]
StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name.
void addClassToPassName(StringRef ClassName, StringRef PassName)
Add a class name to pass name mapping for use by pass instrumentation.
bool empty() const
Definition: SmallVector.h:94
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:556
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:282
static constexpr size_t npos
Definition: StringRef.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1729
bool isSpecialPass(StringRef PassID, const std::vector< StringRef > &Specials)
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28