Skip to content

Commit c1f9288

Browse files
committed
[mlir][spirv] Use MapVector for BlockMergeInfoMap
This should ensure that the structurizer while loop is deterministic across runs. Use of MapVector addresses the source of the nondeterminism which is use of a Block* as a map key. fixes #128547
1 parent 21fedcb commit c1f9288

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,9 +2923,6 @@ LogicalResult spirv::Deserializer::structurizeControlFlow() {
29232923
return failure();
29242924
}
29252925

2926-
// TODO: This loop is non-deterministic. Iteration order may vary between runs
2927-
// for the same shader as the key to the map is a pointer. See:
2928-
// https://github.com/llvm/llvm-project/issues/128547
29292926
while (!blockMergeInfo.empty()) {
29302927
Block *headerBlock = blockMergeInfo.begin()->first;
29312928
BlockMergeInfo mergeInfo = blockMergeInfo.begin()->second;

mlir/lib/Target/SPIRV/Deserialization/Deserializer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ struct DebugLine {
5858
};
5959

6060
/// Map from a selection/loop's header block to its merge (and continue) target.
61-
using BlockMergeInfoMap = DenseMap<Block *, BlockMergeInfo>;
61+
/// Use `MapVector<>` to ensure a deterministic iteration order with a pointer
62+
/// key.
63+
using BlockMergeInfoMap = llvm::MapVector<Block *, BlockMergeInfo>;
6264

6365
/// A "deferred struct type" is a struct type with one or more member types not
6466
/// known when the Deserializer first encounters the struct. This happens, for

0 commit comments

Comments
 (0)