Skip to content

Commit 872ec70

Browse files
author
git apple-llvm automerger
committed
Merge commit '0f9e6451a836' from llvm.org/main into apple/main
2 parents e19ea0c + 0f9e645 commit 872ec70

File tree

12 files changed

+38
-13
lines changed

12 files changed

+38
-13
lines changed

mlir/lib/IR/BuiltinAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ LogicalResult OpaqueAttr::verify(function_ref<InFlightDiagnostic()> emitError,
360360
<< " attribute created with unregistered dialect. If this is "
361361
"intended, please call allowUnregisteredDialects() on the "
362362
"MLIRContext, or use -allow-unregistered-dialect with "
363-
"mlir-opt";
363+
"the MLIR opt tool used";
364364
}
365365

366366
return success();

mlir/lib/IR/BuiltinTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ LogicalResult OpaqueType::verify(function_ref<InFlightDiagnostic()> emitError,
264264
<< "` type created with unregistered dialect. If this is "
265265
"intended, please call allowUnregisteredDialects() on the "
266266
"MLIRContext, or use -allow-unregistered-dialect with "
267-
"mlir-opt";
267+
"the MLIR opt tool used";
268268
}
269269

270270
return success();

mlir/lib/IR/Operation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ Operation::Operation(Location location, OperationName name, unsigned numResults,
176176
numRegions(numRegions), hasOperandStorage(hasOperandStorage), name(name),
177177
attrs(attributes) {
178178
assert(attributes && "unexpected null attribute dictionary");
179+
#ifndef NDEBUG
180+
if (!getDialect() && !getContext()->allowsUnregisteredDialects())
181+
llvm::report_fatal_error(
182+
name.getStringRef() +
183+
" created with unregistered dialect. If this is intended, please call "
184+
"allowUnregisteredDialects() on the MLIRContext, or use "
185+
"-allow-unregistered-dialect with the MLIR opt tool used");
186+
#endif
179187
}
180188

181189
// Operations are deleted through the destroy() member because they are

mlir/lib/IR/Verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ LogicalResult OperationVerifier::verifyOperation(
230230
<< "created with unregistered dialect. If this is "
231231
"intended, please call allowUnregisteredDialects() on the "
232232
"MLIRContext, or use -allow-unregistered-dialect with "
233-
"mlir-opt";
233+
"the MLIR opt tool used";
234234
}
235235
return success();
236236
}

mlir/lib/Parser/Parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ Value OperationParser::resolveSSAUse(SSAUseInfo useInfo, Type type) {
653653

654654
// Otherwise, this is a forward reference. Create a placeholder and remember
655655
// that we did so.
656-
auto result = createForwardRefPlaceholder(useInfo.loc, type);
656+
Value result = createForwardRefPlaceholder(useInfo.loc, type);
657657
entries[useInfo.number] = {result, useInfo.loc};
658658
return maybeRecordUse(result);
659659
}
@@ -730,7 +730,7 @@ Value OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) {
730730
// We create these placeholders as having an empty name, which we know
731731
// cannot be created through normal user input, allowing us to distinguish
732732
// them.
733-
auto name = OperationName("placeholder", getContext());
733+
auto name = OperationName("unrealized_conversion_cast", getContext());
734734
auto *op = Operation::create(
735735
getEncodedSourceLocation(loc), name, type, /*operands=*/{},
736736
/*attributes=*/llvm::None, /*successors=*/{}, /*numRegions=*/0);

mlir/test/CAPI/ir.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ static int constructAndTraverseIr(MlirContext ctx) {
479479
/// block/operation-relative API and their final order is checked.
480480
static void buildWithInsertionsAndPrint(MlirContext ctx) {
481481
MlirLocation loc = mlirLocationUnknownGet(ctx);
482+
mlirContextSetAllowUnregisteredDialects(ctx, true);
482483

483484
MlirRegion owningRegion = mlirRegionCreate();
484485
MlirBlock nullBlock = mlirRegionGetFirstBlock(owningRegion);
@@ -542,6 +543,7 @@ static void buildWithInsertionsAndPrint(MlirContext ctx) {
542543

543544
mlirOperationDump(op);
544545
mlirOperationDestroy(op);
546+
mlirContextSetAllowUnregisteredDialects(ctx, false);
545547
// clang-format off
546548
// CHECK-LABEL: "insertion.order.test"
547549
// CHECK: ^{{.*}}(%{{.*}}: i1
@@ -1561,6 +1563,8 @@ int testOperands() {
15611563
// CHECK-LABEL: @testOperands
15621564

15631565
MlirContext ctx = mlirContextCreate();
1566+
mlirRegisterAllDialects(ctx);
1567+
mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("test"));
15641568
MlirLocation loc = mlirLocationUnknownGet(ctx);
15651569
MlirType indexType = mlirIndexTypeGet(ctx);
15661570

@@ -1590,6 +1594,7 @@ int testOperands() {
15901594
MlirValue constOneValue = mlirOperationGetResult(constOne, 0);
15911595

15921596
// Create the operation under test.
1597+
mlirContextSetAllowUnregisteredDialects(ctx, true);
15931598
MlirOperationState opState =
15941599
mlirOperationStateGet(mlirStringRefCreateFromCString("dummy.op"), loc);
15951600
MlirValue initialOperands[] = {constZeroValue};
@@ -1604,13 +1609,13 @@ int testOperands() {
16041609
MlirValue opOperand = mlirOperationGetOperand(op, 0);
16051610
fprintf(stderr, "Original operand: ");
16061611
mlirValuePrint(opOperand, printToStderr, NULL);
1607-
// CHECK: Original operand: {{.+}} {value = 0 : index}
1612+
// CHECK: Original operand: {{.+}} constant 0 : index
16081613

16091614
mlirOperationSetOperand(op, 0, constOneValue);
16101615
opOperand = mlirOperationGetOperand(op, 0);
16111616
fprintf(stderr, "Updated operand: ");
16121617
mlirValuePrint(opOperand, printToStderr, NULL);
1613-
// CHECK: Updated operand: {{.+}} {value = 1 : index}
1618+
// CHECK: Updated operand: {{.+}} constant 1 : index
16141619

16151620
mlirOperationDestroy(op);
16161621
mlirOperationDestroy(constZero);
@@ -1626,6 +1631,8 @@ int testClone() {
16261631
// CHECK-LABEL: @testClone
16271632

16281633
MlirContext ctx = mlirContextCreate();
1634+
mlirRegisterAllDialects(ctx);
1635+
mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("std"));
16291636
MlirLocation loc = mlirLocationUnknownGet(ctx);
16301637
MlirType indexType = mlirIndexTypeGet(ctx);
16311638
MlirStringRef valueStringRef = mlirStringRefCreateFromCString("value");
@@ -1646,8 +1653,8 @@ int testClone() {
16461653

16471654
mlirOperationPrint(constZero, printToStderr, NULL);
16481655
mlirOperationPrint(constOne, printToStderr, NULL);
1649-
// CHECK: %0 = "std.constant"() {value = 0 : index} : () -> index
1650-
// CHECK: %0 = "std.constant"() {value = 1 : index} : () -> index
1656+
// CHECK: constant 0 : index
1657+
// CHECK: constant 1 : index
16511658

16521659
return 0;
16531660
}

mlir/test/Dialect/PDL/invalid.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pdl.pattern : benefit(1) {
167167
// expected-error@below {{expected only `pdl` operations within the pattern body}}
168168
pdl.pattern : benefit(1) {
169169
// expected-note@below {{see non-`pdl` operation defined here}}
170-
"foo.other_op"() : () -> ()
170+
"test.foo.other_op"() : () -> ()
171171

172172
%root = pdl.operation "foo.op"
173173
pdl.rewrite %root with "foo"

mlir/test/IR/invalid-module-op.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ func @module_op() {
66
// expected-error@+1 {{Operations with a 'SymbolTable' must have exactly one block}}
77
module {
88
^bb1:
9-
"module_terminator"() : () -> ()
9+
"test.dummy"() : () -> ()
1010
^bb2:
11-
"module_terminator"() : () -> ()
11+
"test.dummy"() : () -> ()
1212
}
1313
return
1414
}

mlir/test/IR/invalid-unregistered.mlir

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
22

3+
// REQUIRES: noasserts
4+
35
// expected-error @below {{op created with unregistered dialect}}
46
"unregistered_dialect.op"() : () -> ()
57

mlir/test/lit.cfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,8 @@
111111
# lib/Bindings/Python/CMakeLists.txt for where this is set up.
112112
os.path.join(config.llvm_obj_root, 'python'),
113113
], append_path=True)
114+
115+
if config.enable_assertions:
116+
config.available_features.add('asserts')
117+
else:
118+
config.available_features.add('noasserts')

mlir/test/python/dialects/python_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ def run(f):
99

1010
# CHECK-LABEL: TEST: testAttributes
1111
def testAttributes():
12-
with Context(), Location.unknown():
12+
with Context() as ctx, Location.unknown():
13+
ctx.allow_unregistered_dialects = True
14+
1315
#
1416
# Check op construction with attributes.
1517
#

mlir/unittests/Pass/PassManagerTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct InvalidPass : Pass {
9191

9292
TEST(PassManagerTest, InvalidPass) {
9393
MLIRContext context;
94+
context.allowUnregisteredDialects();
9495

9596
// Create a module
9697
OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));

0 commit comments

Comments
 (0)