[OpenMP] Eliminate redundant barriers in the same block
authorJohannes Doerfert <johannes@jdoerfert.de>
Sat, 22 Jan 2022 22:24:52 +0000 (16:24 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Tue, 1 Feb 2022 07:07:50 +0000 (01:07 -0600)
commit3c8a4c6f471765451a1b074eb589c9ad367a8e3c
tree53ed29310ed622aa37fc198e949238b9df87623c
parent989674f110548866f149b964288d8a84f0d60f40
[OpenMP] Eliminate redundant barriers in the same block

Patch originally by Giorgis Georgakoudis (@ggeorgakoudis), typos and
bugs introduced later by me.

This patch allows us to remove redundant barriers if they are part
of a "consecutive" pair of barriers in a basic block with no impacted
memory effect (read or write) in-between them. Memory accesses to
local (=thread private) or constant memory are allowed to appear.
Technically we could also allow any other memory that is not used to
share information between threads, e.g., the result of a malloc that
is also not captured. However, it will be easier to do more reasoning
once the code is put into an AA. That will also allow us to look through
phis/selects reasonably. At that point we should also deal with calls,
barriers in different blocks, and other complexities.

Differential Revision: https://reviews.llvm.org/D118002
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/barrier_removal.ll [new file with mode: 0644]
openmp/docs/remarks/OMP180.rst
openmp/docs/remarks/OMP190.rst [new file with mode: 0644]
openmp/docs/remarks/OptimizationRemarks.rst