[Mlir-commits] [mlir] 7f2dd2d - [mlir][Tosa] Fix test failure when running with Asan.
Adrian Kuegel
llvmlistbot at llvm.org
Tue Oct 17 04:25:31 PDT 2023
Author: Adrian Kuegel
Date: 2023-10-17T11:23:47Z
New Revision: 7f2dd2da99371ef5b281834b604d251f3112cb23
URL: https://github.com/llvm/llvm-project/commit/7f2dd2da99371ef5b281834b604d251f3112cb23
DIFF: https://github.com/llvm/llvm-project/commit/7f2dd2da99371ef5b281834b604d251f3112cb23.diff
LOG: [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.
Added:
Modified:
mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index d686ce125c13516..d973ac9cae2e842 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -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) {
@@ -448,7 +448,7 @@ 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;
}
@@ -456,7 +456,7 @@ bool TosaValidation::CheckVariable(Operation *op) {
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;
@@ -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();
More information about the Mlir-commits
mailing list