[PATCH] D121061: [OpenMPIRBuilder] Allocate temporary at the correct block in a nested parallel
William Moses via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 5 15:30:33 PST 2022
wsmoses created this revision.
wsmoses added reviewers: jdoerfert, ftynse, mehdi_amini, rriddle.
Herald added subscribers: Chia-hungDuan, ormris, guansong, hiraditya, yaxunl.
Herald added a project: All.
wsmoses requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1, stephenneuendorffer.
Herald added a project: LLVM.
The OpenMPIRBuilder has a bug. Specifically, suppose you have two nested openmp parallel regions (writing with MLIR for ease)
omp.parallel {
%a = ...
omp.parallel {
use(%a)
}
}
As OpenMP only permits pointer-like inputs, the builder will wrap all of the inputs into a stack allocation, and then pass this
allocation to the inner parallel. For example, we would want to get something like the following:
omp.parallel {
%a = ...
%tmp = alloc
store %tmp[] = %a
kmpc_fork(outlined, %tmp)
}
However, in practice, this is not what currently occurs in the context of nested parallel regions. Specifically to the OpenMPIRBuilder,
the entirety of the function (at the LLVM level) is currently inlined with blocks marking the corresponding start and end of each
region.
entry:
...
parallel1:
%a = ...
...
parallel2:
use(%a)
...
endparallel2:
...
endparallel1:
...
When the allocation is inserted, it presently inserted into the parent of the entire function (e.g. entry) rather than the parent
allocation scope to the function being outlined. If we were outlining parallel2, the corresponding alloca location would be parallel1.
This causes a variety of bugs, including https://github.com/llvm/llvm-project/issues/54165 as one example.
This PR allows the stack allocation to be created at the correct allocation block, and thus remedies such issues.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121061
Files:
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Transforms/Utils/CodeExtractor.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121061.413258.patch
Type: text/x-patch
Size: 6903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220305/69657ecb/attachment.bin>
More information about the llvm-commits
mailing list