mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
6cdbedb38b
To support options like -print-before=<pass> and -print-after=<pass> the PassBuilder will register PassInstrumentation callbacks as well as a mapping between internal pass class names and the pass names used in those options (and other cmd line interfaces). But for some reason all the passes that takes options where missing in those maps, so for example "-print-after=loop-vectorize" didn't work. This patch will add the missing entries by also taking care of function and loop passes with params when setting up the class to pass name maps. One might notice that even with this patch it might be tricky to know what pass name to use in options such as -print-after. This because there only is a single mapping from class name to pass name, while the PassRegistry currently is a bit messy as it sometimes reuses the same class for different pass names (without using the "pass with params" scheme, or the pass-name<variant> syntax). It gets extra messy in some situations. For example the MemorySanitizerPass can run like this (with debug and print-after) opt -passes='kmsan' -print-after=msan-module -debug-only=msan The 'kmsan' alias for 'msan<kernel>' is just confusing as one might think that 'kmsan' is a separate pass (but the DEBUG_TYPE is still just 'msan'). And since the module pass version of the pass adds a mapping from 'MemorySanitizerPass' to 'msan-module' one need to use 'msan-module' in the print-before and print-after options. Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D105006
42 lines
1.4 KiB
C++
42 lines
1.4 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 {
|
|
|
|
void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
|
|
StringRef PassName) {
|
|
if (ClassToPassName[ClassName].empty())
|
|
ClassToPassName[ClassName] = PassName.str();
|
|
}
|
|
|
|
StringRef
|
|
PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) {
|
|
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.endswith(S); });
|
|
}
|
|
|
|
} // namespace llvm
|