[clang] [openmp] [OpenMP] Assign lastprivate loop counter init on empty worksharing loops (PR #243086)
Amit Tiwari via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 26 23:12:52 PST 2026
================
@@ -4075,14 +4063,25 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
// whole loop.
bool CondConstant;
llvm::BasicBlock *ContBlock = nullptr;
+ const Expr *EmptyLoopInit = getEmptyLoopLastprivateInit(S);
if (ConstantFoldsToSimpleInteger(S.getPreCond(), CondConstant)) {
- if (!CondConstant)
+ if (!CondConstant) {
+ if (EmptyLoopInit)
+ EmitIgnoredExpr(EmptyLoopInit);
return false;
+ }
} else {
llvm::BasicBlock *ThenBlock = createBasicBlock("omp.precond.then");
ContBlock = createBasicBlock("omp.precond.end");
- emitPreCond(*this, S, S.getPreCond(), ThenBlock, ContBlock,
+ llvm::BasicBlock *EmptyBlock =
----------------
loopacino wrote:
1) Renamed to `FalseBlock`, 2) Kept one `emitPreCond` call and 3) use `EmptyLoopInit` for both.
https://github.com/llvm/llvm-project/pull/243086
More information about the cfe-commits
mailing list