Skip to content

Commit 60e9fb9

Browse files
authored
[Flang][OpenMP] Don't expect block arguments using early privatization (#105842)
There are some spots where all symbols to privatize collected by a `DataSharingProcessor` instance are expected to have corresponding entry block arguments associated regardless of whether delayed privatization was enabled. This can result in compiler crashes if a `DataSharingProcessor` instance created with `useDelayedPrivatization=false` is queried in this way. The solution proposed by this patch is to provide another public method to query specifically delayed privatization symbols, which will either be empty or point to the complete set of symbols to privatize accordingly.
1 parent fdca2c3 commit 60e9fb9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ class DataSharingProcessor {
153153
getAllSymbolsToPrivatize() const {
154154
return allPrivatizedSymbols;
155155
}
156+
157+
llvm::ArrayRef<const semantics::Symbol *> getDelayedPrivSymbols() const {
158+
return useDelayedPrivatization
159+
? allPrivatizedSymbols.getArrayRef()
160+
: llvm::ArrayRef<const semantics::Symbol *>();
161+
}
156162
};
157163

158164
} // namespace omp

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ static void genBodyOfTargetOp(
882882
}
883883

884884
for (auto [argIndex, argSymbol] :
885-
llvm::enumerate(dsp.getAllSymbolsToPrivatize())) {
885+
llvm::enumerate(dsp.getDelayedPrivSymbols())) {
886886
argIndex = mapSyms.size() + argIndex;
887887

888888
const mlir::BlockArgument &arg = region.getArgument(argIndex);
@@ -1494,8 +1494,8 @@ genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
14941494
allRegionArgLocs);
14951495

14961496
llvm::SmallVector<const semantics::Symbol *> allSymbols(reductionSyms);
1497-
allSymbols.append(dsp.getAllSymbolsToPrivatize().begin(),
1498-
dsp.getAllSymbolsToPrivatize().end());
1497+
allSymbols.append(dsp.getDelayedPrivSymbols().begin(),
1498+
dsp.getDelayedPrivSymbols().end());
14991499

15001500
unsigned argIdx = 0;
15011501
for (const semantics::Symbol *arg : allSymbols) {

0 commit comments

Comments
 (0)