MLIR location infos do not print?

Hi all, I want to set a name loc to each op. But I set the location when creating ops, when I dump the SSA, there is no loc infomations.

Can anyone show me how I am wrong with it?

std::vector locs;
auto loc = NameLoc::get(builder_.getStringAttr(“123456”));
locs.push_back(Location(loc));
auto loc1 = builder_.getFusedLoc(llvm::makeArrayRef(locs));

auto noneOp = builder_.create<mlir::NoneOp>(loc1, builder_.getNoneType());

you can see no loc info printed as follows:

module {
func.func @main_func(%arg0: none) → tensor<1x2x3x4xsi10> {
%0 = “xgt.None”() : () → none
%1 = “xgt.Constant”() {value = dense<1> : tensor<1x2x3x4xi32>} : () → tensor<1x2x3x4xsi10>
return %1 : tensor<1x2x3x4xsi10>
}
}

Unfortunately MLIR does not print them by default (I think this is a design defect personally by the way), depending on how you print there are two ways:

  • On the command line: --mlir-print-debuginfo will enable them.
  • Through the print() C++ API, it takes an OpPrintingFlags which can be used to enable printing debug info, like here for example.

Hi @mehdi_amini , thank you for your quick answer. I will have a try, thanks a lot!