Skip to content

Commit 779871c

Browse files
ChiaHungDuantstellar
authored andcommitted
[mlir-tblgen] Fix non-deterministic generating static verifier in DRR.
Use SetVector instead of DenseSet to ensure we always generate the same name for the same function. This issue is found in #53768. Reviewed By: quinnp, rdzhabarov Differential Revision: https://reviews.llvm.org/D120514 (cherry picked from commit d56ef5e)
1 parent 4de8e56 commit 779871c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mlir/include/mlir/TableGen/CodeGenHelpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class StaticVerifierFunctionEmitter {
114114
///
115115
/// Constraints that do not meet the restriction that they can only reference
116116
/// `$_self`, `$_op`, and `$_builder` are not uniqued.
117-
void emitPatternConstraints(const DenseSet<DagLeaf> &constraints);
117+
void emitPatternConstraints(const ArrayRef<DagLeaf> constraints);
118118

119119
/// Get the name of the static function used for the given type constraint.
120120
/// These functions are used for operand and result constraints and have the
@@ -178,7 +178,7 @@ class StaticVerifierFunctionEmitter {
178178
/// Collect and unique all the constraints used by operations.
179179
void collectOpConstraints(ArrayRef<llvm::Record *> opDefs);
180180
/// Collect and unique all pattern constraints.
181-
void collectPatternConstraints(const DenseSet<DagLeaf> &constraints);
181+
void collectPatternConstraints(ArrayRef<DagLeaf> constraints);
182182

183183
/// The output stream.
184184
raw_ostream &os;

mlir/tools/mlir-tblgen/CodeGenHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void StaticVerifierFunctionEmitter::emitOpConstraints(
6262
}
6363

6464
void StaticVerifierFunctionEmitter::emitPatternConstraints(
65-
const llvm::DenseSet<DagLeaf> &constraints) {
65+
const llvm::ArrayRef<DagLeaf> constraints) {
6666
collectPatternConstraints(constraints);
6767
emitPatternConstraints();
6868
}
@@ -332,7 +332,7 @@ void StaticVerifierFunctionEmitter::collectOpConstraints(
332332
}
333333

334334
void StaticVerifierFunctionEmitter::collectPatternConstraints(
335-
const llvm::DenseSet<DagLeaf> &constraints) {
335+
const llvm::ArrayRef<DagLeaf> constraints) {
336336
for (auto &leaf : constraints) {
337337
assert(leaf.isOperandMatcher() || leaf.isAttrMatcher());
338338
collectConstraint(

mlir/tools/mlir-tblgen/RewriterGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class StaticMatcherHelper {
322322
int staticMatcherCounter = 0;
323323

324324
// The DagLeaf which contains type or attr constraint.
325-
DenseSet<DagLeaf> constraints;
325+
SetVector<DagLeaf> constraints;
326326

327327
// Static type/attribute verification function emitter.
328328
StaticVerifierFunctionEmitter staticVerifierEmitter;
@@ -1708,7 +1708,7 @@ void StaticMatcherHelper::populateStaticMatchers(raw_ostream &os) {
17081708
}
17091709

17101710
void StaticMatcherHelper::populateStaticConstraintFunctions(raw_ostream &os) {
1711-
staticVerifierEmitter.emitPatternConstraints(constraints);
1711+
staticVerifierEmitter.emitPatternConstraints(constraints.getArrayRef());
17121712
}
17131713

17141714
void StaticMatcherHelper::addPattern(Record *record) {

0 commit comments

Comments
 (0)