Add a flag on the context to protect against creation of operations in unregistered dialects

Differential Revision: https://reviews.llvm.org/D76903
This commit is contained in:
Mehdi Amini 2020-03-29 22:35:38 +00:00
parent ced99a1a63
commit bab5bcf8fd
80 changed files with 143 additions and 99 deletions

View File

@ -49,6 +49,12 @@ public:
return static_cast<T *>(getRegisteredDialect(T::getDialectNamespace()));
}
/// Return true if we allow to create operation for unregistered dialects.
bool allowsUnregisteredDialects();
/// Enables creating operations in unregistered dialects.
void allowUnregisteredDialects(bool allow = true);
/// Return information about all registered operations. This isn't very
/// efficient: typically you should ask the operations about their properties
/// directly.

View File

@ -26,6 +26,6 @@ LogicalResult MlirOptMain(llvm::raw_ostream &os,
std::unique_ptr<llvm::MemoryBuffer> buffer,
const PassPipelineCLParser &passPipeline,
bool splitInputFile, bool verifyDiagnostics,
bool verifyPasses);
bool verifyPasses, bool allowUnregisteredDialects);
} // end namespace mlir

View File

@ -198,9 +198,18 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) {
it = dialectAllowsUnknownOps
.try_emplace(dialectPrefix, dialect->allowsUnknownOperations())
.first;
// Otherwise, conservatively allow unknown operations.
else
// Otherwise, unregistered dialects (when allowed by the context)
// conservatively allow unknown operations.
else {
if (!op.getContext()->allowsUnregisteredDialects() && !op.getDialect())
return op.emitOpError()
<< "created with unregistered dialect. If this is "
"intended, please call allowUnregisteredDialects() on the "
"MLIRContext, or use -allow-unregistered-dialect with "
"mlir-opt";
it = dialectAllowsUnknownOps.try_emplace(dialectPrefix, true).first;
}
}
if (!it->second) {

View File

@ -161,6 +161,15 @@ public:
//===--------------------------------------------------------------------===//
DiagnosticEngine diagEngine;
//===--------------------------------------------------------------------===//
// Options
//===--------------------------------------------------------------------===//
/// In most cases, creating operation in unregistered dialect is not desired
/// and indicate a misconfiguration of the compiler. This option enables to
/// detect such use cases
bool allowUnregisteredDialects = false;
//===--------------------------------------------------------------------===//
// Other
//===--------------------------------------------------------------------===//
@ -349,6 +358,14 @@ void Dialect::registerDialect(MLIRContext *context) {
impl.dialects.insert(insertPt, std::move(dialect));
}
bool MLIRContext::allowsUnregisteredDialects() {
return impl->allowUnregisteredDialects;
}
void MLIRContext::allowUnregisteredDialects(bool allowing) {
impl->allowUnregisteredDialects = allowing;
}
/// Return information about all registered operations. This isn't very
/// efficient, typically you should ask the operations about their properties
/// directly.

View File

@ -67,6 +67,7 @@ static LogicalResult performActions(raw_ostream &os, bool verifyDiagnostics,
static LogicalResult processBuffer(raw_ostream &os,
std::unique_ptr<MemoryBuffer> ownedBuffer,
bool verifyDiagnostics, bool verifyPasses,
bool allowUnregisteredDialects,
const PassPipelineCLParser &passPipeline) {
// Tell sourceMgr about this buffer, which is what the parser will pick up.
SourceMgr sourceMgr;
@ -74,6 +75,7 @@ static LogicalResult processBuffer(raw_ostream &os,
// Parse the input file.
MLIRContext context;
context.allowUnregisteredDialects(allowUnregisteredDialects);
// If we are in verify diagnostics mode then we have a lot of work to do,
// otherwise just perform the actions without worrying about it.
@ -100,7 +102,8 @@ LogicalResult mlir::MlirOptMain(raw_ostream &os,
std::unique_ptr<MemoryBuffer> buffer,
const PassPipelineCLParser &passPipeline,
bool splitInputFile, bool verifyDiagnostics,
bool verifyPasses) {
bool verifyPasses,
bool allowUnregisteredDialects) {
// The split-input-file mode is a very specific mode that slices the file
// up into small pieces and checks each independently.
if (splitInputFile)
@ -108,10 +111,11 @@ LogicalResult mlir::MlirOptMain(raw_ostream &os,
std::move(buffer),
[&](std::unique_ptr<MemoryBuffer> chunkBuffer, raw_ostream &os) {
return processBuffer(os, std::move(chunkBuffer), verifyDiagnostics,
verifyPasses, passPipeline);
verifyPasses, allowUnregisteredDialects,
passPipeline);
},
os);
return processBuffer(os, std::move(buffer), verifyDiagnostics, verifyPasses,
passPipeline);
allowUnregisteredDialects, passPipeline);
}

View File

@ -446,7 +446,7 @@ Value Importer::processValue(llvm::Value *value) {
// We don't expect to see instructions in dominator order. If we haven't seen
// this instruction yet, create an unknown op and remap it later.
if (isa<llvm::Instruction>(value)) {
OperationState state(UnknownLoc::get(context), "unknown");
OperationState state(UnknownLoc::get(context), "llvm.unknown");
LLVMType type = processType(value->getType());
if (!type)
return nullptr;

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s --launch-func-to-cuda | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s --launch-func-to-cuda | FileCheck %s
module attributes {gpu.container_module} {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt --convert-gpu-to-nvvm --split-input-file %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect --convert-gpu-to-nvvm --split-input-file %s | FileCheck %s
gpu.module @kernel {
// CHECK-LABEL: llvm.func @private

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s -o - | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s -o - | FileCheck %s
module attributes {gpu.container_module} {
gpu.module @kernels {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -convert-std-to-llvm -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -convert-std-to-llvm -split-input-file -verify-diagnostics | FileCheck %s
// CHECK-LABEL: func @address_space(
// CHECK-SAME: !llvm<"float addrspace(7)*">

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -convert-std-to-spirv %s -o - | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -convert-std-to-spirv %s -o - | FileCheck %s
//===----------------------------------------------------------------------===//
// std arithmetic ops

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -affine-super-vectorizer-test -compose-maps 2>&1 | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -compose-maps 2>&1 | FileCheck %s
// For all these cases, the test traverses the `test_affine_map` ops and
// composes them in order one-by-one.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s
// Affine maps for test case: compose_affine_maps_1dto2d_no_symbols
// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 - 1)>

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s -split-input-file -affine-data-copy-generate -affine-data-copy-generate-dma -affine-data-copy-generate-fast-mem-space=2 -affine-data-copy-generate-skip-non-unit-stride-loops -verify-diagnostics | FileCheck %s
// RUN: mlir-opt %s -split-input-file -affine-data-copy-generate -affine-data-copy-generate-dma -affine-data-copy-generate-fast-mem-capacity=16 -affine-data-copy-generate-fast-mem-space=2 | FileCheck %s --check-prefix FAST-MEM-16KB
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-data-copy-generate -affine-data-copy-generate-dma -affine-data-copy-generate-fast-mem-space=2 -affine-data-copy-generate-skip-non-unit-stride-loops -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-data-copy-generate -affine-data-copy-generate-dma -affine-data-copy-generate-fast-mem-capacity=16 -affine-data-copy-generate-fast-mem-space=2 | FileCheck %s --check-prefix FAST-MEM-16KB
// We run most test cases with -copy-skip-non-unit-stride-loops to allow testing
// DMA generation at inner levels easily - since the DMA generation would

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -inline -mlir-disable-inline-simplify | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -inline -mlir-disable-inline-simplify | FileCheck %s
// Basic test that functions within affine operations are inlined.
func @func_with_affine_ops(%N: index) {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
// -----

View File

@ -1,6 +1,6 @@
// RUN: mlir-opt %s -split-input-file -affine-loop-tile -affine-tile-size=32 | FileCheck %s
// RUN: mlir-opt %s -split-input-file -affine-loop-tile -affine-tile-cache-size=512 | FileCheck %s --check-prefix=MODEL
// RUN: mlir-opt %s -split-input-file -affine-loop-tile -affine-tile-size=32 -affine-tile-separate | FileCheck %s --check-prefix=SEPARATE
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile -affine-tile-size=32 | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile -affine-tile-cache-size=512 | FileCheck %s --check-prefix=MODEL
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile -affine-tile-size=32 -affine-tile-separate | FileCheck %s --check-prefix=SEPARATE
// -----

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt -split-input-file %s | FileCheck %s
// RUN: mlir-opt %s -mlir-print-op-generic | FileCheck -check-prefix=GENERIC %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-op-generic | FileCheck -check-prefix=GENERIC %s
// Check that the attributes for the affine operations are round-tripped.
// Check that `affine.terminator` is visible in the generic form.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-detect-parallel -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -test-detect-parallel -split-input-file -verify-diagnostics | FileCheck %s
// CHECK-LABEL: func @loop_nest_3d_outer_two_parallel
func @loop_nest_3d_outer_two_parallel(%N : index) {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -simplify-affine-structures | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -simplify-affine-structures | FileCheck %s
// CHECK-DAG: [[SET_EMPTY_2D:#set[0-9]+]] = affine_set<(d0, d1) : (1 == 0)>
// CHECK-DAG: #set1 = affine_set<(d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0)>

View File

@ -1,6 +1,6 @@
// RUN: mlir-opt %s -affine-super-vectorizer-test -forward-slicing=true 2>&1 | FileCheck %s --check-prefix=FWD
// RUN: mlir-opt %s -affine-super-vectorizer-test -backward-slicing=true 2>&1 | FileCheck %s --check-prefix=BWD
// RUN: mlir-opt %s -affine-super-vectorizer-test -slicing=true 2>&1 | FileCheck %s --check-prefix=FWDBWD
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -forward-slicing=true 2>&1 | FileCheck %s --check-prefix=FWD
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -backward-slicing=true 2>&1 | FileCheck %s --check-prefix=BWD
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -slicing=true 2>&1 | FileCheck %s --check-prefix=FWDBWD
/// 1 2 3 4
/// |_______| |______|

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s -affine-loop-unroll-jam -unroll-jam-factor=2 | FileCheck %s
// RUN: mlir-opt %s -affine-loop-unroll-jam -unroll-jam-factor=4 | FileCheck --check-prefix=UJAM-FOUR %s
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll-jam -unroll-jam-factor=2 | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll-jam -unroll-jam-factor=4 | FileCheck --check-prefix=UJAM-FOUR %s
// CHECK-DAG: [[MAP_PLUS_1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)>
// CHECK-DAG: [[MAP_DIV_OFFSET:#map[0-9]+]] = affine_map<()[s0] -> (((s0 - 1) floordiv 2) * 2 + 1)>

View File

@ -1,7 +1,7 @@
// RUN: mlir-opt %s -affine-loop-unroll -unroll-full | FileCheck %s --check-prefix UNROLL-FULL
// RUN: mlir-opt %s -affine-loop-unroll -unroll-full -unroll-full-threshold=2 | FileCheck %s --check-prefix SHORT
// RUN: mlir-opt %s -affine-loop-unroll -unroll-factor=4 | FileCheck %s --check-prefix UNROLL-BY-4
// RUN: mlir-opt %s -affine-loop-unroll -unroll-factor=1 | FileCheck %s --check-prefix UNROLL-BY-1
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll -unroll-full | FileCheck %s --check-prefix UNROLL-FULL
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll -unroll-full -unroll-full-threshold=2 | FileCheck %s --check-prefix SHORT
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll -unroll-factor=4 | FileCheck %s --check-prefix UNROLL-BY-4
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll -unroll-factor=1 | FileCheck %s --check-prefix UNROLL-BY-1
// UNROLL-FULL-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)>
// UNROLL-FULL-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
module attributes {gpu.container_module} {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -gpu-kernel-outlining -split-input-file -verify-diagnostics %s | FileCheck %s -dump-input-on-failure
// RUN: mlir-opt -allow-unregistered-dialect -gpu-kernel-outlining -split-input-file -verify-diagnostics %s | FileCheck %s -dump-input-on-failure
// CHECK: module attributes {gpu.container_module}

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -test-gpu-memory-promotion -split-input-file %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -test-gpu-memory-promotion -split-input-file %s | FileCheck %s
module @foo attributes {gpu.kernel_module} {
// Verify that the attribution was indeed introduced

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
// expected-error@+1{{llvm.noalias argument attribute of non boolean type}}
func @invalid_noalias(%arg0: !llvm.i32 {llvm.noalias = 3}) {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
func @loop_for_lb(%arg0: f32, %arg1: index) {
// expected-error@+1 {{operand #0 must be index}}

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(parallel-loop-fusion)' -split-input-file | FileCheck %s --dump-input-on-failure
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(parallel-loop-fusion)' -split-input-file | FileCheck %s --dump-input-on-failure
func @fuse_empty_loops() {
%c2 = constant 2 : index

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file | FileCheck %s
// -----
// CHECK-LABEL: parseFullySpecified

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
// -----
func @invalidStatisticsMismatchedLayerType(%arg0: tensor<8x4x3xf32>) ->

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file | FileCheck %s
// -----
// All per-layer params specified:

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s
// CHECK-LABEL: @source
func @source(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<4xf32>) -> (tensor<4xf32>) {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spv.Branch

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spv.AccessChain

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spv._address_of

View File

@ -47,6 +47,7 @@ static MLIRContext &globalContext() {
}();
(void)init_once;
static thread_local MLIRContext context;
context.allowUnregisteredDialects();
return context;
}

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
// Identity maps used in trivial compositions in MemRefs are optimized away.
// CHECK-NOT: #map{{[0-9]+}} = affine_map<(d0, d1) -> (d0, d1)>

View File

@ -1,8 +1,8 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
// Verify the printed output can be parsed.
// RUN: mlir-opt %s | mlir-opt | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect | FileCheck %s
// Verify the generic form can be parsed.
// RUN: mlir-opt -mlir-print-op-generic %s | mlir-opt | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -mlir-print-op-generic %s | mlir-opt -allow-unregistered-dialect | FileCheck %s
// CHECK: #map0 = affine_map<(d0) -> (d0 + 1)>

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s -verify-diagnostics -split-input-file -mlir-print-elementsattrs-with-hex-if-larger=1 | FileCheck %s --check-prefix=HEX
// RUN: mlir-opt %s -verify-diagnostics -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -verify-diagnostics -split-input-file -mlir-print-elementsattrs-with-hex-if-larger=1 | FileCheck %s --check-prefix=HEX
// RUN: mlir-opt -allow-unregistered-dialect %s -verify-diagnostics -split-input-file | FileCheck %s
// HEX: dense<"0x00000000000024400000000000001440"> : tensor<2xf64>
"foo.op"() {dense.attr = dense<[10.0, 5.0]> : tensor<2xf64>} : () -> ()

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
func @dim(tensor<1xf32>) {
^bb(%0: tensor<1xf32>):

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
// Check different error cases.
// -----

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -mlir-print-debuginfo | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo | FileCheck %s
// This test verifies that debug locations are round-trippable.
#set0 = affine_set<(d0) : (1 == 0)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -mlir-print-debuginfo | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -mlir-print-debuginfo | FileCheck %s
// CHECK: module {
module {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -print-op-stats %s -o=/dev/null 2>&1 | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -print-op-stats %s -o=/dev/null 2>&1 | FileCheck %s
func @main(tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> {
^bb0(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>):

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-opaque-loc -mlir-print-debuginfo | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -test-opaque-loc -mlir-print-debuginfo | FileCheck %s
// This test verifies that debug opaque locations can be printed.
#set0 = affine_set<(d0) : (1 == 0)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
// CHECK-DAG: #map{{[0-9]+}} = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>
#map0 = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -mlir-print-debuginfo -mlir-pretty-debuginfo | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo -mlir-pretty-debuginfo | FileCheck %s
#set0 = affine_set<(d0) : (1 == 0)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
// CHECK-LABEL: func @custom_region_names
func @custom_region_names() -> () {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -mlir-print-local-scope | FileCheck %s --dump-input-on-failure
// RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-local-scope | FileCheck %s --dump-input-on-failure
// CHECK: "foo.op"() : () -> memref<?xf32, affine_map<(d0) -> (d0 * 2)>>
"foo.op"() : () -> (memref<?xf32, affine_map<(d0) -> (2*d0)>>)

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s
//===----------------------------------------------------------------------===//
// Test the number of regions

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s -symbol-dce -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt %s -pass-pipeline="module(symbol-dce)" -split-input-file | FileCheck %s --check-prefix=NESTED
// RUN: mlir-opt -allow-unregistered-dialect %s -symbol-dce -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="module(symbol-dce)" -split-input-file | FileCheck %s --check-prefix=NESTED
// Check that trivially dead and trivially live non-nested cases are handled.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-symbol-rauw -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-rauw -split-input-file | FileCheck %s
// Symbol references to the module itself don't affect uses of symbols within
// its table.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-symbol-uses -split-input-file -verify-diagnostics
// RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-uses -split-input-file -verify-diagnostics
// Symbol references to the module itself don't affect uses of symbols within
// its table.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s
// CHECK: succeededSameOperandsElementType
func @succeededSameOperandsElementType(%t10x10 : tensor<10x10xf32>, %t1f: tensor<1xf32>, %v1: vector<1xf32>, %t1i: tensor<1xi32>, %sf: f32) {

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s | FileCheck %s
// RUN: mlir-opt -mlir-print-op-generic -mlir-print-debuginfo %s | FileCheck %s --check-prefix=CHECK-GENERIC
// RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -mlir-print-op-generic -mlir-print-debuginfo %s | FileCheck %s --check-prefix=CHECK-GENERIC
// CHECK-LABEL: func @wrapping_op
// CHECK-GENERIC: "func"

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s --dump-input=fail
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s --dump-input=fail
// Test case: Simple case of deleting a dead pure op.

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(canonicalize)' -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(canonicalize)' -split-input-file | FileCheck %s
// CHECK-LABEL: func @test_subi_zero
func @test_subi_zero(%arg0: i32) -> i32 {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -test-constant-fold | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -test-constant-fold | FileCheck %s
// -----

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(cse)' | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(cse)' | FileCheck %s
// CHECK-DAG: #map0 = affine_map<(d0) -> (d0 mod 2)>
#map0 = affine_map<(d0) -> (d0 mod 2)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -inline | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -inline | FileCheck %s
// This file tests the callgraph dead code elimination performed by the inliner.

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt -snapshot-op-locations='filename=%/t' -mlir-print-debuginfo %s | FileCheck %s -DFILE=%/t
// RUN: mlir-opt -snapshot-op-locations='filename=%/t tag='tagged'' -mlir-print-debuginfo %s | FileCheck %s --check-prefix=TAG -DFILE=%/t
// RUN: mlir-opt -allow-unregistered-dialect -snapshot-op-locations='filename=%/t' -mlir-print-debuginfo %s | FileCheck %s -DFILE=%/t
// RUN: mlir-opt -allow-unregistered-dialect -snapshot-op-locations='filename=%/t tag='tagged'' -mlir-print-debuginfo %s | FileCheck %s --check-prefix=TAG -DFILE=%/t
// CHECK-LABEL: func @function
// CHECK-NEXT: loc("[[FILE]]":{{[0-9]+}}:{{[0-9]+}})

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -loop-coalescing %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -loop-coalescing %s | FileCheck %s
// CHECK-LABEL: @one_3d_nest
func @one_3d_nest() {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-loop-fusion -test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-fusion -test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
// -----

View File

@ -1,5 +1,5 @@
// RUN: mlir-opt %s -affine-loop-fusion -split-input-file | FileCheck %s
// RUN: mlir-opt %s -affine-loop-fusion -fusion-maximal -split-input-file | FileCheck %s --check-prefix=MAXIMAL
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion -split-input-file | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion -fusion-maximal -split-input-file | FileCheck %s --check-prefix=MAXIMAL
// TODO(andydavis) Add more tests:
// *) Add nested fusion test cases when non-constant loop bound support is

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -memref-dataflow-opt | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -memref-dataflow-opt | FileCheck %s
// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> (d1 + 1)>
// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (d0)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(parallel-loop-collapsing{collapsed-indices-0=0,3 collapsed-indices-1=1,4 collapsed-indices-2=2}, canonicalize)' | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(parallel-loop-collapsing{collapsed-indices-0=0,3 collapsed-indices-1=1,4 collapsed-indices-2=2}, canonicalize)' | FileCheck %s
// CHECK-LABEL: func @parallel_many_dims() {
func @parallel_many_dims() {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -test-mapping-to-processing-elements %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -test-mapping-to-processing-elements %s | FileCheck %s
// CHECK-LABEL: @map1d
// CHECK: (%[[lb:.*]]: index, %[[ub:.*]]: index, %[[step:.*]]: index) {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -split-input-file -affine-pipeline-data-transfer | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-pipeline-data-transfer | FileCheck %s
// -----

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(parallel-loop-collapsing{collapsed-indices-0=0,1}, canonicalize)' | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(parallel-loop-collapsing{collapsed-indices-0=0,1}, canonicalize)' | FileCheck %s
// CHECK-LABEL: func @collapse_to_single() {
func @collapse_to_single() {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -mlir-print-debuginfo -strip-debuginfo | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo -strip-debuginfo | FileCheck %s
// This test verifies that debug locations are stripped.
#set0 = affine_set<(d0) : (1 == 0)>

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -pass-pipeline='func(canonicalize)' | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(canonicalize)' | FileCheck %s
// CHECK-LABEL: func @remove_op_with_inner_ops_pattern
func @remove_op_with_inner_ops_pattern() {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s -test-inline | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -test-inline | FileCheck %s
// CHECK-LABEL: func @inline_with_arg
func @inline_with_arg(%arg0 : i32) -> i32 {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -test-legalize-patterns -verify-diagnostics -test-legalize-mode=analysis %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -test-legalize-patterns -verify-diagnostics -test-legalize-mode=analysis %s | FileCheck %s
// expected-remark@-2 {{op 'module' is legalizable}}
// expected-remark@-3 {{op 'module_terminator' is legalizable}}

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -test-legalize-patterns -test-legalize-mode=full -split-input-file -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -test-legalize-patterns -test-legalize-mode=full -split-input-file -verify-diagnostics %s | FileCheck %s
// CHECK-LABEL: func @multi_level_mapping
func @multi_level_mapping() {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt -split-input-file -test-legalize-patterns -verify-diagnostics %s | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -test-legalize-patterns -verify-diagnostics %s | FileCheck %s
// CHECK-LABEL: verifyDirectPattern
func @verifyDirectPattern() -> i32 {

View File

@ -1,4 +1,4 @@
// RUN: mlir-opt %s | mlir-opt -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect -verify-diagnostics | FileCheck %s
// CHECK: %[[I64:.*]] =
%i64 = "foo.op"() : () -> (i64)

View File

@ -85,6 +85,10 @@ static cl::opt<bool>
cl::desc("Run the verifier after each transformation pass"),
cl::init(true));
static cl::opt<bool> allowUnregisteredDialects(
"allow-unregistered-dialect",
cl::desc("Allow operation with no registered dialects"), cl::init(false));
void registerTestPasses() {
registerConvertToTargetEnvPass();
registerInliner();
@ -163,5 +167,6 @@ int main(int argc, char **argv) {
}
return failed(MlirOptMain(output->os(), std::move(file), passPipeline,
splitInputFile, verifyDiagnostics, verifyPasses));
splitInputFile, verifyDiagnostics, verifyPasses,
allowUnregisteredDialects));
}

View File

@ -73,6 +73,7 @@ int main(int argc, char **argv) {
auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
raw_ostream &os) {
MLIRContext context;
context.allowUnregisteredDialects();
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());

View File

@ -14,15 +14,16 @@
using namespace mlir;
using namespace mlir::detail;
namespace {
Operation *createOp(MLIRContext *context, bool resizableOperands,
ArrayRef<Value> operands = llvm::None,
ArrayRef<Type> resultTypes = llvm::None) {
static Operation *createOp(MLIRContext *context, bool resizableOperands,
ArrayRef<Value> operands = llvm::None,
ArrayRef<Type> resultTypes = llvm::None) {
context->allowUnregisteredDialects();
return Operation::create(
UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes,
operands, llvm::None, llvm::None, 0, resizableOperands);
}
namespace {
TEST(OperandStorageTest, NonResizable) {
MLIRContext context;
Builder builder(&context);