Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Dec 17, 2024
1 parent 892f813 commit 4168f8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions mlir/docs/PassManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -1401,19 +1401,22 @@ $ tree /tmp/pipeline_output
* `mlir-use-nameloc-as-prefix`
* If your source IR has named locations (`loc("named_location")"`) then passing this flag will use those
names (`named_location`) to prefix the corresponding SSA identifiers:
```

```mlir
%1 = memref.load %0[] : memref<i32> loc("alice")
%2 = memref.load %0[] : memref<i32> loc("bob")
%3 = memref.load %0[] : memref<i32> loc("bob")
```
will print
```
```mlir
%alice = memref.load %0[] : memref<i32>
%bob = memref.load %0[] : memref<i32>
%bob_0 = memref.load %0[] : memref<i32>
```
These names will also be preserved through passes to newly created operations
(assuming the pass writer was diligent about forward `Location` information).
These names will also be preserved through passes to newly created operations if using the appropriate location.
## Crash and Failure Reproduction
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/IR/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool OpPrintingFlags::shouldPrintUniqueSSAIDs() const {
return printUniqueSSAIDsFlag || shouldPrintGenericOpForm();
}

/// Return if the printer should use NameLocs as prefixes when printing SSA IDs
/// Return if the printer should use NameLocs as prefixes when printing SSA IDs.
bool OpPrintingFlags::shouldUseNameLocAsPrefix() const {
return useNameLocAsPrefix;
}
Expand Down
14 changes: 7 additions & 7 deletions mlir/test/IR/print-use-nameloc-as-prefix.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// CHECK-LABEL: test_basic
func.func @test_basic() {
%0 = memref.alloc() : memref<i32>
// CHECK: %alice
// CHECK: %alice = memref.load
%1 = memref.load %0[] : memref<i32> loc("alice")
return
}
Expand All @@ -14,9 +14,9 @@ func.func @test_basic() {
// CHECK-LABEL: test_repeat_namelocs
func.func @test_repeat_namelocs() {
%0 = memref.alloc() : memref<i32>
// CHECK: %alice
// CHECK: %alice = memref.load
%1 = memref.load %0[] : memref<i32> loc("alice")
// CHECK: %alice_0
// CHECK: %alice_0 = memref.load
%2 = memref.load %0[] : memref<i32> loc("alice")
return
}
Expand All @@ -36,9 +36,9 @@ func.func private @make_two_results() -> (index, index)

// CHECK-LABEL: test_multiple_results
func.func @test_multiple_results(%cond: i1) {
// CHECK: %foo:2
// CHECK: %foo:2 = call @make_two_results
%0:2 = call @make_two_results() : () -> (index, index) loc("foo")
// CHECK: %bar:2
// CHECK: %bar:2 = call @make_two_results
%1, %2 = call @make_two_results() : () -> (index, index) loc("bar")

// CHECK: %kevin:2 = scf.while (%arg1 = %bar#0, %arg2 = %bar#0)
Expand All @@ -65,9 +65,9 @@ func.func @test_multiple_results(%cond: i1) {

// CHECK-LABEL: test_op_asm_interface
func.func @test_op_asm_interface(%arg0: tensor<?xf32>, %arg1: tensor<?xf32>) {
// CHECK: %c0
// CHECK: %c0 = arith.constant
%0 = arith.constant 0 : index
// CHECK: %foo
// CHECK: %foo = arith.constant
%1 = arith.constant 1 : index loc("foo")

linalg.generic #trait ins(%arg0: tensor<?xf32>) outs(%arg0, %arg1: tensor<?xf32>, tensor<?xf32>) {
Expand Down

0 comments on commit 4168f8e

Please sign in to comment.