Skip to content

Commit 4ba4bfb

Browse files
[coverity issue] fix uninitialized var (#609)
1 parent a4122d3 commit 4ba4bfb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/Transforms/AddOuterParallelLoop.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct AddOuterParallelLoopPass
3131
auto func = getOperation();
3232
if (func.getBody().empty())
3333
return;
34-
std::vector<llvm::SmallVector<Operation *, 4>> groupedOps;
34+
llvm::SmallVector<llvm::SmallVector<Operation *, 4>, 4> groupedOps;
3535
// populate the top level for-loop
3636
for (auto topIt = func.getBody().front().begin();
3737
topIt != func.getBody().front().end();) {
@@ -69,13 +69,14 @@ struct AddOuterParallelLoopPass
6969
it = std::next(it);
7070
}
7171
if (!hasReturnOp) {
72-
Block::iterator endIt = ++endOp->getIterator();
72+
Block::iterator endIt = std::next(endOp->getIterator());
7373
topIt = endIt;
74-
llvm::SmallVector<Operation *, 4> ops; // (forOp->getIterator(), endIt);
75-
for (auto it = forOp->getIterator(); it != endIt; it++) {
74+
llvm::SmallVector<Operation *, 4> ops;
75+
for (auto it = forOp->getIterator(); it != endIt; it = std::next(it)) {
7676
ops.push_back(&*it);
7777
}
78-
groupedOps.push_back(ops);
78+
if (!ops.empty())
79+
groupedOps.push_back(ops);
7980
}
8081
}
8182
// move the for-loop and its users into the newly created parallel-loop

0 commit comments

Comments
 (0)