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 14 #include "llvm/IR/PassInstrumentation.h" 15 #include "llvm/ADT/STLExtras.h" 16 #include "llvm/IR/PassManager.h" 17 18 namespace llvm { 19 20 void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName, 21 StringRef PassName) { 22 ClassToPassName[ClassName] = PassName.str(); 23 } 24 25 StringRef 26 PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) { 27 return ClassToPassName[ClassName]; 28 } 29 30 AnalysisKey PassInstrumentationAnalysis::Key; 31 32 bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) { 33 size_t Pos = PassID.find('<'); 34 StringRef Prefix = PassID; 35 if (Pos != StringRef::npos) 36 Prefix = PassID.substr(0, Pos); 37 return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); }); 38 } 39 40 } // namespace llvm 41