Skip to content

Commit 815910b

Browse files
committed
[Flang][OpenMP] Access full list of entry block syms and vars (NFC)
This patch adds methods to `EntryBlockArgs` to access the full list of entry block argument-related symbols and variables, in their standard order. This helps centralizing this logic in as few places as possible to avoid future inconsistencies.
1 parent 2de1fc8 commit 815910b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ struct EntryBlockArgs {
7676
reduction.isValid() && taskReduction.isValid() &&
7777
useDeviceAddr.isValid() && useDevicePtr.isValid();
7878
}
79+
80+
auto getSyms() const {
81+
return llvm::concat<const semantics::Symbol *const>(
82+
inReduction.syms, map.syms, priv.syms, reduction.syms,
83+
taskReduction.syms, useDeviceAddr.syms, useDevicePtr.syms);
84+
}
85+
86+
auto getVars() const {
87+
return llvm::concat<const mlir::Value>(
88+
inReduction.vars, map.vars, priv.vars, reduction.vars,
89+
taskReduction.vars, useDeviceAddr.vars, useDevicePtr.vars);
90+
}
7991
};
8092
} // namespace
8193

@@ -1506,8 +1518,7 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
15061518
genEntryBlock(converter, args, op->getRegion(0));
15071519
bindEntryBlockArgs(
15081520
converter, llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op), args);
1509-
return llvm::to_vector(llvm::concat<const semantics::Symbol *const>(
1510-
args.priv.syms, args.reduction.syms));
1521+
return llvm::to_vector(args.getSyms());
15111522
};
15121523

15131524
assert((!enableDelayedPrivatization || dsp) &&
@@ -1581,11 +1592,11 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
15811592
mlir::Operation *terminator =
15821593
lower::genOpenMPTerminator(builder, sectionsOp, loc);
15831594

1584-
auto reductionCallback = [&](mlir::Operation *op) {
1595+
auto genRegionEntryCB = [&](mlir::Operation *op) {
15851596
genEntryBlock(converter, args, op->getRegion(0));
15861597
bindEntryBlockArgs(
15871598
converter, llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op), args);
1588-
return reductionSyms;
1599+
return llvm::to_vector(args.getSyms());
15891600
};
15901601

15911602
// Generate nested SECTION constructs.
@@ -1611,7 +1622,7 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
16111622
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, nestedEval,
16121623
llvm::omp::Directive::OMPD_section)
16131624
.setClauses(&sectionQueue.begin()->clauses)
1614-
.setGenRegionEntryCb(reductionCallback),
1625+
.setGenRegionEntryCb(genRegionEntryCB),
16151626
sectionQueue, sectionQueue.begin());
16161627
}
16171628

0 commit comments

Comments
 (0)