Author: Duncan P. N. Exon Smith Date: 2021-12-08T15:22:50-08:00 New Revision: cfd1d49dc0cc4369ace2e9485bdba04b27f158b5
URL: https://github.com/llvm/llvm-project/commit/cfd1d49dc0cc4369ace2e9485bdba04b27f158b5 DIFF: https://github.com/llvm/llvm-project/commit/cfd1d49dc0cc4369ace2e9485bdba04b27f158b5.diff LOG: 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 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index f6853a22cd361..6f0ef7bb7fe52 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1972,7 +1972,7 @@ CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest(const Stmt *S, int Depth) { // 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; diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index d5776964889b4..81f5ec54d1ce3 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -1831,7 +1831,7 @@ OpenMPIRBuilder::collapseLoops(DebugLoc DL, ArrayRef<CanonicalLoopInfo *> Loops, 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(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits