Files
TheRock/compiler/amd-llvm/mlir/test/Dialect/Func/invalid.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

226 lines
5.8 KiB
MLIR

// RUN: mlir-opt -allow-unregistered-dialect -split-input-file %s -verify-diagnostics
func.func @unsupported_attribute() {
// expected-error @+1 {{invalid kind of attribute specified}}
%0 = constant "" : index
return
}
// -----
func.func private @return_i32_f32() -> (i32, f32)
func.func @call() {
// expected-error @+3 {{op result type mismatch at index 0}}
// expected-note @+2 {{op result types: 'f32', 'i32'}}
// expected-note @+1 {{function result types: 'i32', 'f32'}}
%0:2 = call @return_i32_f32() : () -> (f32, i32)
return
}
// -----
func.func @resulterror() -> i32 {
^bb42:
return // expected-error {{'func.return' op has 0 operands, but enclosing function (@resulterror) returns 1}}
}
// -----
func.func @return_type_mismatch() -> i32 {
%0 = "foo"() : ()->f32
return %0 : f32 // expected-error {{type of return operand 0 ('f32') doesn't match function result type ('i32') in function @return_type_mismatch}}
}
// -----
func.func @return_inside_loop() {
affine.for %i = 1 to 100 {
// expected-error@+1 {{'func.return' op expects parent op 'func.func'}}
func.return
}
return
}
// -----
// expected-error@+1 {{expected non-function type}}
func.func @func_variadic(...)
// -----
func.func @foo() {
^bb0:
%x = constant @foo : (i32) -> () // expected-error {{reference to function with mismatched type}}
return
}
// -----
func.func @undefined_function() {
^bb0:
%x = constant @qux : (i32) -> () // expected-error {{reference to undefined function 'qux'}}
return
}
// -----
#map1 = affine_map<(i)[j] -> (i+j)>
func.func @bound_symbol_mismatch(%N : index) {
affine.for %i = #map1(%N) to 100 {
// expected-error@-1 {{symbol operand count and affine map symbol count must match}}
}
return
}
// -----
#map1 = affine_map<(i)[j] -> (i+j)>
func.func @bound_dim_mismatch(%N : index) {
affine.for %i = #map1(%N, %N)[%N] to 100 {
// expected-error@-1 {{dim operand count and affine map dim count must match}}
}
return
}
// -----
func.func @large_bound() {
affine.for %i = 1 to 9223372036854775810 {
// expected-error@-1 {{integer constant out of range for attribute}}
}
return
}
// -----
func.func @max_in_upper_bound(%N : index) {
affine.for %i = 1 to max affine_map<(i)->(N, 100)> { //expected-error {{expected attribute value}}
}
return
}
// -----
func.func @step_typo() {
affine.for %i = 1 to 100 step -- 1 { //expected-error {{expected constant integer}}
}
return
}
// -----
func.func @invalid_bound_map(%N : i32) {
affine.for %i = 1 to affine_map<(i)->(j)>(%N) { //expected-error {{use of undeclared identifier}}
}
return
}
// -----
// expected-error @+1 {{expected '(' in integer set constraint list}}
#set0 = affine_set<(i)[N, M] : )i >= 0)>
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func.func @invalid_if_operands1(%N : index) {
affine.for %i = 1 to 10 {
affine.if #set0(%i) {
// expected-error@-1 {{symbol operand count and integer set symbol count must match}}
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func.func @invalid_if_operands2(%N : index) {
affine.for %i = 1 to 10 {
affine.if #set0()[%N] {
// expected-error@-1 {{dim operand count and integer set dim count must match}}
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func.func @invalid_if_operands3(%N : index) {
affine.for %i = 1 to 10 {
affine.if #set0(%i)[%i] {
// expected-error@-1 {{operand cannot be used as a symbol}}
}
}
return
}
// -----
func.func @redundant_signature(%a : i32) -> () {
^bb0(%b : i32): // expected-error {{invalid block name in region with named arguments}}
return
}
// -----
func.func @mixed_named_arguments(%a : i32,
f32) -> () {
// expected-error @-1 {{expected SSA identifier}}
return
}
// -----
func.func @mixed_named_arguments(f32,
%a : i32) -> () { // expected-error {{expected type instead of SSA identifier}}
return
}
// -----
// expected-error @+1 {{@ identifier expected to start with letter or '_'}}
func.func @$invalid_function_name()
// -----
// expected-error @+1 {{arguments may only have dialect attributes}}
func.func private @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
// -----
// expected-error @+1 {{results may only have dialect attributes}}
func.func private @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
// -----
func.func @foo() {} // expected-error {{expected non-empty function body}}
// -----
// test.loop_block_term implements RegionBranchTerminatorOpInterface.
// getMutableSuccessorOperands(parent) returns only the exit operand (f32).
// The function returns i32, so the type check must fail.
func.func @region_branch_term_type_mismatch(%arg: i32) -> i32 {
%0 = "test.constant"() { value = 5.3 : f32 } : () -> f32
// expected-error @+1 {{type of return operand 0 ('f32') doesn't match function result type ('i32') in function @region_branch_term_type_mismatch}}
test.loop_block_term iter %arg exit %0
}
// -----
// test.loop_block_term has one exit operand (f32) but the function returns
// nothing. getMutableSuccessorOperands(parent) returns 1 operand while the
// function has 0 results, so the count check must fail.
func.func @region_branch_term_count_mismatch(%arg: i32) {
%0 = "test.constant"() { value = 5.3 : f32 } : () -> f32
// expected-error @+1 {{'test.loop_block_term' op has 1 operands, but enclosing function (@region_branch_term_count_mismatch) returns 0}}
test.loop_block_term iter %arg exit %0
}
// -----
// After moving the return-type checks from FuncOp::verify() to
// FuncOp::verifyRegions() (hasRegionVerifier=1), the terminator is verified
// first and emits a clean diagnostic instead of crashing.
func.func @func_verifier_runs_before_region() -> () {
// expected-error @below {{requires 'valid' unit attribute}}
test.crashing_return
}