diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -745,9 +745,17 @@ // Initialize the op specific pass pipelines. llvm::StringMap pipelines; - for (OpPassManager pipeline : opPipelineList) - if (!pipeline.empty()) - pipelines.try_emplace(pipeline.getOpName(), pipeline); + for (OpPassManager pipeline : opPipelineList) { + if (pipeline.empty()) + continue; + auto it = pipelines.try_emplace(pipeline.getOpName(), pipeline); + if (!it.second) { + llvm::errs() + << "Inliner: Registering duplicate simplification pipeline for op '" + << it.first->getKey() << "'\n"; + return failure(); + } + } opPipelines.assign({std::move(pipelines)}); return success(); diff --git a/mlir/test/Transforms/inlining.mlir b/mlir/test/Transforms/inlining.mlir --- a/mlir/test/Transforms/inlining.mlir +++ b/mlir/test/Transforms/inlining.mlir @@ -3,6 +3,9 @@ // RUN: mlir-opt %s -inline='default-pipeline=''' -mlir-print-debuginfo -mlir-print-local-scope | FileCheck %s --check-prefix INLINE-LOC // RUN: mlir-opt %s -inline | FileCheck %s --check-prefix INLINE_SIMPLIFY // RUN: mlir-opt %s -inline='op-pipelines=func.func(canonicalize,cse)' | FileCheck %s --check-prefix INLINE_SIMPLIFY +// RUN: not mlir-opt %s -inline='op-pipelines=func.func(canonicalize),func.func(cse)' 2>&1 | FileCheck %s --check-prefix ERROR_DUPLICATE_PIPELINE + +// ERROR_DUPLICATE_PIPELINE: Inliner: Registering duplicate simplification pipeline for op 'func.func' // Inline a function that takes an argument. func @func_with_arg(%c : i32) -> i32 {