LLVM  13.0.0git
OpenMPOpt.h
Go to the documentation of this file.
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 
14 #include "llvm/IR/PassManager.h"
15 
16 namespace llvm {
17 
18 namespace omp {
19 
20 /// Summary of a kernel (=entry point for target offloading).
21 using Kernel = Function *;
22 
23 /// Helper to remember if the module contains OpenMP (runtime calls), to be used
24 /// foremost with containsOpenMP.
26  OpenMPInModule &operator=(bool Found) {
27  if (Found)
28  Value = OpenMPInModule::OpenMP::FOUND;
29  else
30  Value = OpenMPInModule::OpenMP::NOT_FOUND;
31  return *this;
32  }
33  bool isKnown() { return Value != OpenMP::UNKNOWN; }
34  operator bool() { return Value != OpenMP::NOT_FOUND; }
35 
36  /// Does this function \p F contain any OpenMP runtime calls?
38  return FuncsWithOMPRuntimeCalls.contains(F);
39  }
40 
41  /// Return the known kernels (=GPU entry points) in the module.
42  SmallPtrSetImpl<Kernel> &getKernels() { return Kernels; }
43 
44  /// Identify kernels in the module and populate the Kernels set.
45  void identifyKernels(Module &M);
46 
47 private:
48  enum class OpenMP { FOUND, NOT_FOUND, UNKNOWN } Value = OpenMP::UNKNOWN;
49 
50  friend bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule);
51 
52  /// In which functions are OpenMP runtime calls present?
53  SmallPtrSet<Function *, 32> FuncsWithOMPRuntimeCalls;
54 
55  /// Collection of known kernels (=GPU entry points) in the module.
56  SmallPtrSet<Kernel, 8> Kernels;
57 };
58 
59 /// Helper to determine if \p M contains OpenMP (runtime calls).
60 bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule);
61 
62 } // namespace omp
63 
64 /// OpenMP optimizations pass.
65 class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
66  /// Helper to remember if the module contains OpenMP (runtime calls).
67  omp::OpenMPInModule OMPInModule;
68 
69 public:
71 };
72 
73 class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> {
74  /// Helper to remember if the module contains OpenMP (runtime calls).
75  omp::OpenMPInModule OMPInModule;
76 
77 public:
80 };
81 
82 } // end namespace llvm
83 
84 #endif // LLVM_TRANSFORMS_IPO_OPENMPOPT_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
llvm::OpenMPOptCGSCCPass::run
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
Definition: OpenMPOpt.cpp:2505
llvm::omp::OpenMPInModule::identifyKernels
void identifyKernels(Module &M)
Identify kernels in the module and populate the Kernels set.
Definition: OpenMPOpt.cpp:2637
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:421
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::OpenMPOptCGSCCPass
Definition: OpenMPOpt.h:73
llvm::omp::OpenMPInModule::getKernels
SmallPtrSetImpl< Kernel > & getKernels()
Return the known kernels (=GPU entry points) in the module.
Definition: OpenMPOpt.h:42
LazyCallGraph.h
llvm::omp::containsOpenMP
bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule)
Helper to determine if M contains OpenMP (runtime calls).
Definition: OpenMPOpt.cpp:2661
llvm::omp::OpenMPInModule::operator=
OpenMPInModule & operator=(bool Found)
Definition: OpenMPOpt.h:26
CGSCCPassManager.h
llvm::omp::OpenMPInModule::containsOMPRuntimeCalls
bool containsOMPRuntimeCalls(Function *F) const
Does this function F contain any OpenMP runtime calls?
Definition: OpenMPOpt.h:37
llvm::omp::OpenMPInModule::containsOpenMP
friend bool containsOpenMP(Module &M, OpenMPInModule &OMPInModule)
Helper to determine if M contains OpenMP (runtime calls).
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::CGSCCUpdateResult
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
Definition: CGSCCPassManager.h:232
llvm::OpenMPOptPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: OpenMPOpt.cpp:2463
llvm::omp::OpenMPInModule::isKnown
bool isKnown()
Definition: OpenMPOpt.h:33
PassManager.h
llvm::OpenMPOptPass
OpenMP optimizations pass.
Definition: OpenMPOpt.h:65
llvm::omp::OpenMPInModule
Helper to remember if the module contains OpenMP (runtime calls), to be used foremost with containsOp...
Definition: OpenMPOpt.h:25
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::LazyCallGraph
A lazily constructed view of the call graph of a module.
Definition: LazyCallGraph.h:112
llvm::Value
LLVM Value Representation.
Definition: Value.h:75