From 73c5b56377fb7eabe91f92535d6754a2fec4d1cd Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Tue, 27 Feb 2024 11:22:28 +0000 Subject: [PATCH] Fix clang-tidy findings Includes a real memory problem: ValueRange is a non-owning container, assining the returned value of type SmallVector to ValueRange will lead to ValueRange starting with a dangling pointer. --- enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp | 4 ++-- enzyme/Enzyme/MLIR/Passes/Passes.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp b/enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp index 5baf2f982d9d..648509f58e52 100644 --- a/enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp +++ b/enzyme/Enzyme/MLIR/Passes/AddToOpToIndexAndLoad.cpp @@ -85,7 +85,7 @@ struct AddToOpToIndexAndLoadPass // auto load = cacheBuilder.create(loc, inputs[i], map[i], // indices); auto store = cacheBuilder.create(loc, load, // inputs[i], map[i], indices); - ValueRange mapAppliedIndices = + SmallVector mapAppliedIndices = applyAffineMap(map[num_ins + i], indices, cacheBuilder, loc); auto load = cacheBuilder.create(loc, outs[i], mapAppliedIndices); @@ -96,7 +96,7 @@ struct AddToOpToIndexAndLoadPass } for (int i = 0; i < retargs.size(); i++) { - ValueRange mapAppliedIndices = + SmallVector mapAppliedIndices = applyAffineMap(map[num_ins + i], indices, cacheBuilder, loc); auto load = cacheBuilder.create(loc, outs[i], mapAppliedIndices); diff --git a/enzyme/Enzyme/MLIR/Passes/Passes.h b/enzyme/Enzyme/MLIR/Passes/Passes.h index 25362d01294a..80c88373090c 100644 --- a/enzyme/Enzyme/MLIR/Passes/Passes.h +++ b/enzyme/Enzyme/MLIR/Passes/Passes.h @@ -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"