[PATCH] D115378: OpenMP: Avoid using SmallVector::set_size()
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 8 12:35:54 PST 2021
dexonsmith created this revision.
dexonsmith added a reviewer: Meinersbur.
Herald added subscribers: guansong, hiraditya, yaxunl.
dexonsmith requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added projects: clang, LLVM.
Update `OpenMPIRBuilder::collapseLoops()` to call `resize()` instead of
`set_size()`. The latter asserts on capacity limits and cannot grow,
which seems likely to be unintentional here (if it is, I think a local
assertion would be good for clarity).
Also update `CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest()` to
use `pop_back_n()` instead of `set_size()`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115378
Files:
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1831,7 +1831,7 @@
Value *Leftover = Result->getIndVar();
SmallVector<Value *> NewIndVars;
- NewIndVars.set_size(NumLoops);
+ NewIndVars.resize(NumLoops);
for (int i = NumLoops - 1; i >= 1; --i) {
Value *OrigTripCount = Loops[i]->getTripCount();
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1972,7 +1972,7 @@
// Pop the \p Depth loops requested by the call from that stack and restore
// the previous context.
- OMPLoopNestStack.set_size(OMPLoopNestStack.size() - Depth);
+ OMPLoopNestStack.pop_back_n(Depth);
ExpectedOMPLoopDepth = ParentExpectedOMPLoopDepth;
return Result;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115378.392874.patch
Type: text/x-patch
Size: 973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211208/4367baa1/attachment-0001.bin>
More information about the llvm-commits
mailing list