[clang] [openmp] [Clang][OpenMP] Guard Inner flatten inits on enclosing loop trip counts (PR #237907)
Michael Kruse via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 04:52:44 PST 2026
================
@@ -17580,12 +17580,24 @@ SemaOpenMP::ActOnOpenMPFlattenDirective(ArrayRef<OMPClause *> Clauses,
// Collect pre-init statements in outer-to-inner order.
SmallVector<Stmt *> PreInits;
+ SmallVector<SmallVector<Stmt *, 2>, 4> GatedInits(NumLoops);
----------------
Meinersbur wrote:
```suggestion
SmallVector<SmallVector<Stmt *, 0>, 4> GatedInits(NumLoops);
```
[nit] SmallVector inside other contrainers are problematic, they use space no matter how many items they store. A small size of `1` would also be fine if we know that there are few empty lists. `2` seems unmotivated for the cost it brings. Consider that the critical case is not when `GatedInits` itself is small and it finishes quickly anyway, but when it becomes really big (memory constraints). Not that I expect that in this case, but generally to keep in mind.
https://github.com/llvm/llvm-project/pull/237907
More information about the cfe-commits
mailing list