Skip to content

Commit cfd1d49

Browse files
committed
OpenMP: Avoid using SmallVector::set_size()
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()`. Differential Revision: https://reviews.llvm.org/D115378
1 parent ccf1469 commit cfd1d49

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest(const Stmt *S, int Depth) {
19721972

19731973
// Pop the \p Depth loops requested by the call from that stack and restore
19741974
// the previous context.
1975-
OMPLoopNestStack.set_size(OMPLoopNestStack.size() - Depth);
1975+
OMPLoopNestStack.pop_back_n(Depth);
19761976
ExpectedOMPLoopDepth = ParentExpectedOMPLoopDepth;
19771977

19781978
return Result;

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ OpenMPIRBuilder::collapseLoops(DebugLoc DL, ArrayRef<CanonicalLoopInfo *> Loops,
18311831

18321832
Value *Leftover = Result->getIndVar();
18331833
SmallVector<Value *> NewIndVars;
1834-
NewIndVars.set_size(NumLoops);
1834+
NewIndVars.resize(NumLoops);
18351835
for (int i = NumLoops - 1; i >= 1; --i) {
18361836
Value *OrigTripCount = Loops[i]->getTripCount();
18371837

0 commit comments

Comments
 (0)