Do not emit aliases when printing local form
Expand local scope printing to skip printing aliases as aliases are printed out at the top of a module and may not be part of the output generated by local scope print. PiperOrigin-RevId: 280278617
This commit is contained in:
parent
8abda15b3f
commit
d1c99e10d0
|
@ -84,6 +84,11 @@ static llvm::cl::opt<bool>
|
|||
llvm::cl::desc("Print the generic op form"),
|
||||
llvm::cl::init(false), llvm::cl::Hidden);
|
||||
|
||||
static llvm::cl::opt<bool> printLocalScopeOpt(
|
||||
"mlir-print-local-scope",
|
||||
llvm::cl::desc("Print assuming in local scope by default"),
|
||||
llvm::cl::init(false), llvm::cl::Hidden);
|
||||
|
||||
/// Initialize the printing flags with default supplied by the cl::opts above.
|
||||
OpPrintingFlags::OpPrintingFlags()
|
||||
: elementsAttrElementLimit(
|
||||
|
@ -92,7 +97,8 @@ OpPrintingFlags::OpPrintingFlags()
|
|||
: Optional<int64_t>()),
|
||||
printDebugInfoFlag(printDebugInfoOpt),
|
||||
printDebugInfoPrettyFormFlag(printPrettyDebugInfoOpt),
|
||||
printGenericOpFormFlag(printGenericOpFormOpt), printLocalScope(false) {}
|
||||
printGenericOpFormFlag(printGenericOpFormOpt),
|
||||
printLocalScope(printLocalScopeOpt) {}
|
||||
|
||||
/// Enable the elision of large elements attributes, by printing a '...'
|
||||
/// instead of the element data, when the number of elements is greater than
|
||||
|
@ -2020,7 +2026,9 @@ void Block::printAsOperand(raw_ostream &os, bool printType) {
|
|||
|
||||
void ModuleOp::print(raw_ostream &os, OpPrintingFlags flags) {
|
||||
ModuleState state(getContext());
|
||||
state.initialize(*this);
|
||||
// Skip initializing in local scope to avoid populating aliases.
|
||||
if (!flags.shouldUseLocalScope())
|
||||
state.initialize(*this);
|
||||
ModulePrinter(os, flags, &state).print(*this);
|
||||
}
|
||||
|
||||
|
|
5
mlir/test/IR/print-op-local-scope.mlir
Normal file
5
mlir/test/IR/print-op-local-scope.mlir
Normal file
|
@ -0,0 +1,5 @@
|
|||
// RUN: mlir-opt %s -mlir-print-local-scope | FileCheck %s --dump-input-on-failure
|
||||
|
||||
// CHECK: "foo.op"() : () -> memref<?xf32, (d0) -> (d0 * 2)>
|
||||
"foo.op"() : () -> (memref<?xf32, (d0) -> (2*d0)>)
|
||||
|
Loading…
Reference in a new issue