Skip to content

Commit e6edc1b

Browse files
committed
[MLIR] Fix non-deterministic generation from buffer-deallocation pass
The buffer-deallocation pass generates a different output on each run due to an unstable iteration order. Fixes: llvm#59118 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D143622
1 parent 68c9068 commit e6edc1b

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

mlir/include/mlir/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BufferViewFlowAnalysis {
5555
ValueSetT resolve(Value value) const;
5656

5757
/// Removes the given values from all alias sets.
58-
void remove(const SmallPtrSetImpl<Value> &aliasValues);
58+
void remove(const SetVector<Value> &aliasValues);
5959

6060
private:
6161
/// This function constructs a mapping from values to its immediate

mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class BufferDeallocation : public BufferPlacementTransformationBase {
259259
// Initialize the set of values that require a dedicated memory free
260260
// operation since their operands cannot be safely deallocated in a post
261261
// dominator.
262-
SmallPtrSet<Value, 8> valuesToFree;
262+
SetVector<Value> valuesToFree;
263263
llvm::SmallDenseSet<std::tuple<Value, Block *>> visitedValues;
264264
SmallVector<std::tuple<Value, Block *>, 8> toProcess;
265265

mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "mlir/Interfaces/ControlFlowInterfaces.h"
1313
#include "mlir/Interfaces/ViewLikeInterface.h"
1414
#include "llvm/ADT/SetOperations.h"
15+
#include "llvm/ADT/SetVector.h"
1516

1617
using namespace mlir;
1718

@@ -40,7 +41,7 @@ BufferViewFlowAnalysis::resolve(Value rootValue) const {
4041
}
4142

4243
/// Removes the given values from all alias sets.
43-
void BufferViewFlowAnalysis::remove(const SmallPtrSetImpl<Value> &aliasValues) {
44+
void BufferViewFlowAnalysis::remove(const SetVector<Value> &aliasValues) {
4445
for (auto &entry : dependencies)
4546
llvm::set_subtract(entry.second, aliasValues);
4647
}

0 commit comments

Comments
 (0)