Skip to content

Commit

Permalink
Fix clang-tidy findings
Browse files Browse the repository at this point in the history
Includes a real memory problem: ValueRange is a non-owning container,
assining the returned value of type SmallVector<Value> to ValueRange
will lead to ValueRange starting with a dangling pointer.
  • Loading branch information
ftynse committed Feb 27, 2024
1 parent c38423b commit c47610c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct AddToOpToIndexAndLoadPass
// auto load = cacheBuilder.create<AffineLoadOp>(loc, inputs[i], map[i],
// indices); auto store = cacheBuilder.create<AffineStoreOp>(loc, load,
// inputs[i], map[i], indices);
ValueRange mapAppliedIndices =
SmallVector<Value> mapAppliedIndices =
applyAffineMap(map[num_ins + i], indices, cacheBuilder, loc);
auto load = cacheBuilder.create<memref::LoadOp>(loc, outs[i],
mapAppliedIndices);
Expand All @@ -96,7 +96,7 @@ struct AddToOpToIndexAndLoadPass
}

for (int i = 0; i < retargs.size(); i++) {
ValueRange mapAppliedIndices =
SmallVector<Value> mapAppliedIndices =
applyAffineMap(map[num_ins + i], indices, cacheBuilder, loc);
auto load = cacheBuilder.create<memref::LoadOp>(loc, outs[i],
mapAppliedIndices);
Expand Down
7 changes: 5 additions & 2 deletions enzyme/Enzyme/MLIR/Passes/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ class MemRefDialect;

namespace func {
class FuncDialect;
}
} // end namespace func

namespace affine {
class AffineDialect;
} // end namespace affine

namespace LLVM {
class LLVMDialect;
}
} // end namespace LLVM

#define GEN_PASS_REGISTRATION
#include "Passes/Passes.h.inc"
Expand Down

0 comments on commit c47610c

Please sign in to comment.