LLVM  14.0.0git
OMPIRBuilder.h
Go to the documentation of this file.
1 //===- IR/OpenMPIRBuilder.h - OpenMP encoding builder for LLVM IR - 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 // This file defines the OpenMPIRBuilder class and helpers used as a convenient
10 // way to create LLVM instructions for OpenMP directives.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
15 #define LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
16 
18 #include "llvm/IR/DebugLoc.h"
19 #include "llvm/IR/IRBuilder.h"
20 #include "llvm/Support/Allocator.h"
21 #include <forward_list>
22 
23 namespace llvm {
24 class CanonicalLoopInfo;
25 
26 /// An interface to create LLVM-IR for OpenMP directives.
27 ///
28 /// Each OpenMP directive has a corresponding public generator method.
30 public:
31  /// Create a new OpenMPIRBuilder operating on the given module \p M. This will
32  /// not have an effect on \p M (see initialize).
33  OpenMPIRBuilder(Module &M) : M(M), Builder(M.getContext()) {}
35 
36  /// Initialize the internal state, this will put structures types and
37  /// potentially other helpers into the underlying module. Must be called
38  /// before any other method and only once!
39  void initialize();
40 
41  /// Finalize the underlying module, e.g., by outlining regions.
42  /// \param Fn The function to be finalized. If not used,
43  /// all functions are finalized.
44  /// \param AllowExtractorSinking Flag to include sinking instructions,
45  /// emitted by CodeExtractor, in the
46  /// outlined region. Default is false.
47  void finalize(Function *Fn = nullptr, bool AllowExtractorSinking = false);
48 
49  /// Add attributes known for \p FnID to \p Fn.
51 
52  /// Type used throughout for insertion points.
54 
55  /// Callback type for variable finalization (think destructors).
56  ///
57  /// \param CodeGenIP is the insertion point at which the finalization code
58  /// should be placed.
59  ///
60  /// A finalize callback knows about all objects that need finalization, e.g.
61  /// destruction, when the scope of the currently generated construct is left
62  /// at the time, and location, the callback is invoked.
64 
66  /// The finalization callback provided by the last in-flight invocation of
67  /// createXXXX for the directive of kind DK.
69 
70  /// The directive kind of the innermost directive that has an associated
71  /// region which might require finalization when it is left.
72  omp::Directive DK;
73 
74  /// Flag to indicate if the directive is cancellable.
76  };
77 
78  /// Push a finalization callback on the finalization stack.
79  ///
80  /// NOTE: Temporary solution until Clang CG is gone.
82  FinalizationStack.push_back(FI);
83  }
84 
85  /// Pop the last finalization callback from the finalization stack.
86  ///
87  /// NOTE: Temporary solution until Clang CG is gone.
88  void popFinalizationCB() { FinalizationStack.pop_back(); }
89 
90  /// Callback type for body (=inner region) code generation
91  ///
92  /// The callback takes code locations as arguments, each describing a
93  /// location at which code might need to be generated or a location that is
94  /// the target of control transfer.
95  ///
96  /// \param AllocaIP is the insertion point at which new alloca instructions
97  /// should be placed.
98  /// \param CodeGenIP is the insertion point at which the body code should be
99  /// placed.
100  /// \param ContinuationBB is the basic block target to leave the body.
101  ///
102  /// Note that all blocks pointed to by the arguments have terminators.
103  using BodyGenCallbackTy =
104  function_ref<void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
105  BasicBlock &ContinuationBB)>;
106 
107  // This is created primarily for sections construct as llvm::function_ref
108  // (BodyGenCallbackTy) is not storable (as described in the comments of
109  // function_ref class - function_ref contains non-ownable reference
110  // to the callable.
112  std::function<void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
113  BasicBlock &ContinuationBB)>;
114 
115  /// Callback type for loop body code generation.
116  ///
117  /// \param CodeGenIP is the insertion point where the loop's body code must be
118  /// placed. This will be a dedicated BasicBlock with a
119  /// conditional branch from the loop condition check and
120  /// terminated with an unconditional branch to the loop
121  /// latch.
122  /// \param IndVar is the induction variable usable at the insertion point.
123  using LoopBodyGenCallbackTy =
124  function_ref<void(InsertPointTy CodeGenIP, Value *IndVar)>;
125 
126  /// Callback type for variable privatization (think copy & default
127  /// constructor).
128  ///
129  /// \param AllocaIP is the insertion point at which new alloca instructions
130  /// should be placed.
131  /// \param CodeGenIP is the insertion point at which the privatization code
132  /// should be placed.
133  /// \param Original The value being copied/created, should not be used in the
134  /// generated IR.
135  /// \param Inner The equivalent of \p Original that should be used in the
136  /// generated IR; this is equal to \p Original if the value is
137  /// a pointer and can thus be passed directly, otherwise it is
138  /// an equivalent but different value.
139  /// \param ReplVal The replacement value, thus a copy or new created version
140  /// of \p Inner.
141  ///
142  /// \returns The new insertion point where code generation continues and
143  /// \p ReplVal the replacement value.
145  InsertPointTy AllocaIP, InsertPointTy CodeGenIP, Value &Original,
146  Value &Inner, Value *&ReplVal)>;
147 
148  /// Description of a LLVM-IR insertion point (IP) and a debug/source location
149  /// (filename, line, column, ...).
151  template <typename T, typename U>
153  : IP(IRB.saveIP()), DL(IRB.getCurrentDebugLocation()) {}
156  : IP(IP), DL(DL) {}
159  };
160 
161  /// Emitter methods for OpenMP directives.
162  ///
163  ///{
164 
165  /// Generator for '#omp barrier'
166  ///
167  /// \param Loc The location where the barrier directive was encountered.
168  /// \param DK The kind of directive that caused the barrier.
169  /// \param ForceSimpleCall Flag to force a simple (=non-cancellation) barrier.
170  /// \param CheckCancelFlag Flag to indicate a cancel barrier return value
171  /// should be checked and acted upon.
172  ///
173  /// \returns The insertion point after the barrier.
174  InsertPointTy createBarrier(const LocationDescription &Loc, omp::Directive DK,
175  bool ForceSimpleCall = false,
176  bool CheckCancelFlag = true);
177 
178  /// Generator for '#omp cancel'
179  ///
180  /// \param Loc The location where the directive was encountered.
181  /// \param IfCondition The evaluated 'if' clause expression, if any.
182  /// \param CanceledDirective The kind of directive that is cancled.
183  ///
184  /// \returns The insertion point after the barrier.
185  InsertPointTy createCancel(const LocationDescription &Loc, Value *IfCondition,
186  omp::Directive CanceledDirective);
187 
188  /// Generator for '#omp parallel'
189  ///
190  /// \param Loc The insert and source location description.
191  /// \param AllocaIP The insertion points to be used for alloca instructions.
192  /// \param BodyGenCB Callback that will generate the region code.
193  /// \param PrivCB Callback to copy a given variable (think copy constructor).
194  /// \param FiniCB Callback to finalize variable copies.
195  /// \param IfCondition The evaluated 'if' clause expression, if any.
196  /// \param NumThreads The evaluated 'num_threads' clause expression, if any.
197  /// \param ProcBind The value of the 'proc_bind' clause (see ProcBindKind).
198  /// \param IsCancellable Flag to indicate a cancellable parallel region.
199  ///
200  /// \returns The insertion position *after* the parallel.
202  createParallel(const LocationDescription &Loc, InsertPointTy AllocaIP,
203  BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB,
204  FinalizeCallbackTy FiniCB, Value *IfCondition,
205  Value *NumThreads, omp::ProcBindKind ProcBind,
206  bool IsCancellable);
207 
208  /// Generator for the control flow structure of an OpenMP canonical loop.
209  ///
210  /// This generator operates on the logical iteration space of the loop, i.e.
211  /// the caller only has to provide a loop trip count of the loop as defined by
212  /// base language semantics. The trip count is interpreted as an unsigned
213  /// integer. The induction variable passed to \p BodyGenCB will be of the same
214  /// type and run from 0 to \p TripCount - 1. It is up to the callback to
215  /// convert the logical iteration variable to the loop counter variable in the
216  /// loop body.
217  ///
218  /// \param Loc The insert and source location description. The insert
219  /// location can be between two instructions or the end of a
220  /// degenerate block (e.g. a BB under construction).
221  /// \param BodyGenCB Callback that will generate the loop body code.
222  /// \param TripCount Number of iterations the loop body is executed.
223  /// \param Name Base name used to derive BB and instruction names.
224  ///
225  /// \returns An object representing the created control flow structure which
226  /// can be used for loop-associated directives.
228  LoopBodyGenCallbackTy BodyGenCB,
229  Value *TripCount,
230  const Twine &Name = "loop");
231 
232  /// Generator for the control flow structure of an OpenMP canonical loop.
233  ///
234  /// Instead of a logical iteration space, this allows specifying user-defined
235  /// loop counter values using increment, upper- and lower bounds. To
236  /// disambiguate the terminology when counting downwards, instead of lower
237  /// bounds we use \p Start for the loop counter value in the first body
238  /// iteration.
239  ///
240  /// Consider the following limitations:
241  ///
242  /// * A loop counter space over all integer values of its bit-width cannot be
243  /// represented. E.g using uint8_t, its loop trip count of 256 cannot be
244  /// stored into an 8 bit integer):
245  ///
246  /// DO I = 0, 255, 1
247  ///
248  /// * Unsigned wrapping is only supported when wrapping only "once"; E.g.
249  /// effectively counting downwards:
250  ///
251  /// for (uint8_t i = 100u; i > 0; i += 127u)
252  ///
253  ///
254  /// TODO: May need to add additional parameters to represent:
255  ///
256  /// * Allow representing downcounting with unsigned integers.
257  ///
258  /// * Sign of the step and the comparison operator might disagree:
259  ///
260  /// for (int i = 0; i < 42; i -= 1u)
261  ///
262  //
263  /// \param Loc The insert and source location description.
264  /// \param BodyGenCB Callback that will generate the loop body code.
265  /// \param Start Value of the loop counter for the first iterations.
266  /// \param Stop Loop counter values past this will stop the loop.
267  /// \param Step Loop counter increment after each iteration; negative
268  /// means counting down.
269  /// \param IsSigned Whether Start, Stop and Step are signed integers.
270  /// \param InclusiveStop Whether \p Stop itself is a valid value for the loop
271  /// counter.
272  /// \param ComputeIP Insertion point for instructions computing the trip
273  /// count. Can be used to ensure the trip count is available
274  /// at the outermost loop of a loop nest. If not set,
275  /// defaults to the preheader of the generated loop.
276  /// \param Name Base name used to derive BB and instruction names.
277  ///
278  /// \returns An object representing the created control flow structure which
279  /// can be used for loop-associated directives.
281  LoopBodyGenCallbackTy BodyGenCB,
282  Value *Start, Value *Stop, Value *Step,
283  bool IsSigned, bool InclusiveStop,
284  InsertPointTy ComputeIP = {},
285  const Twine &Name = "loop");
286 
287  /// Collapse a loop nest into a single loop.
288  ///
289  /// Merges loops of a loop nest into a single CanonicalLoopNest representation
290  /// that has the same number of innermost loop iterations as the origin loop
291  /// nest. The induction variables of the input loops are derived from the
292  /// collapsed loop's induction variable. This is intended to be used to
293  /// implement OpenMP's collapse clause. Before applying a directive,
294  /// collapseLoops normalizes a loop nest to contain only a single loop and the
295  /// directive's implementation does not need to handle multiple loops itself.
296  /// This does not remove the need to handle all loop nest handling by
297  /// directives, such as the ordered(<n>) clause or the simd schedule-clause
298  /// modifier of the worksharing-loop directive.
299  ///
300  /// Example:
301  /// \code
302  /// for (int i = 0; i < 7; ++i) // Canonical loop "i"
303  /// for (int j = 0; j < 9; ++j) // Canonical loop "j"
304  /// body(i, j);
305  /// \endcode
306  ///
307  /// After collapsing with Loops={i,j}, the loop is changed to
308  /// \code
309  /// for (int ij = 0; ij < 63; ++ij) {
310  /// int i = ij / 9;
311  /// int j = ij % 9;
312  /// body(i, j);
313  /// }
314  /// \endcode
315  ///
316  /// In the current implementation, the following limitations apply:
317  ///
318  /// * All input loops have an induction variable of the same type.
319  ///
320  /// * The collapsed loop will have the same trip count integer type as the
321  /// input loops. Therefore it is possible that the collapsed loop cannot
322  /// represent all iterations of the input loops. For instance, assuming a
323  /// 32 bit integer type, and two input loops both iterating 2^16 times, the
324  /// theoretical trip count of the collapsed loop would be 2^32 iteration,
325  /// which cannot be represented in an 32-bit integer. Behavior is undefined
326  /// in this case.
327  ///
328  /// * The trip counts of every input loop must be available at \p ComputeIP.
329  /// Non-rectangular loops are not yet supported.
330  ///
331  /// * At each nest level, code between a surrounding loop and its nested loop
332  /// is hoisted into the loop body, and such code will be executed more
333  /// often than before collapsing (or not at all if any inner loop iteration
334  /// has a trip count of 0). This is permitted by the OpenMP specification.
335  ///
336  /// \param DL Debug location for instructions added for collapsing,
337  /// such as instructions to compute/derive the input loop's
338  /// induction variables.
339  /// \param Loops Loops in the loop nest to collapse. Loops are specified
340  /// from outermost-to-innermost and every control flow of a
341  /// loop's body must pass through its directly nested loop.
342  /// \param ComputeIP Where additional instruction that compute the collapsed
343  /// trip count. If not set, defaults to before the generated
344  /// loop.
345  ///
346  /// \returns The CanonicalLoopInfo object representing the collapsed loop.
349  InsertPointTy ComputeIP);
350 
351  /// Modifies the canonical loop to be a statically-scheduled workshare loop.
352  ///
353  /// This takes a \p LoopInfo representing a canonical loop, such as the one
354  /// created by \p createCanonicalLoop and emits additional instructions to
355  /// turn it into a workshare loop. In particular, it calls to an OpenMP
356  /// runtime function in the preheader to obtain the loop bounds to be used in
357  /// the current thread, updates the relevant instructions in the canonical
358  /// loop and calls to an OpenMP runtime finalization function after the loop.
359  ///
360  /// TODO: Workshare loops with static scheduling may contain up to two loops
361  /// that fulfill the requirements of an OpenMP canonical loop. One for
362  /// iterating over all iterations of a chunk and another one for iterating
363  /// over all chunks that are executed on the same thread. Returning
364  /// CanonicalLoopInfo objects representing them may eventually be useful for
365  /// the apply clause planned in OpenMP 6.0, but currently whether these are
366  /// canonical loops is irrelevant.
367  ///
368  /// \param DL Debug location for instructions added for the
369  /// workshare-loop construct itself.
370  /// \param CLI A descriptor of the canonical loop to workshare.
371  /// \param AllocaIP An insertion point for Alloca instructions usable in the
372  /// preheader of the loop.
373  /// \param NeedsBarrier Indicates whether a barrier must be inserted after
374  /// the loop.
375  /// \param Chunk The size of loop chunk considered as a unit when
376  /// scheduling. If \p nullptr, defaults to 1.
377  ///
378  /// \returns Point where to insert code after the workshare construct.
380  InsertPointTy AllocaIP,
381  bool NeedsBarrier,
382  Value *Chunk = nullptr);
383 
384  /// Modifies the canonical loop to be a dynamically-scheduled workshare loop.
385  ///
386  /// This takes a \p LoopInfo representing a canonical loop, such as the one
387  /// created by \p createCanonicalLoop and emits additional instructions to
388  /// turn it into a workshare loop. In particular, it calls to an OpenMP
389  /// runtime function in the preheader to obtain, and then in each iteration
390  /// to update the loop counter.
391  ///
392  /// \param DL Debug location for instructions added for the
393  /// workshare-loop construct itself.
394  /// \param CLI A descriptor of the canonical loop to workshare.
395  /// \param AllocaIP An insertion point for Alloca instructions usable in the
396  /// preheader of the loop.
397  /// \param SchedType Type of scheduling to be passed to the init function.
398  /// \param NeedsBarrier Indicates whether a barrier must be insterted after
399  /// the loop.
400  /// \param Chunk The size of loop chunk considered as a unit when
401  /// scheduling. If \p nullptr, defaults to 1.
402  ///
403  /// \returns Point where to insert code after the workshare construct.
405  InsertPointTy AllocaIP,
406  omp::OMPScheduleType SchedType,
407  bool NeedsBarrier,
408  Value *Chunk = nullptr);
409 
410  /// Modifies the canonical loop to be a workshare loop.
411  ///
412  /// This takes a \p LoopInfo representing a canonical loop, such as the one
413  /// created by \p createCanonicalLoop and emits additional instructions to
414  /// turn it into a workshare loop. In particular, it calls to an OpenMP
415  /// runtime function in the preheader to obtain the loop bounds to be used in
416  /// the current thread, updates the relevant instructions in the canonical
417  /// loop and calls to an OpenMP runtime finalization function after the loop.
418  ///
419  /// \param DL Debug location for instructions added for the
420  /// workshare-loop construct itself.
421  /// \param CLI A descriptor of the canonical loop to workshare.
422  /// \param AllocaIP An insertion point for Alloca instructions usable in the
423  /// preheader of the loop.
424  /// \param NeedsBarrier Indicates whether a barrier must be insterted after
425  /// the loop.
426  ///
427  /// \returns Point where to insert code after the workshare construct.
429  InsertPointTy AllocaIP, bool NeedsBarrier);
430 
431  /// Tile a loop nest.
432  ///
433  /// Tiles the loops of \p Loops by the tile sizes in \p TileSizes. Loops in
434  /// \p/ Loops must be perfectly nested, from outermost to innermost loop
435  /// (i.e. Loops.front() is the outermost loop). The trip count llvm::Value
436  /// of every loop and every tile sizes must be usable in the outermost
437  /// loop's preheader. This implies that the loop nest is rectangular.
438  ///
439  /// Example:
440  /// \code
441  /// for (int i = 0; i < 15; ++i) // Canonical loop "i"
442  /// for (int j = 0; j < 14; ++j) // Canonical loop "j"
443  /// body(i, j);
444  /// \endcode
445  ///
446  /// After tiling with Loops={i,j} and TileSizes={5,7}, the loop is changed to
447  /// \code
448  /// for (int i1 = 0; i1 < 3; ++i1)
449  /// for (int j1 = 0; j1 < 2; ++j1)
450  /// for (int i2 = 0; i2 < 5; ++i2)
451  /// for (int j2 = 0; j2 < 7; ++j2)
452  /// body(i1*3+i2, j1*3+j2);
453  /// \endcode
454  ///
455  /// The returned vector are the loops {i1,j1,i2,j2}. The loops i1 and j1 are
456  /// referred to the floor, and the loops i2 and j2 are the tiles. Tiling also
457  /// handles non-constant trip counts, non-constant tile sizes and trip counts
458  /// that are not multiples of the tile size. In the latter case the tile loop
459  /// of the last floor-loop iteration will have fewer iterations than specified
460  /// as its tile size.
461  ///
462  ///
463  /// @param DL Debug location for instructions added by tiling, for
464  /// instance the floor- and tile trip count computation.
465  /// @param Loops Loops to tile. The CanonicalLoopInfo objects are
466  /// invalidated by this method, i.e. should not used after
467  /// tiling.
468  /// @param TileSizes For each loop in \p Loops, the tile size for that
469  /// dimensions.
470  ///
471  /// \returns A list of generated loops. Contains twice as many loops as the
472  /// input loop nest; the first half are the floor loops and the
473  /// second half are the tile loops.
474  std::vector<CanonicalLoopInfo *>
476  ArrayRef<Value *> TileSizes);
477 
478  /// Fully unroll a loop.
479  ///
480  /// Instead of unrolling the loop immediately (and duplicating its body
481  /// instructions), it is deferred to LLVM's LoopUnrollPass by adding loop
482  /// metadata.
483  ///
484  /// \param DL Debug location for instructions added by unrolling.
485  /// \param Loop The loop to unroll. The loop will be invalidated.
487 
488  /// Fully or partially unroll a loop. How the loop is unrolled is determined
489  /// using LLVM's LoopUnrollPass.
490  ///
491  /// \param DL Debug location for instructions added by unrolling.
492  /// \param Loop The loop to unroll. The loop will be invalidated.
494 
495  /// Partially unroll a loop.
496  ///
497  /// The CanonicalLoopInfo of the unrolled loop for use with chained
498  /// loop-associated directive can be requested using \p UnrolledCLI. Not
499  /// needing the CanonicalLoopInfo allows more efficient code generation by
500  /// deferring the actual unrolling to the LoopUnrollPass using loop metadata.
501  /// A loop-associated directive applied to the unrolled loop needs to know the
502  /// new trip count which means that if using a heuristically determined unroll
503  /// factor (\p Factor == 0), that factor must be computed immediately. We are
504  /// using the same logic as the LoopUnrollPass to derived the unroll factor,
505  /// but which assumes that some canonicalization has taken place (e.g.
506  /// Mem2Reg, LICM, GVN, Inlining, etc.). That is, the heuristic will perform
507  /// better when the unrolled loop's CanonicalLoopInfo is not needed.
508  ///
509  /// \param DL Debug location for instructions added by unrolling.
510  /// \param Loop The loop to unroll. The loop will be invalidated.
511  /// \param Factor The factor to unroll the loop by. A factor of 0
512  /// indicates that a heuristic should be used to determine
513  /// the unroll-factor.
514  /// \param UnrolledCLI If non-null, receives the CanonicalLoopInfo of the
515  /// partially unrolled loop. Otherwise, uses loop metadata
516  /// to defer unrolling to the LoopUnrollPass.
517  void unrollLoopPartial(DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor,
518  CanonicalLoopInfo **UnrolledCLI);
519 
520  /// Generator for '#omp flush'
521  ///
522  /// \param Loc The location where the flush directive was encountered
523  void createFlush(const LocationDescription &Loc);
524 
525  /// Generator for '#omp taskwait'
526  ///
527  /// \param Loc The location where the taskwait directive was encountered.
528  void createTaskwait(const LocationDescription &Loc);
529 
530  /// Generator for '#omp taskyield'
531  ///
532  /// \param Loc The location where the taskyield directive was encountered.
533  void createTaskyield(const LocationDescription &Loc);
534 
535  /// Functions used to generate reductions. Such functions take two Values
536  /// representing LHS and RHS of the reduction, respectively, and a reference
537  /// to the value that is updated to refer to the reduction result.
538  using ReductionGenTy =
540 
541  /// Functions used to generate atomic reductions. Such functions take two
542  /// Values representing pointers to LHS and RHS of the reduction. They are
543  /// expected to atomically update the LHS to the reduced value.
544  using AtomicReductionGenTy =
546 
547  /// Information about an OpenMP reduction.
548  struct ReductionInfo {
554 
555  /// Returns the type of the element being reduced.
556  Type *getElementType() const {
558  }
559 
560  /// Reduction variable of pointer type.
562 
563  /// Thread-private partial reduction variable.
565 
566  /// Callback for generating the reduction body. The IR produced by this will
567  /// be used to combine two values in a thread-safe context, e.g., under
568  /// lock or within the same thread, and therefore need not be atomic.
570 
571  /// Callback for generating the atomic reduction body, may be null. The IR
572  /// produced by this will be used to atomically combine two values during
573  /// reduction. If null, the implementation will use the non-atomic version
574  /// along with the appropriate synchronization mechanisms.
576  };
577 
578  // TODO: provide atomic and non-atomic reduction generators for reduction
579  // operators defined by the OpenMP specification.
580 
581  /// Generator for '#omp reduction'.
582  ///
583  /// Emits the IR instructing the runtime to perform the specific kind of
584  /// reductions. Expects reduction variables to have been privatized and
585  /// initialized to reduction-neutral values separately. Emits the calls to
586  /// runtime functions as well as the reduction function and the basic blocks
587  /// performing the reduction atomically and non-atomically.
588  ///
589  /// The code emitted for the following:
590  ///
591  /// \code
592  /// type var_1;
593  /// type var_2;
594  /// #pragma omp <directive> reduction(reduction-op:var_1,var_2)
595  /// /* body */;
596  /// \endcode
597  ///
598  /// corresponds to the following sketch.
599  ///
600  /// \code
601  /// void _outlined_par() {
602  /// // N is the number of different reductions.
603  /// void *red_array[] = {privatized_var_1, privatized_var_2, ...};
604  /// switch(__kmpc_reduce(..., N, /*size of data in red array*/, red_array,
605  /// _omp_reduction_func,
606  /// _gomp_critical_user.reduction.var)) {
607  /// case 1: {
608  /// var_1 = var_1 <reduction-op> privatized_var_1;
609  /// var_2 = var_2 <reduction-op> privatized_var_2;
610  /// // ...
611  /// __kmpc_end_reduce(...);
612  /// break;
613  /// }
614  /// case 2: {
615  /// _Atomic<ReductionOp>(var_1, privatized_var_1);
616  /// _Atomic<ReductionOp>(var_2, privatized_var_2);
617  /// // ...
618  /// break;
619  /// }
620  /// default: break;
621  /// }
622  /// }
623  ///
624  /// void _omp_reduction_func(void **lhs, void **rhs) {
625  /// *(type *)lhs[0] = *(type *)lhs[0] <reduction-op> *(type *)rhs[0];
626  /// *(type *)lhs[1] = *(type *)lhs[1] <reduction-op> *(type *)rhs[1];
627  /// // ...
628  /// }
629  /// \endcode
630  ///
631  /// \param Loc The location where the reduction was
632  /// encountered. Must be within the associate
633  /// directive and after the last local access to the
634  /// reduction variables.
635  /// \param AllocaIP An insertion point suitable for allocas usable
636  /// in reductions.
637  /// \param ReductionInfos A list of info on each reduction variable.
638  /// \param IsNoWait A flag set if the reduction is marked as nowait.
640  InsertPointTy AllocaIP,
641  ArrayRef<ReductionInfo> ReductionInfos,
642  bool IsNoWait = false);
643 
644  ///}
645 
646  /// Return the insertion point used by the underlying IRBuilder.
648 
649  /// Update the internal location to \p Loc.
651  Builder.restoreIP(Loc.IP);
653  return Loc.IP.getBlock() != nullptr;
654  }
655 
656  /// Return the function declaration for the runtime function with \p FnID.
658  omp::RuntimeFunction FnID);
659 
661 
662  /// Return the (LLVM-IR) string describing the source location \p LocStr.
664 
665  /// Return the (LLVM-IR) string describing the default source location.
667 
668  /// Return the (LLVM-IR) string describing the source location identified by
669  /// the arguments.
670  Constant *getOrCreateSrcLocStr(StringRef FunctionName, StringRef FileName,
671  unsigned Line, unsigned Column);
672 
673  /// Return the (LLVM-IR) string describing the DebugLoc \p DL. Use \p F as
674  /// fallback if \p DL does not specify the function name.
676 
677  /// Return the (LLVM-IR) string describing the source location \p Loc.
678  Constant *getOrCreateSrcLocStr(const LocationDescription &Loc);
679 
680  /// Return an ident_t* encoding the source location \p SrcLocStr and \p Flags.
681  /// TODO: Create a enum class for the Reserve2Flags
682  Value *getOrCreateIdent(Constant *SrcLocStr,
683  omp::IdentFlag Flags = omp::IdentFlag(0),
684  unsigned Reserve2Flags = 0);
685 
686  /// Create a global flag \p Namein the module with initial value \p Value.
688 
689  /// Generate control flow and cleanup for cancellation.
690  ///
691  /// \param CancelFlag Flag indicating if the cancellation is performed.
692  /// \param CanceledDirective The kind of directive that is cancled.
693  /// \param ExitCB Extra code to be generated in the exit block.
694  void emitCancelationCheckImpl(Value *CancelFlag,
695  omp::Directive CanceledDirective,
696  FinalizeCallbackTy ExitCB = {});
697 
698  /// Generate a barrier runtime call.
699  ///
700  /// \param Loc The location at which the request originated and is fulfilled.
701  /// \param DK The directive which caused the barrier
702  /// \param ForceSimpleCall Flag to force a simple (=non-cancellation) barrier.
703  /// \param CheckCancelFlag Flag to indicate a cancel barrier return value
704  /// should be checked and acted upon.
705  ///
706  /// \returns The insertion point after the barrier.
707  InsertPointTy emitBarrierImpl(const LocationDescription &Loc,
708  omp::Directive DK, bool ForceSimpleCall,
709  bool CheckCancelFlag);
710 
711  /// Generate a flush runtime call.
712  ///
713  /// \param Loc The location at which the request originated and is fulfilled.
714  void emitFlush(const LocationDescription &Loc);
715 
716  /// The finalization stack made up of finalize callbacks currently in-flight,
717  /// wrapped into FinalizationInfo objects that reference also the finalization
718  /// target block and the kind of cancellable directive.
720 
721  /// Return true if the last entry in the finalization stack is of kind \p DK
722  /// and cancellable.
723  bool isLastFinalizationInfoCancellable(omp::Directive DK) {
724  return !FinalizationStack.empty() &&
725  FinalizationStack.back().IsCancellable &&
726  FinalizationStack.back().DK == DK;
727  }
728 
729  /// Generate a taskwait runtime call.
730  ///
731  /// \param Loc The location at which the request originated and is fulfilled.
732  void emitTaskwaitImpl(const LocationDescription &Loc);
733 
734  /// Generate a taskyield runtime call.
735  ///
736  /// \param Loc The location at which the request originated and is fulfilled.
737  void emitTaskyieldImpl(const LocationDescription &Loc);
738 
739  /// Return the current thread ID.
740  ///
741  /// \param Ident The ident (ident_t*) describing the query origin.
743 
744  /// The underlying LLVM-IR module
746 
747  /// The LLVM-IR Builder used to create IR.
749 
750  /// Map to remember source location strings
752 
753  /// Map to remember existing ident_t*.
755 
756  /// Helper that contains information about regions we need to outline
757  /// during finalization.
758  struct OutlineInfo {
762 
763  /// Collect all blocks in between EntryBB and ExitBB in both the given
764  /// vector and set.
766  SmallVectorImpl<BasicBlock *> &BlockVector);
767 
768  /// Return the function that contains the region to be outlined.
769  Function *getFunction() const { return EntryBB->getParent(); }
770  };
771 
772  /// Collection of regions that need to be outlined during finalization.
774 
775  /// Collection of owned canonical loop objects that eventually need to be
776  /// free'd.
777  std::forward_list<CanonicalLoopInfo> LoopInfos;
778 
779  /// Add a new region that will be outlined later.
780  void addOutlineInfo(OutlineInfo &&OI) { OutlineInfos.emplace_back(OI); }
781 
782  /// An ordered map of auto-generated variables to their unique names.
783  /// It stores variables with the following names: 1) ".gomp_critical_user_" +
784  /// <critical_section_name> + ".var" for "omp critical" directives; 2)
785  /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
786  /// variables.
788 
789  /// Create the global variable holding the offload mappings information.
791  std::string VarName);
792 
793  /// Create the global variable holding the offload names information.
796  std::string VarName);
797 
798  struct MapperAllocas {
799  AllocaInst *ArgsBase = nullptr;
800  AllocaInst *Args = nullptr;
801  AllocaInst *ArgSizes = nullptr;
802  };
803 
804  /// Create the allocas instruction used in call to mapper functions.
806  InsertPointTy AllocaIP, unsigned NumOperands,
807  struct MapperAllocas &MapperAllocas);
808 
809  /// Create the call for the target mapper function.
810  /// \param Loc The source location description.
811  /// \param MapperFunc Function to be called.
812  /// \param SrcLocInfo Source location information global.
813  /// \param MaptypesArg The argument types.
814  /// \param MapnamesArg The argument names.
815  /// \param MapperAllocas The AllocaInst used for the call.
816  /// \param DeviceID Device ID for the call.
817  /// \param NumOperands Number of operands in the call.
818  void emitMapperCall(const LocationDescription &Loc, Function *MapperFunc,
819  Value *SrcLocInfo, Value *MaptypesArg, Value *MapnamesArg,
820  struct MapperAllocas &MapperAllocas, int64_t DeviceID,
821  unsigned NumOperands);
822 
823 public:
824  /// Generator for __kmpc_copyprivate
825  ///
826  /// \param Loc The source location description.
827  /// \param BufSize Number of elements in the buffer.
828  /// \param CpyBuf List of pointers to data to be copied.
829  /// \param CpyFn function to call for copying data.
830  /// \param DidIt flag variable; 1 for 'single' thread, 0 otherwise.
831  ///
832  /// \return The insertion position *after* the CopyPrivate call.
833 
835  llvm::Value *BufSize, llvm::Value *CpyBuf,
836  llvm::Value *CpyFn, llvm::Value *DidIt);
837 
838  /// Generator for '#omp single'
839  ///
840  /// \param Loc The source location description.
841  /// \param BodyGenCB Callback that will generate the region code.
842  /// \param FiniCB Callback to finalize variable copies.
843  /// \param DidIt Local variable used as a flag to indicate 'single' thread
844  ///
845  /// \returns The insertion position *after* the single call.
847  BodyGenCallbackTy BodyGenCB,
848  FinalizeCallbackTy FiniCB, llvm::Value *DidIt);
849 
850  /// Generator for '#omp master'
851  ///
852  /// \param Loc The insert and source location description.
853  /// \param BodyGenCB Callback that will generate the region code.
854  /// \param FiniCB Callback to finalize variable copies.
855  ///
856  /// \returns The insertion position *after* the master.
858  BodyGenCallbackTy BodyGenCB,
859  FinalizeCallbackTy FiniCB);
860 
861  /// Generator for '#omp masked'
862  ///
863  /// \param Loc The insert and source location description.
864  /// \param BodyGenCB Callback that will generate the region code.
865  /// \param FiniCB Callback to finialize variable copies.
866  ///
867  /// \returns The insertion position *after* the masked.
869  BodyGenCallbackTy BodyGenCB,
870  FinalizeCallbackTy FiniCB, Value *Filter);
871 
872  /// Generator for '#omp critical'
873  ///
874  /// \param Loc The insert and source location description.
875  /// \param BodyGenCB Callback that will generate the region body code.
876  /// \param FiniCB Callback to finalize variable copies.
877  /// \param CriticalName name of the lock used by the critical directive
878  /// \param HintInst Hint Instruction for hint clause associated with critical
879  ///
880  /// \returns The insertion position *after* the critical.
882  BodyGenCallbackTy BodyGenCB,
883  FinalizeCallbackTy FiniCB,
884  StringRef CriticalName, Value *HintInst);
885 
886  /// Generator for '#omp ordered depend (source | sink)'
887  ///
888  /// \param Loc The insert and source location description.
889  /// \param AllocaIP The insertion point to be used for alloca instructions.
890  /// \param NumLoops The number of loops in depend clause.
891  /// \param StoreValues The value will be stored in vector address.
892  /// \param Name The name of alloca instruction.
893  /// \param IsDependSource If true, depend source; otherwise, depend sink.
894  ///
895  /// \return The insertion position *after* the ordered.
897  InsertPointTy AllocaIP, unsigned NumLoops,
898  ArrayRef<llvm::Value *> StoreValues,
899  const Twine &Name, bool IsDependSource);
900 
901  /// Generator for '#omp ordered [threads | simd]'
902  ///
903  /// \param Loc The insert and source location description.
904  /// \param BodyGenCB Callback that will generate the region code.
905  /// \param FiniCB Callback to finalize variable copies.
906  /// \param IsThreads If true, with threads clause or without clause;
907  /// otherwise, with simd clause;
908  ///
909  /// \returns The insertion position *after* the ordered.
911  BodyGenCallbackTy BodyGenCB,
912  FinalizeCallbackTy FiniCB,
913  bool IsThreads);
914 
915  /// Generator for '#omp sections'
916  ///
917  /// \param Loc The insert and source location description.
918  /// \param AllocaIP The insertion points to be used for alloca instructions.
919  /// \param SectionCBs Callbacks that will generate body of each section.
920  /// \param PrivCB Callback to copy a given variable (think copy constructor).
921  /// \param FiniCB Callback to finalize variable copies.
922  /// \param IsCancellable Flag to indicate a cancellable parallel region.
923  /// \param IsNowait If true, barrier - to ensure all sections are executed
924  /// before moving forward will not be generated.
925  /// \returns The insertion position *after* the sections.
927  InsertPointTy AllocaIP,
929  PrivatizeCallbackTy PrivCB,
930  FinalizeCallbackTy FiniCB, bool IsCancellable,
931  bool IsNowait);
932 
933  /// Generator for '#omp section'
934  ///
935  /// \param Loc The insert and source location description.
936  /// \param BodyGenCB Callback that will generate the region body code.
937  /// \param FiniCB Callback to finalize variable copies.
938  /// \returns The insertion position *after* the section.
940  BodyGenCallbackTy BodyGenCB,
941  FinalizeCallbackTy FiniCB);
942 
943  /// Generate conditional branch and relevant BasicBlocks through which private
944  /// threads copy the 'copyin' variables from Master copy to threadprivate
945  /// copies.
946  ///
947  /// \param IP insertion block for copyin conditional
948  /// \param MasterVarPtr a pointer to the master variable
949  /// \param PrivateVarPtr a pointer to the threadprivate variable
950  /// \param IntPtrTy Pointer size type
951  /// \param BranchtoEnd Create a branch between the copyin.not.master blocks
952  // and copy.in.end block
953  ///
954  /// \returns The insertion point where copying operation to be emitted.
956  Value *PrivateAddr,
957  llvm::IntegerType *IntPtrTy,
958  bool BranchtoEnd = true);
959 
960  /// Create a runtime call for kmpc_Alloc
961  ///
962  /// \param Loc The insert and source location description.
963  /// \param Size Size of allocated memory space
964  /// \param Allocator Allocator information instruction
965  /// \param Name Name of call Instruction for OMP_alloc
966  ///
967  /// \returns CallInst to the OMP_Alloc call
969  Value *Allocator, std::string Name = "");
970 
971  /// Create a runtime call for kmpc_free
972  ///
973  /// \param Loc The insert and source location description.
974  /// \param Addr Address of memory space to be freed
975  /// \param Allocator Allocator information instruction
976  /// \param Name Name of call Instruction for OMP_Free
977  ///
978  /// \returns CallInst to the OMP_Free call
980  Value *Allocator, std::string Name = "");
981 
982  /// Create a runtime call for kmpc_threadprivate_cached
983  ///
984  /// \param Loc The insert and source location description.
985  /// \param Pointer pointer to data to be cached
986  /// \param Size size of data to be cached
987  /// \param Name Name of call Instruction for callinst
988  ///
989  /// \returns CallInst to the thread private cache call.
991  llvm::Value *Pointer,
993  const llvm::Twine &Name = Twine(""));
994 
995  /// The `omp target` interface
996  ///
997  /// For more information about the usage of this interface,
998  /// \see openmp/libomptarget/deviceRTLs/common/include/target.h
999  ///
1000  ///{
1001 
1002  /// Create a runtime call for kmpc_target_init
1003  ///
1004  /// \param Loc The insert and source location description.
1005  /// \param IsSPMD Flag to indicate if the kernel is an SPMD kernel or not.
1006  /// \param RequiresFullRuntime Indicate if a full device runtime is necessary.
1007  InsertPointTy createTargetInit(const LocationDescription &Loc, bool IsSPMD,
1008  bool RequiresFullRuntime);
1009 
1010  /// Create a runtime call for kmpc_target_deinit
1011  ///
1012  /// \param Loc The insert and source location description.
1013  /// \param IsSPMD Flag to indicate if the kernel is an SPMD kernel or not.
1014  /// \param RequiresFullRuntime Indicate if a full device runtime is necessary.
1015  void createTargetDeinit(const LocationDescription &Loc, bool IsSPMD,
1016  bool RequiresFullRuntime);
1017 
1018  ///}
1019 
1020  /// Declarations for LLVM-IR types (simple, array, function and structure) are
1021  /// generated below. Their names are defined and used in OpenMPKinds.def. Here
1022  /// we provide the declarations, the initializeTypes function will provide the
1023  /// values.
1024  ///
1025  ///{
1026 #define OMP_TYPE(VarName, InitValue) Type *VarName = nullptr;
1027 #define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) \
1028  ArrayType *VarName##Ty = nullptr; \
1029  PointerType *VarName##PtrTy = nullptr;
1030 #define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) \
1031  FunctionType *VarName = nullptr; \
1032  PointerType *VarName##Ptr = nullptr;
1033 #define OMP_STRUCT_TYPE(VarName, StrName, ...) \
1034  StructType *VarName = nullptr; \
1035  PointerType *VarName##Ptr = nullptr;
1036 #include "llvm/Frontend/OpenMP/OMPKinds.def"
1037 
1038  ///}
1039 
1040 private:
1041  /// Create all simple and struct types exposed by the runtime and remember
1042  /// the llvm::PointerTypes of them for easy access later.
1043  void initializeTypes(Module &M);
1044 
1045  /// Common interface for generating entry calls for OMP Directives.
1046  /// if the directive has a region/body, It will set the insertion
1047  /// point to the body
1048  ///
1049  /// \param OMPD Directive to generate entry blocks for
1050  /// \param EntryCall Call to the entry OMP Runtime Function
1051  /// \param ExitBB block where the region ends.
1052  /// \param Conditional indicate if the entry call result will be used
1053  /// to evaluate a conditional of whether a thread will execute
1054  /// body code or not.
1055  ///
1056  /// \return The insertion position in exit block
1057  InsertPointTy emitCommonDirectiveEntry(omp::Directive OMPD, Value *EntryCall,
1058  BasicBlock *ExitBB,
1059  bool Conditional = false);
1060 
1061  /// Common interface to finalize the region
1062  ///
1063  /// \param OMPD Directive to generate exiting code for
1064  /// \param FinIP Insertion point for emitting Finalization code and exit call
1065  /// \param ExitCall Call to the ending OMP Runtime Function
1066  /// \param HasFinalize indicate if the directive will require finalization
1067  /// and has a finalization callback in the stack that
1068  /// should be called.
1069  ///
1070  /// \return The insertion position in exit block
1071  InsertPointTy emitCommonDirectiveExit(omp::Directive OMPD,
1072  InsertPointTy FinIP,
1073  Instruction *ExitCall,
1074  bool HasFinalize = true);
1075 
1076  /// Common Interface to generate OMP inlined regions
1077  ///
1078  /// \param OMPD Directive to generate inlined region for
1079  /// \param EntryCall Call to the entry OMP Runtime Function
1080  /// \param ExitCall Call to the ending OMP Runtime Function
1081  /// \param BodyGenCB Body code generation callback.
1082  /// \param FiniCB Finalization Callback. Will be called when finalizing region
1083  /// \param Conditional indicate if the entry call result will be used
1084  /// to evaluate a conditional of whether a thread will execute
1085  /// body code or not.
1086  /// \param HasFinalize indicate if the directive will require finalization
1087  /// and has a finalization callback in the stack that
1088  /// should be called.
1089  /// \param IsCancellable if HasFinalize is set to true, indicate if the
1090  /// the directive should be cancellable.
1091  /// \return The insertion point after the region
1092 
1094  EmitOMPInlinedRegion(omp::Directive OMPD, Instruction *EntryCall,
1095  Instruction *ExitCall, BodyGenCallbackTy BodyGenCB,
1096  FinalizeCallbackTy FiniCB, bool Conditional = false,
1097  bool HasFinalize = true, bool IsCancellable = false);
1098 
1099  /// Get the platform-specific name separator.
1100  /// \param Parts different parts of the final name that needs separation
1101  /// \param FirstSeparator First separator used between the initial two
1102  /// parts of the name.
1103  /// \param Separator separator used between all of the rest consecutive
1104  /// parts of the name
1105  static std::string getNameWithSeparators(ArrayRef<StringRef> Parts,
1106  StringRef FirstSeparator,
1107  StringRef Separator);
1108 
1109  /// Gets (if variable with the given name already exist) or creates
1110  /// internal global variable with the specified Name. The created variable has
1111  /// linkage CommonLinkage by default and is initialized by null value.
1112  /// \param Ty Type of the global variable. If it is exist already the type
1113  /// must be the same.
1114  /// \param Name Name of the variable.
1115  Constant *getOrCreateOMPInternalVariable(Type *Ty, const Twine &Name,
1116  unsigned AddressSpace = 0);
1117 
1118  /// Returns corresponding lock object for the specified critical region
1119  /// name. If the lock object does not exist it is created, otherwise the
1120  /// reference to the existing copy is returned.
1121  /// \param CriticalName Name of the critical region.
1122  ///
1123  Value *getOMPCriticalRegionLock(StringRef CriticalName);
1124 
1125  /// Callback type for Atomic Expression update
1126  /// ex:
1127  /// \code{.cpp}
1128  /// unsigned x = 0;
1129  /// #pragma omp atomic update
1130  /// x = Expr(x_old); //Expr() is any legal operation
1131  /// \endcode
1132  ///
1133  /// \param XOld the value of the atomic memory address to use for update
1134  /// \param IRB reference to the IRBuilder to use
1135  ///
1136  /// \returns Value to update X to.
1137  using AtomicUpdateCallbackTy =
1138  const function_ref<Value *(Value *XOld, IRBuilder<> &IRB)>;
1139 
1140 private:
1141  enum AtomicKind { Read, Write, Update, Capture };
1142 
1143  /// Determine whether to emit flush or not
1144  ///
1145  /// \param Loc The insert and source location description.
1146  /// \param AO The required atomic ordering
1147  /// \param AK The OpenMP atomic operation kind used.
1148  ///
1149  /// \returns wether a flush was emitted or not
1150  bool checkAndEmitFlushAfterAtomic(const LocationDescription &Loc,
1151  AtomicOrdering AO, AtomicKind AK);
1152 
1153  /// Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X
1154  /// For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X)
1155  /// Only Scalar data types.
1156  ///
1157  /// \param AllocIP Instruction to create AllocaInst before.
1158  /// \param X The target atomic pointer to be updated
1159  /// \param Expr The value to update X with.
1160  /// \param AO Atomic ordering of the generated atomic
1161  /// instructions.
1162  /// \param RMWOp The binary operation used for update. If
1163  /// operation is not supported by atomicRMW,
1164  /// or belong to {FADD, FSUB, BAD_BINOP}.
1165  /// Then a `cmpExch` based atomic will be generated.
1166  /// \param UpdateOp Code generator for complex expressions that cannot be
1167  /// expressed through atomicrmw instruction.
1168  /// \param VolatileX true if \a X volatile?
1169  /// \param IsXLHSInRHSPart true if \a X is Left H.S. in Right H.S. part of
1170  /// the update expression, false otherwise.
1171  /// (e.g. true for X = X BinOp Expr)
1172  ///
1173  /// \returns A pair of the old value of X before the update, and the value
1174  /// used for the update.
1175  std::pair<Value *, Value *> emitAtomicUpdate(Instruction *AllocIP, Value *X,
1176  Value *Expr, AtomicOrdering AO,
1177  AtomicRMWInst::BinOp RMWOp,
1178  AtomicUpdateCallbackTy &UpdateOp,
1179  bool VolatileX,
1180  bool IsXLHSInRHSPart);
1181 
1182  /// Emit the binary op. described by \p RMWOp, using \p Src1 and \p Src2 .
1183  ///
1184  /// \Return The instruction
1185  Value *emitRMWOpAsInstruction(Value *Src1, Value *Src2,
1186  AtomicRMWInst::BinOp RMWOp);
1187 
1188 public:
1189  /// a struct to pack relevant information while generating atomic Ops
1190  struct AtomicOpValue {
1191  Value *Var = nullptr;
1192  bool IsSigned = false;
1193  bool IsVolatile = false;
1194  };
1195 
1196  /// Emit atomic Read for : V = X --- Only Scalar data types.
1197  ///
1198  /// \param Loc The insert and source location description.
1199  /// \param X The target pointer to be atomically read
1200  /// \param V Memory address where to store atomically read
1201  /// value
1202  /// \param AO Atomic ordering of the generated atomic
1203  /// instructions.
1204  ///
1205  /// \return Insertion point after generated atomic read IR.
1208  AtomicOrdering AO);
1209 
1210  /// Emit atomic write for : X = Expr --- Only Scalar data types.
1211  ///
1212  /// \param Loc The insert and source location description.
1213  /// \param X The target pointer to be atomically written to
1214  /// \param Expr The value to store.
1215  /// \param AO Atomic ordering of the generated atomic
1216  /// instructions.
1217  ///
1218  /// \return Insertion point after generated atomic Write IR.
1220  AtomicOpValue &X, Value *Expr,
1221  AtomicOrdering AO);
1222 
1223  /// Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X
1224  /// For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X)
1225  /// Only Scalar data types.
1226  ///
1227  /// \param Loc The insert and source location description.
1228  /// \param AllocIP Instruction to create AllocaInst before.
1229  /// \param X The target atomic pointer to be updated
1230  /// \param Expr The value to update X with.
1231  /// \param AO Atomic ordering of the generated atomic instructions.
1232  /// \param RMWOp The binary operation used for update. If operation
1233  /// is not supported by atomicRMW, or belong to
1234  /// {FADD, FSUB, BAD_BINOP}. Then a `cmpExch` based
1235  /// atomic will be generated.
1236  /// \param UpdateOp Code generator for complex expressions that cannot be
1237  /// expressed through atomicrmw instruction.
1238  /// \param IsXLHSInRHSPart true if \a X is Left H.S. in Right H.S. part of
1239  /// the update expression, false otherwise.
1240  /// (e.g. true for X = X BinOp Expr)
1241  ///
1242  /// \return Insertion point after generated atomic update IR.
1244  Instruction *AllocIP, AtomicOpValue &X,
1245  Value *Expr, AtomicOrdering AO,
1246  AtomicRMWInst::BinOp RMWOp,
1247  AtomicUpdateCallbackTy &UpdateOp,
1248  bool IsXLHSInRHSPart);
1249 
1250  /// Emit atomic update for constructs: --- Only Scalar data types
1251  /// V = X; X = X BinOp Expr ,
1252  /// X = X BinOp Expr; V = X,
1253  /// V = X; X = Expr BinOp X,
1254  /// X = Expr BinOp X; V = X,
1255  /// V = X; X = UpdateOp(X),
1256  /// X = UpdateOp(X); V = X,
1257  ///
1258  /// \param Loc The insert and source location description.
1259  /// \param AllocIP Instruction to create AllocaInst before.
1260  /// \param X The target atomic pointer to be updated
1261  /// \param V Memory address where to store captured value
1262  /// \param Expr The value to update X with.
1263  /// \param AO Atomic ordering of the generated atomic instructions
1264  /// \param RMWOp The binary operation used for update. If
1265  /// operation is not supported by atomicRMW, or belong to
1266  /// {FADD, FSUB, BAD_BINOP}. Then a cmpExch based
1267  /// atomic will be generated.
1268  /// \param UpdateOp Code generator for complex expressions that cannot be
1269  /// expressed through atomicrmw instruction.
1270  /// \param UpdateExpr true if X is an in place update of the form
1271  /// X = X BinOp Expr or X = Expr BinOp X
1272  /// \param IsXLHSInRHSPart true if X is Left H.S. in Right H.S. part of the
1273  /// update expression, false otherwise.
1274  /// (e.g. true for X = X BinOp Expr)
1275  /// \param IsPostfixUpdate true if original value of 'x' must be stored in
1276  /// 'v', not an updated one.
1277  ///
1278  /// \return Insertion point after generated atomic capture IR.
1281  AtomicOpValue &X, AtomicOpValue &V, Value *Expr,
1283  AtomicUpdateCallbackTy &UpdateOp, bool UpdateExpr,
1284  bool IsPostfixUpdate, bool IsXLHSInRHSPart);
1285 
1286  /// Create the control flow structure of a canonical OpenMP loop.
1287  ///
1288  /// The emitted loop will be disconnected, i.e. no edge to the loop's
1289  /// preheader and no terminator in the AfterBB. The OpenMPIRBuilder's
1290  /// IRBuilder location is not preserved.
1291  ///
1292  /// \param DL DebugLoc used for the instructions in the skeleton.
1293  /// \param TripCount Value to be used for the trip count.
1294  /// \param F Function in which to insert the BasicBlocks.
1295  /// \param PreInsertBefore Where to insert BBs that execute before the body,
1296  /// typically the body itself.
1297  /// \param PostInsertBefore Where to insert BBs that execute after the body.
1298  /// \param Name Base name used to derive BB
1299  /// and instruction names.
1300  ///
1301  /// \returns The CanonicalLoopInfo that represents the emitted loop.
1303  Function *F,
1304  BasicBlock *PreInsertBefore,
1305  BasicBlock *PostInsertBefore,
1306  const Twine &Name = {});
1307 };
1308 
1309 /// Class to represented the control flow structure of an OpenMP canonical loop.
1310 ///
1311 /// The control-flow structure is standardized for easy consumption by
1312 /// directives associated with loops. For instance, the worksharing-loop
1313 /// construct may change this control flow such that each loop iteration is
1314 /// executed on only one thread. The constraints of a canonical loop in brief
1315 /// are:
1316 ///
1317 /// * The number of loop iterations must have been computed before entering the
1318 /// loop.
1319 ///
1320 /// * Has an (unsigned) logical induction variable that starts at zero and
1321 /// increments by one.
1322 ///
1323 /// * The loop's CFG itself has no side-effects. The OpenMP specification
1324 /// itself allows side-effects, but the order in which they happen, including
1325 /// how often or whether at all, is unspecified. We expect that the frontend
1326 /// will emit those side-effect instructions somewhere (e.g. before the loop)
1327 /// such that the CanonicalLoopInfo itself can be side-effect free.
1328 ///
1329 /// Keep in mind that CanonicalLoopInfo is meant to only describe a repeated
1330 /// execution of a loop body that satifies these constraints. It does NOT
1331 /// represent arbitrary SESE regions that happen to contain a loop. Do not use
1332 /// CanonicalLoopInfo for such purposes.
1333 ///
1334 /// The control flow can be described as follows:
1335 ///
1336 /// Preheader
1337 /// |
1338 /// /-> Header
1339 /// | |
1340 /// | Cond---\
1341 /// | | |
1342 /// | Body |
1343 /// | | | |
1344 /// | <...> |
1345 /// | | | |
1346 /// \--Latch |
1347 /// |
1348 /// Exit
1349 /// |
1350 /// After
1351 ///
1352 /// The loop is thought to start at PreheaderIP (at the Preheader's terminator,
1353 /// including) and end at AfterIP (at the After's first instruction, excluding).
1354 /// That is, instructions in the Preheader and After blocks (except the
1355 /// Preheader's terminator) are out of CanonicalLoopInfo's control and may have
1356 /// side-effects. Typically, the Preheader is used to compute the loop's trip
1357 /// count. The instructions from BodyIP (at the Body block's first instruction,
1358 /// excluding) until the Latch are also considered outside CanonicalLoopInfo's
1359 /// control and thus can have side-effects. The body block is the single entry
1360 /// point into the loop body, which may contain arbitrary control flow as long
1361 /// as all control paths eventually branch to the Latch block.
1362 ///
1363 /// TODO: Consider adding another standardized BasicBlock between Body CFG and
1364 /// Latch to guarantee that there is only a single edge to the latch. It would
1365 /// make loop transformations easier to not needing to consider multiple
1366 /// predecessors of the latch (See redirectAllPredecessorsTo) and would give us
1367 /// an equivalant to PreheaderIP, AfterIP and BodyIP for inserting code that
1368 /// executes after each body iteration.
1369 ///
1370 /// There must be no loop-carried dependencies through llvm::Values. This is
1371 /// equivalant to that the Latch has no PHINode and the Header's only PHINode is
1372 /// for the induction variable.
1373 ///
1374 /// All code in Header, Cond, Latch and Exit (plus the terminator of the
1375 /// Preheader) are CanonicalLoopInfo's responsibility and their build-up checked
1376 /// by assertOK(). They are expected to not be modified unless explicitly
1377 /// modifying the CanonicalLoopInfo through a methods that applies a OpenMP
1378 /// loop-associated construct such as applyWorkshareLoop, tileLoops, unrollLoop,
1379 /// etc. These methods usually invalidate the CanonicalLoopInfo and re-use its
1380 /// basic blocks. After invalidation, the CanonicalLoopInfo must not be used
1381 /// anymore as its underlying control flow may not exist anymore.
1382 /// Loop-transformation methods such as tileLoops, collapseLoops and unrollLoop
1383 /// may also return a new CanonicalLoopInfo that can be passed to other
1384 /// loop-associated construct implementing methods. These loop-transforming
1385 /// methods may either create a new CanonicalLoopInfo usually using
1386 /// createLoopSkeleton and invalidate the input CanonicalLoopInfo, or reuse and
1387 /// modify one of the input CanonicalLoopInfo and return it as representing the
1388 /// modified loop. What is done is an implementation detail of
1389 /// transformation-implementing method and callers should always assume that the
1390 /// CanonicalLoopInfo passed to it is invalidated and a new object is returned.
1391 /// Returned CanonicalLoopInfo have the same structure and guarantees as the one
1392 /// created by createCanonicalLoop, such that transforming methods do not have
1393 /// to special case where the CanonicalLoopInfo originated from.
1394 ///
1395 /// Generally, methods consuming CanonicalLoopInfo do not need an
1396 /// OpenMPIRBuilder::InsertPointTy as argument, but use the locations of the
1397 /// CanonicalLoopInfo to insert new or modify existing instructions. Unless
1398 /// documented otherwise, methods consuming CanonicalLoopInfo do not invalidate
1399 /// any InsertPoint that is outside CanonicalLoopInfo's control. Specifically,
1400 /// any InsertPoint in the Preheader, After or Block can still be used after
1401 /// calling such a method.
1402 ///
1403 /// TODO: Provide mechanisms for exception handling and cancellation points.
1404 ///
1405 /// Defined outside OpenMPIRBuilder because nested classes cannot be
1406 /// forward-declared, e.g. to avoid having to include the entire OMPIRBuilder.h.
1408  friend class OpenMPIRBuilder;
1409 
1410 private:
1411  BasicBlock *Preheader = nullptr;
1412  BasicBlock *Header = nullptr;
1413  BasicBlock *Cond = nullptr;
1414  BasicBlock *Body = nullptr;
1415  BasicBlock *Latch = nullptr;
1416  BasicBlock *Exit = nullptr;
1417  BasicBlock *After = nullptr;
1418 
1419  /// Add the control blocks of this loop to \p BBs.
1420  ///
1421  /// This does not include any block from the body, including the one returned
1422  /// by getBody().
1423  ///
1424  /// FIXME: This currently includes the Preheader and After blocks even though
1425  /// their content is (mostly) not under CanonicalLoopInfo's control.
1426  /// Re-evaluated whether this makes sense.
1427  void collectControlBlocks(SmallVectorImpl<BasicBlock *> &BBs);
1428 
1429 public:
1430  /// Returns whether this object currently represents the IR of a loop. If
1431  /// returning false, it may have been consumed by a loop transformation or not
1432  /// been intialized. Do not use in this case;
1433  bool isValid() const { return Header; }
1434 
1435  /// The preheader ensures that there is only a single edge entering the loop.
1436  /// Code that must be execute before any loop iteration can be emitted here,
1437  /// such as computing the loop trip count and begin lifetime markers. Code in
1438  /// the preheader is not considered part of the canonical loop.
1440  assert(isValid() && "Requires a valid canonical loop");
1441  return Preheader;
1442  }
1443 
1444  /// The header is the entry for each iteration. In the canonical control flow,
1445  /// it only contains the PHINode for the induction variable.
1447  assert(isValid() && "Requires a valid canonical loop");
1448  return Header;
1449  }
1450 
1451  /// The condition block computes whether there is another loop iteration. If
1452  /// yes, branches to the body; otherwise to the exit block.
1453  BasicBlock *getCond() const {
1454  assert(isValid() && "Requires a valid canonical loop");
1455  return Cond;
1456  }
1457 
1458  /// The body block is the single entry for a loop iteration and not controlled
1459  /// by CanonicalLoopInfo. It can contain arbitrary control flow but must
1460  /// eventually branch to the \p Latch block.
1461  BasicBlock *getBody() const {
1462  assert(isValid() && "Requires a valid canonical loop");
1463  return Body;
1464  }
1465 
1466  /// Reaching the latch indicates the end of the loop body code. In the
1467  /// canonical control flow, it only contains the increment of the induction
1468  /// variable.
1470  assert(isValid() && "Requires a valid canonical loop");
1471  return Latch;
1472  }
1473 
1474  /// Reaching the exit indicates no more iterations are being executed.
1475  BasicBlock *getExit() const {
1476  assert(isValid() && "Requires a valid canonical loop");
1477  return Exit;
1478  }
1479 
1480  /// The after block is intended for clean-up code such as lifetime end
1481  /// markers. It is separate from the exit block to ensure, analogous to the
1482  /// preheader, it having just a single entry edge and being free from PHI
1483  /// nodes should there be multiple loop exits (such as from break
1484  /// statements/cancellations).
1486  assert(isValid() && "Requires a valid canonical loop");
1487  return After;
1488  }
1489 
1490  /// Returns the llvm::Value containing the number of loop iterations. It must
1491  /// be valid in the preheader and always interpreted as an unsigned integer of
1492  /// any bit-width.
1493  Value *getTripCount() const {
1494  assert(isValid() && "Requires a valid canonical loop");
1495  Instruction *CmpI = &Cond->front();
1496  assert(isa<CmpInst>(CmpI) && "First inst must compare IV with TripCount");
1497  return CmpI->getOperand(1);
1498  }
1499 
1500  /// Returns the instruction representing the current logical induction
1501  /// variable. Always unsigned, always starting at 0 with an increment of one.
1503  assert(isValid() && "Requires a valid canonical loop");
1504  Instruction *IndVarPHI = &Header->front();
1505  assert(isa<PHINode>(IndVarPHI) && "First inst must be the IV PHI");
1506  return IndVarPHI;
1507  }
1508 
1509  /// Return the type of the induction variable (and the trip count).
1510  Type *getIndVarType() const {
1511  assert(isValid() && "Requires a valid canonical loop");
1512  return getIndVar()->getType();
1513  }
1514 
1515  /// Return the insertion point for user code before the loop.
1517  assert(isValid() && "Requires a valid canonical loop");
1518  return {Preheader, std::prev(Preheader->end())};
1519  };
1520 
1521  /// Return the insertion point for user code in the body.
1523  assert(isValid() && "Requires a valid canonical loop");
1524  return {Body, Body->begin()};
1525  };
1526 
1527  /// Return the insertion point for user code after the loop.
1529  assert(isValid() && "Requires a valid canonical loop");
1530  return {After, After->begin()};
1531  };
1532 
1534  assert(isValid() && "Requires a valid canonical loop");
1535  return Header->getParent();
1536  }
1537 
1538  /// Consistency self-check.
1539  void assertOK() const;
1540 
1541  /// Invalidate this loop. That is, the underlying IR does not fulfill the
1542  /// requirements of an OpenMP canonical loop anymore.
1543  void invalidate();
1544 };
1545 
1546 } // end namespace llvm
1547 
1548 #endif // LLVM_FRONTEND_OPENMP_OMPIRBUILDER_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::CanonicalLoopInfo::getPreheaderIP
OpenMPIRBuilder::InsertPointTy getPreheaderIP() const
Return the insertion point for user code before the loop.
Definition: OMPIRBuilder.h:1516
llvm::OpenMPIRBuilder::createCachedThreadPrivate
CallInst * createCachedThreadPrivate(const LocationDescription &Loc, llvm::Value *Pointer, llvm::ConstantInt *Size, const llvm::Twine &Name=Twine(""))
Create a runtime call for kmpc_threadprivate_cached.
Definition: OMPIRBuilder.cpp:2742
llvm::BasicBlock::end
iterator end()
Definition: BasicBlock.h:298
llvm::IRBuilderBase::restoreIP
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Definition: IRBuilder.h:283
llvm::OpenMPIRBuilder::LocationDescription
Description of a LLVM-IR insertion point (IP) and a debug/source location (filename,...
Definition: OMPIRBuilder.h:150
llvm::OpenMPIRBuilder::OutlineInfo::ExitBB
BasicBlock * ExitBB
Definition: OMPIRBuilder.h:761
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::OpenMPIRBuilder::createSection
InsertPointTy createSection(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
Generator for '#omp section'.
Definition: OMPIRBuilder.cpp:1020
llvm::OpenMPIRBuilder::createCritical
InsertPointTy createCritical(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, StringRef CriticalName, Value *HintInst)
Generator for '#omp critical'.
Definition: OMPIRBuilder.cpp:2428
llvm::CanonicalLoopInfo::getAfter
BasicBlock * getAfter() const
The after block is intended for clean-up code such as lifetime end markers.
Definition: OMPIRBuilder.h:1485
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
llvm::OpenMPIRBuilder::createLoopSkeleton
CanonicalLoopInfo * createLoopSkeleton(DebugLoc DL, Value *TripCount, Function *F, BasicBlock *PreInsertBefore, BasicBlock *PostInsertBefore, const Twine &Name={})
Create the control flow structure of a canonical OpenMP loop.
Definition: OMPIRBuilder.cpp:1275
llvm::OpenMPIRBuilder::pushFinalizationCB
void pushFinalizationCB(const FinalizationInfo &FI)
Push a finalization callback on the finalization stack.
Definition: OMPIRBuilder.h:81
llvm::Function
Definition: Function.h:62
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
llvm::OpenMPIRBuilder::ReductionInfo::getElementType
Type * getElementType() const
Returns the type of the element being reduced.
Definition: OMPIRBuilder.h:556
Loops
Hexagon Hardware Loops
Definition: HexagonHardwareLoops.cpp:372
llvm::AtomicRMWInst::BinOp
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:738
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::OpenMPIRBuilder::tileLoops
std::vector< CanonicalLoopInfo * > tileLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, ArrayRef< Value * > TileSizes)
Tile a loop nest.
Definition: OMPIRBuilder.cpp:1903
llvm::OpenMPIRBuilder::InsertPointTy
IRBuilder<>::InsertPoint InsertPointTy
Type used throughout for insertion points.
Definition: OMPIRBuilder.h:53
llvm::IRBuilder
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2657
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::OpenMPIRBuilder::getOrCreateThreadID
Value * getOrCreateThreadID(Value *Ident)
Return the current thread ID.
Definition: OMPIRBuilder.cpp:357
Allocator.h
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:71
llvm::OpenMPIRBuilder::FinalizationInfo::IsCancellable
bool IsCancellable
Flag to indicate if the directive is cancellable.
Definition: OMPIRBuilder.h:75
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::OpenMPIRBuilder::AtomicOpValue
a struct to pack relevant information while generating atomic Ops
Definition: OMPIRBuilder.h:1190
llvm::OpenMPIRBuilder::FinalizationInfo::FiniCB
FinalizeCallbackTy FiniCB
The finalization callback provided by the last in-flight invocation of createXXXX for the directive o...
Definition: OMPIRBuilder.h:68
llvm::CanonicalLoopInfo::getAfterIP
OpenMPIRBuilder::InsertPointTy getAfterIP() const
Return the insertion point for user code after the loop.
Definition: OMPIRBuilder.h:1528
llvm::OpenMPIRBuilder::LocationDescription::LocationDescription
LocationDescription(const IRBuilder< T, U > &IRB)
Definition: OMPIRBuilder.h:152
llvm::OpenMPIRBuilder::ReductionInfo::Variable
Value * Variable
Reduction variable of pointer type.
Definition: OMPIRBuilder.h:561
llvm::OpenMPIRBuilder::FinalizeCallbackTy
std::function< void(InsertPointTy CodeGenIP)> FinalizeCallbackTy
Callback type for variable finalization (think destructors).
Definition: OMPIRBuilder.h:63
llvm::CanonicalLoopInfo::getFunction
Function * getFunction() const
Definition: OMPIRBuilder.h:1533
llvm::OpenMPIRBuilder::AtomicOpValue::Var
Value * Var
Definition: OMPIRBuilder.h:1191
llvm::OpenMPIRBuilder::createAtomicCapture
InsertPointTy createAtomicCapture(const LocationDescription &Loc, Instruction *AllocIP, AtomicOpValue &X, AtomicOpValue &V, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool UpdateExpr, bool IsPostfixUpdate, bool IsXLHSInRHSPart)
Emit atomic update for constructs: — Only Scalar data types V = X; X = X BinOp Expr ,...
Definition: OMPIRBuilder.cpp:3229
llvm::OpenMPIRBuilder::BodyGenCallbackTy
function_ref< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, BasicBlock &ContinuationBB)> BodyGenCallbackTy
Callback type for body (=inner region) code generation.
Definition: OMPIRBuilder.h:105
llvm::OpenMPIRBuilder::emitTaskyieldImpl
void emitTaskyieldImpl(const LocationDescription &Loc)
Generate a taskyield runtime call.
Definition: OMPIRBuilder.cpp:904
llvm::OpenMPIRBuilder::createReductions
InsertPointTy createReductions(const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< ReductionInfo > ReductionInfos, bool IsNoWait=false)
Generator for '#omp reduction'.
Definition: OMPIRBuilder.cpp:1066
llvm::OpenMPIRBuilder::collapseLoops
CanonicalLoopInfo * collapseLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, InsertPointTy ComputeIP)
Collapse a loop nest into a single loop.
Definition: OMPIRBuilder.cpp:1777
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::CanonicalLoopInfo::getIndVar
Instruction * getIndVar() const
Returns the instruction representing the current logical induction variable.
Definition: OMPIRBuilder.h:1502
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::OpenMPIRBuilder::createOrderedDepend
InsertPointTy createOrderedDepend(const LocationDescription &Loc, InsertPointTy AllocaIP, unsigned NumLoops, ArrayRef< llvm::Value * > StoreValues, const Twine &Name, bool IsDependSource)
Generator for '#omp ordered depend (source | sink)'.
Definition: OMPIRBuilder.cpp:2462
llvm::OpenMPIRBuilder::finalize
void finalize(Function *Fn=nullptr, bool AllowExtractorSinking=false)
Finalize the underlying module, e.g., by outlining regions.
Definition: OMPIRBuilder.cpp:159
Mappings
Inject TLI Mappings
Definition: InjectTLIMappings.cpp:172
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::OpenMPIRBuilder::popFinalizationCB
void popFinalizationCB()
Pop the last finalization callback from the finalization stack.
Definition: OMPIRBuilder.h:88
llvm::OpenMPIRBuilder::getOrCreateDefaultSrcLocStr
Constant * getOrCreateDefaultSrcLocStr()
Return the (LLVM-IR) string describing the default source location.
Definition: OMPIRBuilder.cpp:333
llvm::OpenMPIRBuilder::emitMapperCall
void emitMapperCall(const LocationDescription &Loc, Function *MapperFunc, Value *SrcLocInfo, Value *MaptypesArg, Value *MapnamesArg, struct MapperAllocas &MapperAllocas, int64_t DeviceID, unsigned NumOperands)
Create the call for the target mapper function.
Definition: OMPIRBuilder.cpp:2915
llvm::OpenMPIRBuilder::getOrCreateIdent
Value * getOrCreateIdent(Constant *SrcLocStr, omp::IdentFlag Flags=omp::IdentFlag(0), unsigned Reserve2Flags=0)
Return an ident_t* encoding the source location SrcLocStr and Flags.
Definition: OMPIRBuilder.cpp:258
llvm::OpenMPIRBuilder::M
Module & M
The underlying LLVM-IR module.
Definition: OMPIRBuilder.h:745
llvm::CanonicalLoopInfo::assertOK
void assertOK() const
Consistency self-check.
Definition: OMPIRBuilder.cpp:3325
llvm::CanonicalLoopInfo::getCond
BasicBlock * getCond() const
The condition block computes whether there is another loop iteration.
Definition: OMPIRBuilder.h:1453
llvm::OpenMPIRBuilder
An interface to create LLVM-IR for OpenMP directives.
Definition: OMPIRBuilder.h:29
llvm::OpenMPIRBuilder::OutlineInfos
SmallVector< OutlineInfo, 16 > OutlineInfos
Collection of regions that need to be outlined during finalization.
Definition: OMPIRBuilder.h:773
llvm::OpenMPIRBuilder::createOMPFree
CallInst * createOMPFree(const LocationDescription &Loc, Value *Addr, Value *Allocator, std::string Name="")
Create a runtime call for kmpc_free.
Definition: OMPIRBuilder.cpp:2728
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:296
llvm::OpenMPIRBuilder::createMapperAllocas
void createMapperAllocas(const LocationDescription &Loc, InsertPointTy AllocaIP, unsigned NumOperands, struct MapperAllocas &MapperAllocas)
Create the allocas instruction used in call to mapper functions.
Definition: OMPIRBuilder.cpp:2896
llvm::OpenMPIRBuilder::ReductionInfo::ReductionInfo
ReductionInfo(Value *Variable, Value *PrivateVariable, ReductionGenTy ReductionGen, AtomicReductionGenTy AtomicReductionGen)
Definition: OMPIRBuilder.h:549
llvm::OpenMPIRBuilder::createBarrier
InsertPointTy createBarrier(const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall=false, bool CheckCancelFlag=true)
Emitter methods for OpenMP directives.
Definition: OMPIRBuilder.cpp:364
llvm::OpenMPIRBuilder::createAtomicRead
InsertPointTy createAtomicRead(const LocationDescription &Loc, AtomicOpValue &X, AtomicOpValue &V, AtomicOrdering AO)
Emit atomic Read for : V = X — Only Scalar data types.
Definition: OMPIRBuilder.cpp:3002
IP
Definition: NVPTXLowerArgs.cpp:166
llvm::OpenMPIRBuilder::getInsertionPoint
InsertPointTy getInsertionPoint()
}
Definition: OMPIRBuilder.h:647
llvm::IRBuilderBase::SetCurrentDebugLocation
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:208
llvm::OpenMPIRBuilder::~OpenMPIRBuilder
~OpenMPIRBuilder()
Definition: OMPIRBuilder.cpp:244
llvm::IntegerType
Class to represent integer types.
Definition: DerivedTypes.h:40
llvm::CanonicalLoopInfo::isValid
bool isValid() const
Returns whether this object currently represents the IR of a loop.
Definition: OMPIRBuilder.h:1433
llvm::OpenMPIRBuilder::IdentMap
DenseMap< std::pair< Constant *, uint64_t >, Value * > IdentMap
Map to remember existing ident_t*.
Definition: OMPIRBuilder.h:754
llvm::OpenMPIRBuilder::AtomicOpValue::IsSigned
bool IsSigned
Definition: OMPIRBuilder.h:1192
llvm::OpenMPIRBuilder::LocationDescription::LocationDescription
LocationDescription(const InsertPointTy &IP)
Definition: OMPIRBuilder.h:154
llvm::Instruction
Definition: Instruction.h:45
llvm::OpenMPIRBuilder::StorableBodyGenCallbackTy
std::function< void(InsertPointTy AllocaIP, InsertPointTy CodeGenIP, BasicBlock &ContinuationBB)> StorableBodyGenCallbackTy
Definition: OMPIRBuilder.h:113
llvm::OpenMPIRBuilder::LocationDescription::LocationDescription
LocationDescription(const InsertPointTy &IP, const DebugLoc &DL)
Definition: OMPIRBuilder.h:155
llvm::CanonicalLoopInfo::getBodyIP
OpenMPIRBuilder::InsertPointTy getBodyIP() const
Return the insertion point for user code in the body.
Definition: OMPIRBuilder.h:1522
DebugLoc.h
llvm::OpenMPIRBuilder::MapperAllocas::Args
AllocaInst * Args
Definition: OMPIRBuilder.h:800
llvm::omp::IdentFlag
IdentFlag
IDs for all omp runtime library ident_t flag encodings (see their defintion in openmp/runtime/src/kmp...
Definition: OMPConstants.h:74
llvm::OpenMPIRBuilder::OpenMPIRBuilder
OpenMPIRBuilder(Module &M)
Create a new OpenMPIRBuilder operating on the given module M.
Definition: OMPIRBuilder.h:33
llvm::OpenMPIRBuilder::unrollLoopFull
void unrollLoopFull(DebugLoc DL, CanonicalLoopInfo *Loop)
Fully unroll a loop.
Definition: OMPIRBuilder.cpp:2119
llvm::OpenMPIRBuilder::emitTaskwaitImpl
void emitTaskwaitImpl(const LocationDescription &Loc)
Generate a taskwait runtime call.
Definition: OMPIRBuilder.cpp:886
llvm::OpenMPIRBuilder::createAtomicUpdate
InsertPointTy createAtomicUpdate(const LocationDescription &Loc, Instruction *AllocIP, AtomicOpValue &X, Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp, bool IsXLHSInRHSPart)
Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X For complex Operations: X = ...
Definition: OMPIRBuilder.cpp:3077
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::OpenMPIRBuilder::createOMPAlloc
CallInst * createOMPAlloc(const LocationDescription &Loc, Value *Size, Value *Allocator, std::string Name="")
Create a runtime call for kmpc_Alloc.
Definition: OMPIRBuilder.cpp:2712
llvm::OpenMPIRBuilder::addAttributes
void addAttributes(omp::RuntimeFunction FnID, Function &Fn)
Add attributes known for FnID to Fn.
Definition: OMPIRBuilder.cpp:59
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::OpenMPIRBuilder::applyDynamicWorkshareLoop
InsertPointTy applyDynamicWorkshareLoop(DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, omp::OMPScheduleType SchedType, bool NeedsBarrier, Value *Chunk=nullptr)
Modifies the canonical loop to be a dynamically-scheduled workshare loop.
Definition: OMPIRBuilder.cpp:1604
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:108
llvm::OpenMPIRBuilder::OutlineInfo::EntryBB
BasicBlock * EntryBB
Definition: OMPIRBuilder.h:761
llvm::OpenMPIRBuilder::Builder
IRBuilder Builder
The LLVM-IR Builder used to create IR.
Definition: OMPIRBuilder.h:748
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::omp::RuntimeFunction
RuntimeFunction
IDs for all omp runtime library (RTL) functions.
Definition: OMPConstants.h:54
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition: AtomicOrdering.h:56
llvm::OpenMPIRBuilder::createTaskyield
void createTaskyield(const LocationDescription &Loc)
Generator for '#omp taskyield'.
Definition: OMPIRBuilder.cpp:915
llvm::CanonicalLoopInfo::getPreheader
BasicBlock * getPreheader() const
The preheader ensures that there is only a single edge entering the loop.
Definition: OMPIRBuilder.h:1439
llvm::OpenMPIRBuilder::createOffloadMaptypes
GlobalVariable * createOffloadMaptypes(SmallVectorImpl< uint64_t > &Mappings, std::string VarName)
Create the global variable holding the offload mappings information.
Definition: OMPIRBuilder.cpp:2884
llvm::OpenMPIRBuilder::AtomicOpValue::IsVolatile
bool IsVolatile
Definition: OMPIRBuilder.h:1193
llvm::OpenMPIRBuilder::createSections
InsertPointTy createSections(const LocationDescription &Loc, InsertPointTy AllocaIP, ArrayRef< StorableBodyGenCallbackTy > SectionCBs, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, bool IsCancellable, bool IsNowait)
Generator for '#omp sections'.
Definition: OMPIRBuilder.cpp:921
llvm::OpenMPIRBuilder::MapperAllocas::ArgsBase
AllocaInst * ArgsBase
Definition: OMPIRBuilder.h:799
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::OpenMPIRBuilder::ReductionInfo::PrivateVariable
Value * PrivateVariable
Thread-private partial reduction variable.
Definition: OMPIRBuilder.h:564
llvm::OpenMPIRBuilder::createOrderedThreadsSimd
InsertPointTy createOrderedThreadsSimd(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool IsThreads)
Generator for '#omp ordered [threads | simd]'.
Definition: OMPIRBuilder.cpp:2501
llvm::OpenMPIRBuilder::OutlineInfo::getFunction
Function * getFunction() const
Return the function that contains the region to be outlined.
Definition: OMPIRBuilder.h:769
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::OpenMPIRBuilder::isLastFinalizationInfoCancellable
bool isLastFinalizationInfoCancellable(omp::Directive DK)
Return true if the last entry in the finalization stack is of kind DK and cancellable.
Definition: OMPIRBuilder.h:723
llvm::DenseMap
Definition: DenseMap.h:714
llvm::OpenMPIRBuilder::FinalizationInfo::DK
omp::Directive DK
The directive kind of the innermost directive that has an associated region which might require final...
Definition: OMPIRBuilder.h:72
llvm::OpenMPIRBuilder::emitCancelationCheckImpl
void emitCancelationCheckImpl(Value *CancelFlag, omp::Directive CanceledDirective, FinalizeCallbackTy ExitCB={})
Generate control flow and cleanup for cancellation.
Definition: OMPIRBuilder.cpp:469
llvm::OpenMPIRBuilder::createCanonicalLoop
CanonicalLoopInfo * createCanonicalLoop(const LocationDescription &Loc, LoopBodyGenCallbackTy BodyGenCB, Value *TripCount, const Twine &Name="loop")
Generator for the control flow structure of an OpenMP canonical loop.
Definition: OMPIRBuilder.cpp:1345
llvm::OpenMPIRBuilder::createTargetInit
InsertPointTy createTargetInit(const LocationDescription &Loc, bool IsSPMD, bool RequiresFullRuntime)
The omp target interface.
Definition: OMPIRBuilder.cpp:2762
llvm::OpenMPIRBuilder::createParallel
IRBuilder ::InsertPoint createParallel(const LocationDescription &Loc, InsertPointTy AllocaIP, BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, Value *IfCondition, Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable)
Generator for '#omp parallel'.
Definition: OMPIRBuilder.cpp:508
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::OpenMPIRBuilder::ReductionGenTy
function_ref< InsertPointTy(InsertPointTy, Value *, Value *, Value *&)> ReductionGenTy
Functions used to generate reductions.
Definition: OMPIRBuilder.h:539
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::OpenMPIRBuilder::LocationDescription::DL
DebugLoc DL
Definition: OMPIRBuilder.h:158
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::OpenMPIRBuilder::unrollLoopHeuristic
void unrollLoopHeuristic(DebugLoc DL, CanonicalLoopInfo *Loop)
Fully or partially unroll a loop.
Definition: OMPIRBuilder.cpp:2126
llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr
Function * getOrCreateRuntimeFunctionPtr(omp::RuntimeFunction FnID)
Definition: OMPIRBuilder.cpp:150
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::OpenMPIRBuilder::createMaster
InsertPointTy createMaster(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
Generator for '#omp master'.
Definition: OMPIRBuilder.cpp:1228
llvm::OpenMPIRBuilder::createFlush
void createFlush(const LocationDescription &Loc)
Generator for '#omp flush'.
Definition: OMPIRBuilder.cpp:880
llvm::OpenMPIRBuilder::OutlineInfo
Helper that contains information about regions we need to outline during finalization.
Definition: OMPIRBuilder.h:758
llvm::CanonicalLoopInfo
Class to represented the control flow structure of an OpenMP canonical loop.
Definition: OMPIRBuilder.h:1407
llvm::OpenMPIRBuilder::createGlobalFlag
GlobalValue * createGlobalFlag(unsigned Value, StringRef Name)
Create a global flag Namein the module with initial value Value.
Definition: OMPIRBuilder.cpp:248
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:179
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::OpenMPIRBuilder::createOffloadMapnames
GlobalVariable * createOffloadMapnames(SmallVectorImpl< llvm::Constant * > &Names, std::string VarName)
Create the global variable holding the offload names information.
Definition: OMPIRBuilder.cpp:3264
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::OpenMPIRBuilder::MapperAllocas::ArgSizes
AllocaInst * ArgSizes
Definition: OMPIRBuilder.h:801
llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCB
PostOutlineCBTy PostOutlineCB
Definition: OMPIRBuilder.h:760
llvm::OpenMPIRBuilder::unrollLoopPartial
void unrollLoopPartial(DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor, CanonicalLoopInfo **UnrolledCLI)
Partially unroll a loop.
Definition: OMPIRBuilder.cpp:2304
llvm::OpenMPIRBuilder::addOutlineInfo
void addOutlineInfo(OutlineInfo &&OI)
Add a new region that will be outlined later.
Definition: OMPIRBuilder.h:780
llvm::OpenMPIRBuilder::createMasked
InsertPointTy createMasked(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, Value *Filter)
Generator for '#omp masked'.
Definition: OMPIRBuilder.cpp:1252
llvm::OpenMPIRBuilder::applyWorkshareLoop
InsertPointTy applyWorkshareLoop(DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier)
Modifies the canonical loop to be a workshare loop.
Definition: OMPIRBuilder.cpp:1566
llvm::OpenMPIRBuilder::updateToLocation
bool updateToLocation(const LocationDescription &Loc)
Update the internal location to Loc.
Definition: OMPIRBuilder.h:650
llvm::OpenMPIRBuilder::FinalizationStack
SmallVector< FinalizationInfo, 8 > FinalizationStack
The finalization stack made up of finalize callbacks currently in-flight, wrapped into FinalizationIn...
Definition: OMPIRBuilder.h:719
llvm::BasicBlock::front
const Instruction & front() const
Definition: BasicBlock.h:308
llvm::CanonicalLoopInfo::getExit
BasicBlock * getExit() const
Reaching the exit indicates no more iterations are being executed.
Definition: OMPIRBuilder.h:1475
llvm::OpenMPIRBuilder::LoopInfos
std::forward_list< CanonicalLoopInfo > LoopInfos
Collection of owned canonical loop objects that eventually need to be free'd.
Definition: OMPIRBuilder.h:777
llvm::OpenMPIRBuilder::createTaskwait
void createTaskwait(const LocationDescription &Loc)
Generator for '#omp taskwait'.
Definition: OMPIRBuilder.cpp:898
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::OpenMPIRBuilder::ReductionInfo::ReductionGen
ReductionGenTy ReductionGen
Callback for generating the reduction body.
Definition: OMPIRBuilder.h:569
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::OpenMPIRBuilder::createAtomicWrite
InsertPointTy createAtomicWrite(const LocationDescription &Loc, AtomicOpValue &X, Value *Expr, AtomicOrdering AO)
Emit atomic write for : X = Expr — Only Scalar data types.
Definition: OMPIRBuilder.cpp:3044
llvm::CanonicalLoopInfo::invalidate
void invalidate()
Invalidate this loop.
Definition: OMPIRBuilder.cpp:3415
llvm::OpenMPIRBuilder::createCancel
InsertPointTy createCancel(const LocationDescription &Loc, Value *IfCondition, omp::Directive CanceledDirective)
Generator for '#omp cancel'.
Definition: OMPIRBuilder.cpp:419
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCBTy
std::function< void(Function &)> PostOutlineCBTy
Definition: OMPIRBuilder.h:759
llvm::CanonicalLoopInfo::getHeader
BasicBlock * getHeader() const
The header is the entry for each iteration.
Definition: OMPIRBuilder.h:1446
llvm::OpenMPIRBuilder::getOrCreateSrcLocStr
Constant * getOrCreateSrcLocStr(StringRef LocStr)
Return the (LLVM-IR) string describing the source location LocStr.
Definition: OMPIRBuilder.cpp:296
OMPConstants.h
llvm::OpenMPIRBuilder::createTargetDeinit
void createTargetDeinit(const LocationDescription &Loc, bool IsSPMD, bool RequiresFullRuntime)
Create a runtime call for kmpc_target_deinit.
Definition: OMPIRBuilder.cpp:2814
llvm::OpenMPIRBuilder::ReductionInfo
Information about an OpenMP reduction.
Definition: OMPIRBuilder.h:548
llvm::IRBuilderBase::saveIP
InsertPoint saveIP() const
Returns the current insert point.
Definition: IRBuilder.h:271
llvm::OpenMPIRBuilder::initialize
void initialize()
Initialize the internal state, this will put structures types and potentially other helpers into the ...
Definition: OMPIRBuilder.cpp:157
llvm::CanonicalLoopInfo::getLatch
BasicBlock * getLatch() const
Reaching the latch indicates the end of the loop body code.
Definition: OMPIRBuilder.h:1469
llvm::OpenMPIRBuilder::FinalizationInfo
Definition: OMPIRBuilder.h:65
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
llvm::Type::getPointerElementType
Type * getPointerElementType() const
Definition: Type.h:369
llvm::CanonicalLoopInfo::getIndVarType
Type * getIndVarType() const
Return the type of the induction variable (and the trip count).
Definition: OMPIRBuilder.h:1510
llvm::OpenMPIRBuilder::SrcLocStrMap
StringMap< Constant * > SrcLocStrMap
Map to remember source location strings.
Definition: OMPIRBuilder.h:751
llvm::OpenMPIRBuilder::emitBarrierImpl
InsertPointTy emitBarrierImpl(const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall, bool CheckCancelFlag)
Generate a barrier runtime call.
Definition: OMPIRBuilder.cpp:372
llvm::OpenMPIRBuilder::InternalVars
StringMap< AssertingVH< Constant >, BumpPtrAllocator > InternalVars
An ordered map of auto-generated variables to their unique names.
Definition: OMPIRBuilder.h:787
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:165
llvm::SmallVectorImpl< BasicBlock * >
llvm::CanonicalLoopInfo::getTripCount
Value * getTripCount() const
Returns the llvm::Value containing the number of loop iterations.
Definition: OMPIRBuilder.h:1493
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
llvm::OpenMPIRBuilder::emitFlush
void emitFlush(const LocationDescription &Loc)
Generate a flush runtime call.
Definition: OMPIRBuilder.cpp:872
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1475
llvm::OpenMPIRBuilder::OutlineInfo::collectBlocks
void collectBlocks(SmallPtrSetImpl< BasicBlock * > &BlockSet, SmallVectorImpl< BasicBlock * > &BlockVector)
Collect all blocks in between EntryBB and ExitBB in both the given vector and set.
Definition: OMPIRBuilder.cpp:3298
llvm::OpenMPIRBuilder::MapperAllocas
Definition: OMPIRBuilder.h:798
llvm::OpenMPIRBuilder::applyStaticWorkshareLoop
InsertPointTy applyStaticWorkshareLoop(DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier, Value *Chunk=nullptr)
Modifies the canonical loop to be a statically-scheduled workshare loop.
Definition: OMPIRBuilder.cpp:1475
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:62
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::OpenMPIRBuilder::createSingle
InsertPointTy createSingle(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, llvm::Value *DidIt)
Generator for '#omp single'.
Definition: OMPIRBuilder.cpp:2394
llvm::OpenMPIRBuilder::createCopyinClauseBlocks
InsertPointTy createCopyinClauseBlocks(InsertPointTy IP, Value *MasterAddr, Value *PrivateAddr, llvm::IntegerType *IntPtrTy, bool BranchtoEnd=true)
Generate conditional branch and relevant BasicBlocks through which private threads copy the 'copyin' ...
Definition: OMPIRBuilder.cpp:2662
llvm::OpenMPIRBuilder::createCopyPrivate
InsertPointTy createCopyPrivate(const LocationDescription &Loc, llvm::Value *BufSize, llvm::Value *CpyBuf, llvm::Value *CpyFn, llvm::Value *DidIt)
Generator for __kmpc_copyprivate.
Definition: OMPIRBuilder.cpp:2373
llvm::omp::OMPScheduleType
OMPScheduleType
Definition: OMPConstants.h:113
llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction
FunctionCallee getOrCreateRuntimeFunction(Module &M, omp::RuntimeFunction FnID)
Return the function declaration for the runtime function with FnID.
Definition: OMPIRBuilder.cpp:92
llvm::OpenMPIRBuilder::ReductionInfo::AtomicReductionGen
AtomicReductionGenTy AtomicReductionGen
Callback for generating the atomic reduction body, may be null.
Definition: OMPIRBuilder.h:575
llvm::CanonicalLoopInfo::getBody
BasicBlock * getBody() const
The body block is the single entry for a loop iteration and not controlled by CanonicalLoopInfo.
Definition: OMPIRBuilder.h:1461
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::OpenMPIRBuilder::LocationDescription::IP
InsertPointTy IP
Definition: OMPIRBuilder.h:157