Skip to content

Commit

Permalink
[mlir][Tosa] Fix test failure when running with Asan.
Browse files Browse the repository at this point in the history
We cannot rely on the address of StringAttr being the same if the stored
string is the same.
  • Loading branch information
akuegel committed Oct 17, 2023
1 parent b736e04 commit 7f2dd2d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ struct TosaValidation : public tosa::impl::TosaValidationBase<TosaValidation> {

SmallVector<std::function<LogicalResult(Operation *)>> const_checkers;
tosa_level_t tosa_level;
DenseMap<const mlir::StringAttr *, mlir::Type> variables_map;
DenseMap<StringAttr, mlir::Type> variables_map;
};

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

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

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

variables_map[&name_attr] = type;
variables_map[name_attr] = type;
}

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

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

auto var_type = variables_map[&name_attr];
auto var_type = variables_map[name_attr];

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

0 comments on commit 7f2dd2d

Please sign in to comment.