1 //===- PassInstrumentation.cpp - Pass Instrumentation interface -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// This file provides the implementation of PassInstrumentation class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/IR/PassInstrumentation.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/IR/PassManager.h"
20 void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName
,
22 if (ClassToPassName
[ClassName
].empty())
23 ClassToPassName
[ClassName
] = PassName
.str();
27 PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName
) {
28 return ClassToPassName
[ClassName
];
31 AnalysisKey
PassInstrumentationAnalysis::Key
;
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
,
39 [Prefix
](StringRef S
) { return Prefix
.ends_with(S
); });