[mlir] Include anchor op in reproducer pipeline string

Including the anchor op ensures that all pass manager settings are fully
specified, and makes the string consistent with the printed form.

Depends on D134622

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134623
This commit is contained in:
rkayaith 2022-09-20 20:20:44 -04:00
parent d7f0f4a0a2
commit d511a5d471
5 changed files with 21 additions and 12 deletions

View File

@ -1328,7 +1328,7 @@ module {
{-#
external_resources: {
mlir_reproducer: {
pipeline: "func.func(cse,canonicalize),inline",
pipeline: "builtin.module(func.func(cse,canonicalize),inline)",
disable_threading: true,
verify_each: true
}
@ -1371,7 +1371,7 @@ module {
{-#
external_resources: {
mlir_reproducer: {
pipeline: "func.func(canonicalize)",
pipeline: "builtin.module(func.func(canonicalize))",
disable_threading: true,
verify_each: true
}

View File

@ -60,7 +60,7 @@ private:
static void registerSignalHandler();
/// The textual description of the currently executing pipeline.
std::string pipeline;
std::string pipelineElements;
/// The MLIR operation representing the IR before the crash.
Operation *preCrashOperation;
@ -93,8 +93,8 @@ llvm::ManagedStatic<llvm::SmallSetVector<RecoveryReproducerContext *, 1>>
RecoveryReproducerContext::RecoveryReproducerContext(
std::string passPipelineStr, Operation *op,
PassManager::ReproducerStreamFactory &streamFactory, bool verifyPasses)
: pipeline(std::move(passPipelineStr)), preCrashOperation(op->clone()),
streamFactory(streamFactory),
: pipelineElements(std::move(passPipelineStr)),
preCrashOperation(op->clone()), streamFactory(streamFactory),
disableThreads(!op->getContext()->isMultithreadingEnabled()),
verifyPasses(verifyPasses) {
enable();
@ -118,6 +118,9 @@ void RecoveryReproducerContext::generate(std::string &description) {
}
descOS << "reproducer generated at `" << stream->description() << "`";
std::string pipeline = (preCrashOperation->getName().getStringRef() + "(" +
pipelineElements + ")")
.str();
AsmState state(preCrashOperation);
state.attachResourcePrinter(
"mlir_reproducer", [&](Operation *op, AsmResourceBuilder &builder) {
@ -470,9 +473,12 @@ void PassReproducerOptions::attachResourceParser(ParserConfig &config) {
}
LogicalResult PassReproducerOptions::apply(PassManager &pm) const {
if (pipeline.has_value())
if (failed(parsePassPipeline(*pipeline, pm)))
if (pipeline.has_value()) {
FailureOr<OpPassManager> reproPm = parsePassPipeline(*pipeline);
if (failed(reproPm))
return failure();
static_cast<OpPassManager &>(pm) = std::move(*reproPm);
}
if (disableThreading.has_value())
pm.getContext()->disableMultithreading(*disableThreading);

View File

@ -15,4 +15,4 @@ module @inner_mod1 {
// REPRO_LOCAL_DYNAMIC_FAILURE: module @inner_mod1
// REPRO_LOCAL_DYNAMIC_FAILURE: module @foo {
// REPRO_LOCAL_DYNAMIC_FAILURE: pipeline: "builtin.module(test-pass-failure)"
// REPRO_LOCAL_DYNAMIC_FAILURE: pipeline: "builtin.module(builtin.module(test-pass-failure))"

View File

@ -22,12 +22,12 @@ module @inner_mod1 {
// REPRO: module @inner_mod1
// REPRO: module @foo {
// REPRO: pipeline: "builtin.module(test-module-pass,test-pass-crash)"
// REPRO: pipeline: "builtin.module(builtin.module(test-module-pass,test-pass-crash))"
// REPRO_LOCAL: module @inner_mod1
// REPRO_LOCAL: module @foo {
// REPRO_LOCAL: pipeline: "builtin.module(test-pass-crash)"
// REPRO_LOCAL: pipeline: "builtin.module(builtin.module(test-pass-crash))"
// REPRO_LOCAL_DYNAMIC: module @inner_mod1
// REPRO_LOCAL_DYNAMIC: module @foo {
// REPRO_LOCAL_DYNAMIC: pipeline: "builtin.module(test-pass-crash)"
// REPRO_LOCAL_DYNAMIC: pipeline: "builtin.module(builtin.module(test-pass-crash))"

View File

@ -1,3 +1,4 @@
// RUN: mlir-opt %s -dump-pass-pipeline 2>&1 | FileCheck %s
// RUN: mlir-opt %s -mlir-print-ir-before=cse 2>&1 | FileCheck -check-prefix=BEFORE %s
func.func @foo() {
@ -12,7 +13,9 @@ func.func @bar() {
{-#
external_resources: {
mlir_reproducer: {
pipeline: "func.func(cse,canonicalize)",
verify_each: true,
// CHECK: builtin.module(func.func(cse,canonicalize{ max-iterations=1 region-simplify=false top-down=false}))
pipeline: "builtin.module(func.func(cse,canonicalize{max-iterations=1 region-simplify=false top-down=false}))",
disable_threading: true
}
}