Skip to content

[MLIR] Broken bytecode roundtrip for properties #155210

@Dinistro

Description

@Dinistro

There seems to be some unexpected issue in the bytecode rountrip. When running mlir-opt -verify-roundtrip with the following input, the property parsing explodes.

llvm.func @foo()

llvm.func @repro(%val: f32) {
  llvm.call @foo() : () -> ()
  %t = arith.addf %val, %val : f32

  llvm.return
}

Crash log:

loc("-":8:10): error: invalid properties {fastmath = #llvm.fastmath<none>} for op arith.addf: Invalid attribute `fastmath` in property conversion: #llvm.fastmath<none>
repro.mlir:0:0: error: 'builtin.module' op failed to parse textual content back, cannot verify round-trip.

repro.mlir:0:0: note: see current operation:
"builtin.module"() ({
  "llvm.func"() <{CConv = #llvm.cconv<ccc>, function_type = !llvm.func<void ()>, linkage = #llvm.linkage<external>, sym_name = "foo", unnamed_addr = 0 : i64, visibility_ = 0 : i64}> ({
  }) : () -> ()
  "llvm.func"() <{CConv = #llvm.cconv<ccc>, function_type = !llvm.func<void (f32)>, linkage = #llvm.linkage<external>, sym_name = "repro", unnamed_addr = 0 : i64, visibility_ = 0 : i64}> ({
  ^bb0(%arg0: f32):
    "llvm.call"() <{CConv = #llvm.cconv<ccc>, TailCallKind = #llvm.tailcallkind<none>, callee = @foo, fastmathFlags = #llvm.fastmath<none>, op_bundle_sizes = array<i32>, operandSegmentSizes = array<i32: 0, 0>}> : () -> ()
    %0 = "arith.addf"(%arg0, %arg0) <{fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32
    "llvm.return"() : () -> ()
  }) : () -> ()
}) : () -> ()
loc("-":0:0): error: expected mlir::arith::FastMathFlagsAttr, but got: #llvm.fastmath<none>
repro.mlir:0:0: error: 'builtin.module' op failed to parse bytecode content back, cannot verify round-trip.

repro.mlir:0:0: note: see current operation:
"builtin.module"() ({
  "llvm.func"() <{CConv = #llvm.cconv<ccc>, function_type = !llvm.func<void ()>, linkage = #llvm.linkage<external>, sym_name = "foo", unnamed_addr = 0 : i64, visibility_ = 0 : i64}> ({
  }) : () -> ()
  "llvm.func"() <{CConv = #llvm.cconv<ccc>, function_type = !llvm.func<void (f32)>, linkage = #llvm.linkage<external>, sym_name = "repro", unnamed_addr = 0 : i64, visibility_ = 0 : i64}> ({
  ^bb0(%arg0: f32):
    "llvm.call"() <{CConv = #llvm.cconv<ccc>, TailCallKind = #llvm.tailcallkind<none>, callee = @foo, fastmathFlags = #llvm.fastmath<none>, op_bundle_sizes = array<i32>, operandSegmentSizes = array<i32: 0, 0>}> : () -> ()
    %0 = "arith.addf"(%arg0, %arg0) <{fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32
    "llvm.return"() : () -> ()
  }) : () -> ()
}) : () -> ()

So far, I'm not entirely sure what might have introduce this breakage. For now, my suspicion is #151267 (FYI: @hankluo6 @joker-eph). I'll try to revert this commit locally to see if that resolves my issue. I'll report back once I gathered insights.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions