mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 06:56:06 +00:00

This is part of the effort to support for enabling plugins on windows by adding better support for building llvm as a DLL. The export macros used here were added in #96630 Since shared library symbols aren't deduplicated across multiple libraries on windows like Linux we have to manually explicitly import and export `Any::TypeId` template instantiations for the uses of `llvm::Any` in the LLVM codebase to support LLVM Windows shared library builds. This change ensures that external code, including LLVM's own tests, can use PassManager callbacks when LLVM is built as a DLL. I also removed the only use of llvm::Any for LoopNest that only existed in debug code and there also doesn't seem to be any code creating `Any<LoopNest>`
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
//===- PassInstrumentation.cpp - Pass Instrumentation interface -*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
///
|
|
/// This file provides the implementation of PassInstrumentation class.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/PassInstrumentation.h"
|
|
#include "llvm/ADT/STLExtras.h"
|
|
#include "llvm/IR/PassManager.h"
|
|
|
|
namespace llvm {
|
|
|
|
template struct LLVM_EXPORT_TEMPLATE Any::TypeId<const Module *>;
|
|
template struct LLVM_EXPORT_TEMPLATE Any::TypeId<const Function *>;
|
|
template struct LLVM_EXPORT_TEMPLATE Any::TypeId<const Loop *>;
|
|
|
|
void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
|
|
StringRef PassName) {
|
|
ClassToPassName.try_emplace(ClassName, PassName.str());
|
|
}
|
|
|
|
StringRef
|
|
PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) {
|
|
if (!ClassToPassNameCallbacks.empty()) {
|
|
for (auto &Fn : ClassToPassNameCallbacks)
|
|
Fn();
|
|
ClassToPassNameCallbacks.clear();
|
|
}
|
|
return ClassToPassName[ClassName];
|
|
}
|
|
|
|
AnalysisKey PassInstrumentationAnalysis::Key;
|
|
|
|
bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
|
|
size_t Pos = PassID.find('<');
|
|
StringRef Prefix = PassID;
|
|
if (Pos != StringRef::npos)
|
|
Prefix = PassID.substr(0, Pos);
|
|
return any_of(Specials,
|
|
[Prefix](StringRef S) { return Prefix.ends_with(S); });
|
|
}
|
|
|
|
} // namespace llvm
|