PassInstrumentation.cpp 1.4 KB

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