Skip to content

Commit

Permalink
[Flang][OpenMP] Don't expect block arguments using early privatization (
Browse files Browse the repository at this point in the history
llvm#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.
  • Loading branch information
skatrak authored and 5c4lar committed Aug 29, 2024
1 parent a57d007 commit 235b1f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions flang/lib/Lower/OpenMP/DataSharingProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ class DataSharingProcessor {
getAllSymbolsToPrivatize() const {
return allPrivatizedSymbols;
}

llvm::ArrayRef<const semantics::Symbol *> getDelayedPrivSymbols() const {
return useDelayedPrivatization
? allPrivatizedSymbols.getArrayRef()
: llvm::ArrayRef<const semantics::Symbol *>();
}
};

} // namespace omp
Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ static void genBodyOfTargetOp(
}

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

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

llvm::SmallVector<const semantics::Symbol *> allSymbols(reductionSyms);
allSymbols.append(dsp.getAllSymbolsToPrivatize().begin(),
dsp.getAllSymbolsToPrivatize().end());
allSymbols.append(dsp.getDelayedPrivSymbols().begin(),
dsp.getDelayedPrivSymbols().end());

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

0 comments on commit 235b1f3

Please sign in to comment.