1//===- IPO/OpenMPOpt.h - Collection of OpenMP optimizations -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TRANSFORMS_IPO_OPENMPOPT_H
10#define LLVM_TRANSFORMS_IPO_OPENMPOPT_H
11
12#include "llvm/Analysis/CGSCCPassManager.h"
13#include "llvm/Analysis/LazyCallGraph.h"
14#include "llvm/IR/PassManager.h"
15
16namespace llvm {
17
18namespace omp {
19
20/// Summary of a kernel (=entry point for target offloading).
21using Kernel = Function *;
22
23/// Set of kernels in the module
24using KernelSet = SetVector<Kernel>;
25
26/// Helper to determine if \p M contains OpenMP.
27bool containsOpenMP(Module &M);
28
29/// Helper to determine if \p M is a OpenMP target offloading device module.
30bool isOpenMPDevice(Module &M);
31
32/// Return true iff \p Fn is an OpenMP GPU kernel; \p Fn has the "kernel"
33/// attribute.
34bool isOpenMPKernel(Function &Fn);
35
36/// Get OpenMP device kernels in \p M.
37KernelSet getDeviceKernels(Module &M);
38
39} // namespace omp
40
41/// OpenMP optimizations pass.
42class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
43public:
44 OpenMPOptPass() = default;
45 OpenMPOptPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
46
47 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
48
49private:
50 const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
51};
52
53class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> {
54public:
55 OpenMPOptCGSCCPass() = default;
56 OpenMPOptCGSCCPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
57
58 PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
59 LazyCallGraph &CG, CGSCCUpdateResult &UR);
60
61private:
62 const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
63};
64
65} // end namespace llvm
66
67#endif // LLVM_TRANSFORMS_IPO_OPENMPOPT_H
68

source code of llvm/include/llvm/Transforms/IPO/OpenMPOpt.h