Skip to content

Commit 7f2dd2d

Browse files
committed
[mlir][Tosa] Fix test failure when running with Asan.
We cannot rely on the address of StringAttr being the same if the stored string is the same.
1 parent b736e04 commit 7f2dd2d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ struct TosaValidation : public tosa::impl::TosaValidationBase<TosaValidation> {
410410

411411
SmallVector<std::function<LogicalResult(Operation *)>> const_checkers;
412412
tosa_level_t tosa_level;
413-
DenseMap<const mlir::StringAttr *, mlir::Type> variables_map;
413+
DenseMap<StringAttr, mlir::Type> variables_map;
414414
};
415415

416416
LogicalResult TosaValidation::applyLevelCheck(Operation *op) {
@@ -448,15 +448,15 @@ bool TosaValidation::CheckVariable(Operation *op) {
448448
if (isa<mlir::tosa::VariableOp>(op)) {
449449
auto name_attr = cast<mlir::StringAttr>(op->getAttr("name"));
450450

451-
if (variables_map.count(&name_attr)) {
451+
if (variables_map.count(name_attr)) {
452452
op->emitOpError() << "name has already been declared";
453453
return false;
454454
}
455455

456456
auto type_attr = cast<mlir::TypeAttr>(op->getAttr("type"));
457457
mlir::Type type = type_attr.getValue();
458458

459-
variables_map[&name_attr] = type;
459+
variables_map[name_attr] = type;
460460
}
461461

462462
return true;
@@ -467,12 +467,12 @@ bool TosaValidation::CheckVariableReadOrWrite(Operation *op) {
467467
isa<mlir::tosa::VariableWriteOp>(op)) {
468468
auto name_attr = cast<mlir::StringAttr>(op->getAttr("name"));
469469

470-
if (!variables_map.count(&name_attr)) {
470+
if (!variables_map.count(name_attr)) {
471471
op->emitOpError() << "name has not been declared";
472472
return false;
473473
}
474474

475-
auto var_type = variables_map[&name_attr];
475+
auto var_type = variables_map[name_attr];
476476

477477
for (auto v : op->getOperands()) {
478478
auto type = v.getType();

0 commit comments

Comments
 (0)