Skip to content

Bad CHECK-LABEL line generation in mlir/utils/generate-test-checks.py when attribute aliases are on the same line #162310

@TomMurray

Description

@TomMurray

This can happen for e.g. func.func with no references and some attribute alias in the attributes or in return types.

Reproducing example:

// test.mlir
func.func @test() attributes {amap = affine_map<(d0, d1)[s0] -> (d0, d0 + d1 + s0 floordiv 2)>, bmap = affine_map<(d0, d1) -> (d0, d1)>}  {
  return
}

generate-test-checks.py can be run as follows on this input:

mlir-opt test.mlir | ./mlir/utils/generate-test-checks.py

producing the following output:

// ...

// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1)[s0] -> (d0, d0 + d1 + s0 floordiv 2)>
// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1) -> (d0, d1)>
// CHECK-LABEL:   func.func @test() attributes {amap = #map, bmap = #map1} {
// CHECK:           return
// CHECK:         }

See how the attribute aliases in the CHECK-LABEL line do not use the CHECK variables assigned to them.

As CHECK-LABEL lines may not contain variable references, the expected output for this case should in my opinion include an extra line break before the first variable reference:

// ...

// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1)[s0] -> (d0, d0 + d1 + s0 floordiv 2)>
// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1) -> (d0, d1)>
// CHECK-LABEL:   func.func @test() attributes {amap =
// CHECK-SAME:      #[[$ATTR_0]], bmap = #[[$ATTR_1]]} {
// CHECK:           return
// CHECK:         }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions