2018-09-20 19:08:45 +02:00
|
|
|
//===- PassInstrumentation.cpp - Pass Instrumentation interface -*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-09-20 19:08:45 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// This file provides the implementation of PassInstrumentation class.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/IR/PassInstrumentation.h"
|
2020-07-29 02:08:24 +02:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2018-09-20 19:08:45 +02:00
|
|
|
#include "llvm/IR/PassManager.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2020-12-03 19:59:10 +01:00
|
|
|
void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
|
|
|
|
StringRef PassName) {
|
2021-06-28 00:22:11 +02:00
|
|
|
if (ClassToPassName[ClassName].empty())
|
|
|
|
ClassToPassName[ClassName] = PassName.str();
|
2020-12-03 19:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef
|
|
|
|
PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) {
|
|
|
|
return ClassToPassName[ClassName];
|
|
|
|
}
|
|
|
|
|
2018-09-20 19:08:45 +02:00
|
|
|
AnalysisKey PassInstrumentationAnalysis::Key;
|
|
|
|
|
2020-07-29 02:08:24 +02:00
|
|
|
bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
|
|
|
|
size_t Pos = PassID.find('<');
|
2020-11-16 20:47:50 +01:00
|
|
|
StringRef Prefix = PassID;
|
|
|
|
if (Pos != StringRef::npos)
|
|
|
|
Prefix = PassID.substr(0, Pos);
|
2020-07-29 02:08:24 +02:00
|
|
|
return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); });
|
|
|
|
}
|
|
|
|
|
2018-09-20 19:08:45 +02:00
|
|
|
} // namespace llvm
|