[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue May 21 07:26:10 PDT 2024
================
@@ -15097,14 +15125,75 @@ bool SemaOpenMP::checkTransformableLoopNest(
llvm_unreachable("Unhandled loop transformation");
if (!DependentPreInits)
return;
- llvm::append_range(OriginalInits.back(),
- cast<DeclStmt>(DependentPreInits)->getDeclGroup());
+ // CompoundStmts are used as lists of other statements, add their
+ // contents, not the lists themselves to avoid nesting. This is
+ // necessary because DeclStmts need to be visible after the pre-init.
+ else if (auto *CS = dyn_cast<CompoundStmt>(DependentPreInits))
+ llvm::append_range(OriginalInits.back(), CS->body());
+ else
+ OriginalInits.back().push_back(DependentPreInits);
----------------
alexey-bataev wrote:
Suggest moving this pattern to a function to avoid copying it.
https://github.com/llvm/llvm-project/pull/91459
More information about the cfe-commits
mailing list