Skip to content

Commit

Permalink
Revert "Add a breakpoint manager that matches based on File/Line/Col …
Browse files Browse the repository at this point in the history
…Locations"

This reverts commit d09c805.

This is broken on Windows
  • Loading branch information
joker-eph committed Apr 22, 2023
1 parent 1da0da9 commit 6fb4c9f
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 557 deletions.

This file was deleted.

10 changes: 0 additions & 10 deletions mlir/include/mlir/Debug/Observers/ActionLogging.h
Expand Up @@ -30,21 +30,11 @@ struct ActionLogger : public ExecutionContext::Observer {
bool willExecute) override;
void afterExecute(const ActionActiveStack *action) override;

/// If one of multiple breakpoint managers are set, only actions that are
/// matching a breakpoint will be logged.
void addBreakpointManager(const BreakpointManager *manager) {
breakpointManagers.push_back(manager);
}

private:
/// Check if we should log this action or not.
bool shouldLog(const ActionActiveStack *action);

raw_ostream &os;
bool printActions;
bool printBreakpoints;
bool printIRUnits;
std::vector<const BreakpointManager *> breakpointManagers;
};

} // namespace tracing
Expand Down
19 changes: 0 additions & 19 deletions mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
Expand Up @@ -13,7 +13,6 @@
#ifndef MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H
#define MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H

#include "mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/StringRef.h"

Expand All @@ -30,9 +29,6 @@ namespace mlir {
class DialectRegistry;
class PassPipelineCLParser;
class PassManager;
namespace tracing {
class FileLineColLocBreakpointManager;
}

/// Configuration options for the mlir-opt tool.
/// This is intended to help building tools like mlir-opt by collecting the
Expand Down Expand Up @@ -86,18 +82,6 @@ class MlirOptMainConfig {
/// Get the filename to use for logging actions.
StringRef getLogActionsTo() const { return logActionsToFlag; }

/// Set a location breakpoint manager to filter out action logging based on
/// the attached IR location in the Action context. Ownership stays with the
/// caller.
void addLogActionLocFilter(tracing::BreakpointManager *breakpointManager) {
logActionLocationFilter.push_back(breakpointManager);
}

/// Get the location breakpoint managers to use to filter out action logging.
ArrayRef<tracing::BreakpointManager *> getLogActionsLocFilters() const {
return logActionLocationFilter;
}

/// Set the callback to populate the pass manager.
MlirOptMainConfig &
setPassPipelineSetupFn(std::function<LogicalResult(PassManager &)> callback) {
Expand Down Expand Up @@ -176,9 +160,6 @@ class MlirOptMainConfig {
/// Log action execution to the given file (or "-" for stdout)
std::string logActionsToFlag;

/// Location Breakpoints to filter the action logging.
std::vector<tracing::BreakpointManager *> logActionLocationFilter;

/// The callback to populate the pass manager.
std::function<LogicalResult(PassManager &)> passPipelineCallback;

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion mlir/lib/Debug/CMakeLists.txt
Expand Up @@ -3,7 +3,6 @@ add_subdirectory(Observers)
add_mlir_library(MLIRDebug
DebugCounter.cpp
ExecutionContext.cpp
BreakpointManagers/FileLineColLocBreakpointManager.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Debug
Expand Down
15 changes: 0 additions & 15 deletions mlir/lib/Debug/Observers/ActionLogging.cpp
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "mlir/Debug/Observers/ActionLogging.h"
#include "mlir/Debug/BreakpointManager.h"
#include "mlir/IR/Action.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
Expand All @@ -19,20 +18,8 @@ using namespace mlir::tracing;
// ActionLogger
//===----------------------------------------------------------------------===//

bool ActionLogger::shouldLog(const ActionActiveStack *action) {
// If some condition was set, we ensured it is met before logging.
if (breakpointManagers.empty())
return true;
return llvm::any_of(breakpointManagers,
[&](const BreakpointManager *manager) {
return manager->match(action->getAction());
});
}

void ActionLogger::beforeExecute(const ActionActiveStack *action,
Breakpoint *breakpoint, bool willExecute) {
if (!shouldLog(action))
return;
SmallVector<char> name;
llvm::get_thread_name(name);
if (name.empty()) {
Expand Down Expand Up @@ -64,8 +51,6 @@ void ActionLogger::beforeExecute(const ActionActiveStack *action,
}

void ActionLogger::afterExecute(const ActionActiveStack *action) {
if (!shouldLog(action))
return;
SmallVector<char> name;
llvm::get_thread_name(name);
if (name.empty()) {
Expand Down
35 changes: 0 additions & 35 deletions mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
Expand Up @@ -32,7 +32,6 @@
#include "mlir/Tools/ParseUtilities.h"
#include "mlir/Tools/Plugins/DialectPlugin.h"
#include "mlir/Tools/Plugins/PassPlugin.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/InitLLVM.h"
Expand Down Expand Up @@ -82,33 +81,6 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
" '-' is passed"),
cl::location(logActionsToFlag)};

static cl::list<std::string> logActionLocationFilter(
"log-mlir-actions-filter",
cl::desc(
"Comma separated list of locations to filter actions from logging"),
cl::CommaSeparated,
cl::cb<void, std::string>([&](const std::string &location) {
static bool register_once = [&] {
addLogActionLocFilter(&locBreakpointManager);
return true;
}();
(void)register_once;
static std::vector<std::string> locations;
locations.push_back(location);
StringRef locStr = locations.back();

// Parse the individual location filters and set the breakpoints.
auto diag = [](Twine msg) { llvm::errs() << msg << "\n"; };
auto locBreakpoint =
tracing::FileLineColLocBreakpoint::parseFromString(locStr, diag);
if (failed(locBreakpoint)) {
llvm::errs() << "Invalid location filter: " << locStr << "\n";
exit(1);
}
auto [file, line, col] = *locBreakpoint;
locBreakpointManager.addBreakpoint(file, line, col);
}));

static cl::opt<bool, /*ExternalStorage=*/true> showDialects(
"show-dialects",
cl::desc("Print the list of registered dialects and exit"),
Expand Down Expand Up @@ -158,9 +130,6 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
/// Pointer to static dialectPlugins variable in constructor, needed by
/// setDialectPluginsCallback(DialectRegistry&).
cl::list<std::string> *dialectPlugins = nullptr;

/// The breakpoint manager for the log action location filter.
tracing::FileLineColLocBreakpointManager locBreakpointManager;
};
} // namespace

Expand Down Expand Up @@ -230,8 +199,6 @@ class InstallDebugHandler {
logActionsFile->keep();
raw_fd_ostream &logActionsStream = logActionsFile->os();
actionLogger = std::make_unique<tracing::ActionLogger>(logActionsStream);
for (const auto *locationBreakpoint : config.getLogActionsLocFilters())
actionLogger->addBreakpointManager(locationBreakpoint);

executionContext.registerObserver(actionLogger.get());
context.registerActionHandler(executionContext);
Expand All @@ -240,8 +207,6 @@ class InstallDebugHandler {
private:
std::unique_ptr<llvm::ToolOutputFile> logActionsFile;
std::unique_ptr<tracing::ActionLogger> actionLogger;
std::vector<std::unique_ptr<tracing::FileLineColLocBreakpoint>>
locationBreakpoints;
tracing::ExecutionContext executionContext;
};

Expand Down

0 comments on commit 6fb4c9f

Please sign in to comment.