-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[MLIR] Fix use-after-move in debug logging #165208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-sparse Author: Slava Gurevich (noclowns) Changes
Testing: Full diff: https://github.com/llvm/llvm-project/pull/165208.diff 3 Files Affected:
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index eb2d825e17e44..bd25e946908b6 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -495,13 +495,14 @@ FailureOr<PackResult> linalg::pack(RewriterBase &rewriter,
if (failed(maybePackedDimForEachOperand))
return failure();
packedOperandsDims.packedDimForEachOperand = *maybePackedDimForEachOperand;
- listOfPackedOperandsDim.pushBack(std::move(packedOperandsDims));
LDBG() << "++++ After pack size #" << i << ": " << packedSizes[i];
LDBG() << "maps: " << llvm::interleaved(indexingMaps);
LDBG() << "iterators: " << llvm::interleaved(iteratorTypes);
LDBG() << "packedDimForEachOperand: "
<< llvm::interleaved(packedOperandsDims.packedDimForEachOperand);
+
+ listOfPackedOperandsDim.pushBack(std::move(packedOperandsDims));
}
// Step 2. Propagate packing to all LinalgOp operands.
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp
index f53d2727c9b00..b4b319ed3e23a 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp
@@ -152,19 +152,19 @@ IterationGraphSorter IterationGraphSorter::fromGenericOp(
}
IterationGraphSorter::IterationGraphSorter(
- SmallVector<Value> &&ins, SmallVector<AffineMap> &&loop2InsLvl, Value out,
- AffineMap loop2OutLvl, SmallVector<utils::IteratorType> &&iterTypes,
+ SmallVector<Value> &&insArg, SmallVector<AffineMap> &&loop2InsLvlArg, Value out,
+ AffineMap loop2OutLvl, SmallVector<utils::IteratorType> &&iterTypesArg,
sparse_tensor::LoopOrderingStrategy strategy)
- : ins(std::move(ins)), loop2InsLvl(std::move(loop2InsLvl)), out(out),
- loop2OutLvl(loop2OutLvl), iterTypes(std::move(iterTypes)),
+ : ins(std::move(insArg)), loop2InsLvl(std::move(loop2InsLvlArg)), out(out),
+ loop2OutLvl(loop2OutLvl), iterTypes(std::move(iterTypesArg)),
strategy(strategy) {
// One map per tensor.
- assert(this->loop2InsLvl.size() == this->ins.size());
+ assert(loop2InsLvl.size() == ins.size());
// All the affine maps have the same number of dimensions (loops).
assert(llvm::all_equal(llvm::map_range(
- this->loop2InsLvl, [](AffineMap m) { return m.getNumDims(); })));
+ loop2InsLvl, [](AffineMap m) { return m.getNumDims(); })));
// The number of results of the map should match the rank of the tensor.
- assert(llvm::all_of(llvm::zip(this->loop2InsLvl, this->ins), [](auto mvPair) {
+ assert(llvm::all_of(llvm::zip(loop2InsLvl, ins), [](auto mvPair) {
auto [m, v] = mvPair;
// For ranked types the rank must match.
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h
index b2a16e9382758..35e58edeb2562 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h
@@ -59,10 +59,10 @@ class IterationGraphSorter {
private:
// Private constructor.
- IterationGraphSorter(SmallVector<Value> &&ins,
- SmallVector<AffineMap> &&loop2InsLvl, Value out,
+ IterationGraphSorter(SmallVector<Value> &&insArg,
+ SmallVector<AffineMap> &&loop2InsLvlArg, Value out,
AffineMap loop2OutLvl,
- SmallVector<utils::IteratorType> &&iterTypes,
+ SmallVector<utils::IteratorType> &&iterTypesArg,
sparse_tensor::LoopOrderingStrategy strategy =
sparse_tensor::LoopOrderingStrategy::kDefault);
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
1. In 'Transforms.cpp' the debug macro is accessing a SmallVector variable that has been moved-from and reset. Fixed by reordering code for the move-from to happen last. 2. 'IterationGraphSorter' Refine the previous use-after-move fix for style/readability by renaming the private constructor args to resolve naming ambiguity with the class members. Testing: ninja check-mlir
bc90e79 to
26d05f8
Compare
1. In `Transforms.cpp` the debug macro is accessing a SmallVector variable that has been moved-from and reset. Fixed by reordering code for the move-from to happen last. 2. `IterationGraphSorter` Refine the previous use-after-move fix for style/readability by renaming the private constructor args to resolve naming ambiguity with the class members. Testing: `ninja check-mlir`
1. In `Transforms.cpp` the debug macro is accessing a SmallVector variable that has been moved-from and reset. Fixed by reordering code for the move-from to happen last. 2. `IterationGraphSorter` Refine the previous use-after-move fix for style/readability by renaming the private constructor args to resolve naming ambiguity with the class members. Testing: `ninja check-mlir`
In
Transforms.cppthe debug macro is accessing a SmallVector variable that has been moved-from and reset. Fixed by reordering code for the move-from to happen last.IterationGraphSorterRefine the previous use-after-move fix for style/readability by renaming the private constructor args to resolve naming ambiguity with the class members.Testing:
ninja check-mlir