-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLIR][IR] add -mlir-print-unique-ssa-ids to AsmPrinter (#91241)
Add an option to unique the numbers of values, block arguments and naming conflicts when requested and/or printing generic op form. This is helpful when debugging. For example, if you have: scf.for %0 = %1 = opA %0 scf.for %0 = %1 = opB %0 And you get a verifier error which says opB's "operand #0 does not dominate this use", it looks like %0 does dominate the use. This is not intuitive. If these were numbered uniquely, it would look like: scf.for %0 = %1 = opA %0 scf.for %2 = %3 = opB %0 And thus, much clearer as to why you are getting the error since %0 is out of scope. Since generic op form should aim to give you the most possible information, it seems like a good idea to use unique numbers in this situation. Adding an option also gives those an option to use it outside of generic op form. Co-authored-by: Scott Manley <scmanley@nvidia.com>
- Loading branch information
1 parent
e84fae8
commit 5717553
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: mlir-opt -mlir-print-unique-ssa-ids %s | FileCheck %s | ||
// RUN: mlir-opt -mlir-print-op-generic %s | FileCheck %s | ||
// RUN: mlir-opt %s | FileCheck %s --check-prefix=LOCAL_SCOPE | ||
|
||
// CHECK: %arg3 | ||
// CHECK: %7 | ||
// LOCAL_SCOPE-NOT: %arg3 | ||
// LOCAL_SCOPE-NOT: %7 | ||
module { | ||
func.func @uniqueSSAIDs(%arg0 : memref<i32>, %arg1 : memref<i32>) { | ||
%c0 = arith.constant 0 : index | ||
%c1 = arith.constant 1 : index | ||
%c8 = arith.constant 8 : index | ||
scf.for %arg2 = %c0 to %c8 step %c1 { | ||
%a = memref.load %arg0[] : memref<i32> | ||
%b = memref.load %arg1[] : memref<i32> | ||
%0 = arith.addi %a, %b : i32 | ||
%1 = arith.subi %a, %b : i32 | ||
scf.yield | ||
} | ||
scf.for %arg2 = %c0 to %c8 step %c1 { | ||
%a = memref.load %arg0[] : memref<i32> | ||
%b = memref.load %arg1[] : memref<i32> | ||
%0 = arith.addi %a, %b : i32 | ||
%1 = arith.subi %a, %b : i32 | ||
scf.yield | ||
} | ||
return | ||
} | ||
} |