pymlir icon indicating copy to clipboard operation
pymlir copied to clipboard

Incorrect translation for PrettyDialectType.

Open KimythAnly opened this issue 7 months ago • 0 comments

Hi, I noticed that in the following example, the #llvm.linkage (pretty dialect attribute) is being parsed as a pretty dialect type (!llvm.linkage). I'm just curious— is this the expected behavior? Thanks!

This MLIR is copied from https://github.com/spcl/pymlir/issues/42.

module {
  func.func @test(%arg0: memref<?xi32>, %arg1: memref<?xi32>) attributes {llvm.linkage = #llvm.linkage<external>} {
    %c2_i32 = arith.constant 2 : i32
    %c0 = arith.constant 0 : index
    %0 = memref.load %arg1 : memref<?xi32>
    %1 = arith.addi %0, %c2_i32 : i32
    %c0_0 = arith.constant 0 : index
    memref.store %1, %arg0 : memref<?xi32>
    return
  }
}

Reproducible code

import mlir

m = """module {
  func.func @test(%arg0: memref<?xi32>, %arg1: memref<?xi32>) attributes {llvm.linkage = #llvm.linkage<external>} {
    %c2_i32 = arith.constant 2 : i32
    %c0 = arith.constant 0 : index
    %0 = memref.load %arg1 : memref<?xi32>
    %1 = arith.addi %0, %c2_i32 : i32
    %c0_0 = arith.constant 0 : index
    memref.store %1, %arg0 : memref<?xi32>
    return
  }
}"""

parser = mlir.Parser()
print(parser.parse(m).pretty())

The output:

module {
  func.func @test(%arg0: memref<?xi32>, %arg1: memref<?xi32>) attributes {llvm.linkage = !llvm.linkage<external>} {
    %c2_i32 = arith.constant 2 : i32
    %c0 = arith.constant 0 : index
    %0 = memref.load %arg1 : memref<?xi32>
    %1 = arith.addi %0, %c2_i32 : i32
    %c0_0 = arith.constant 0 : index
    memref.store %1, %arg0 : memref<?xi32>
    return
  }
}

KimythAnly avatar Jul 02 '25 14:07 KimythAnly