[OpenMP] Introduce the OpenMPOpt transformation pass
authorJohannes Doerfert <johannes@jdoerfert.de>
Thu, 7 Nov 2019 05:20:06 +0000 (23:20 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Sat, 8 Feb 2020 20:47:03 +0000 (14:47 -0600)
commit9548b74a831ea005649465797f359e0521f3b8a9
tree9926350a7344c63e0ceca262ead8d125a5c8c49b
parent72277ecd62e28a01bb98866c1b15d5f172ed30dc
[OpenMP] Introduce the OpenMPOpt transformation pass

The OpenMPOpt pass is a CGSCC pass in which OpenMP specific
optimizations can reside.

The OpenMPOpt pass uses the OpenMPKinds.def file to identify runtime
calls and their uses. This allows targeted transformations and eases
their implementation.

This initial patch deduplicates `__kmpc_global_thread_num` and
`omp_get_thread_num` calls. We can also identify arguments that are
equivalent to such a call result and use it instead. Later we can
determine "gtid" arguments based on the use in kernel functions etc.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D69930
20 files changed:
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/include/llvm/Transforms/IPO/OpenMPOpt.h [new file with mode: 0644]
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/CMakeLists.txt
llvm/lib/Transforms/IPO/IPO.cpp
llvm/lib/Transforms/IPO/LLVMBuild.txt
llvm/lib/Transforms/IPO/OpenMPOpt.cpp [new file with mode: 0644]
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Other/pass-pipelines.ll
llvm/test/Transforms/OpenMP/gtid.ll [new file with mode: 0644]