llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.01k stars 11.96k forks source link

[mlir] FunctionOpInterfaceSignatureConversion losing location information #60190

Open benvanik opened 1 year ago

benvanik commented 1 year ago

I'm using populateFunctionOpInterfaceTypeConversionPattern on func::FuncOp in order to convert function and block signatures. This does not seem to be preserving location information for function and block arguments, even those that do not change.

Before, where only i64 is getting converted to i32, so ^bb0 shouldn't change while ^bb1 should but both lose their locations:

func.func @main(%arg0: tensor<1x5xf32> loc("foo.mlir split at line #1":143:17), ...
^bb1(%28: tensor<i64> loc("foo.mlir split at line #1":66:6), ...

After:

func.func @main(%arg0: tensor<1x5xf32> loc(unknown), ...
^bb1(%28: tensor<i32> loc(unknown), ...

The root cause (or at least the first place locations are dropped) is the FIXME in ArgConverter::applySignatureConversion:

  // FIXME: We should map the new arguments to proper locations.
  SmallVector<Location> newLocs(convertedTypes.size(),
                                rewriter.getUnknownLoc());
llvmbot commented 1 year ago

@llvm/issue-subscribers-mlir