LLVM  14.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 
18 namespace llvm {
19 
22  if (ClassToPassName[ClassName].empty())
23  ClassToPassName[ClassName] = PassName.str();
24 }
25 
28  return ClassToPassName[ClassName];
29 }
30 
31 AnalysisKey PassInstrumentationAnalysis::Key;
32 
33 bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
34  size_t Pos = PassID.find('<');
35  StringRef Prefix = PassID;
36  if (Pos != StringRef::npos)
37  Prefix = PassID.substr(0, Pos);
38  return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); });
39 }
40 
41 } // namespace llvm
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:60
llvm::StringRef::find
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:315
STLExtras.h
llvm::PassInstrumentationCallbacks::getPassNameForClassName
StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name.
Definition: PassInstrumentation.cpp:27
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:611
PassInstrumentation.h
llvm::isSpecialPass
bool isSpecialPass(StringRef PassID, const std::vector< StringRef > &Specials)
Definition: PassInstrumentation.cpp:33
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:72
llvm::PassInstrumentationCallbacks::addClassToPassName
void addClassToPassName(StringRef ClassName, StringRef PassName)
Add a class name to pass name mapping for use by pass instrumentation.
Definition: PassInstrumentation.cpp:20
llvm::any_of
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:1554
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:254
PassManager.h
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:669