LLVM  13.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)
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 the
267  /// iterations.
268  /// \param Step Loop counter increment after each iteration; negative
269  /// means counting down. \param IsSigned Whether Start, Stop
270  /// and Stop are signed integers.
271  /// \param InclusiveStop Whether \p Stop itself is a valid value for the loop
272  /// counter.
273  /// \param ComputeIP Insertion point for instructions computing the trip
274  /// count. Can be used to ensure the trip count is available
275  /// at the outermost loop of a loop nest. If not set,
276  /// defaults to the preheader of the generated loop.
277  /// \param Name Base name used to derive BB and instruction names.
278  ///
279  /// \returns An object representing the created control flow structure which
280  /// can be used for loop-associated directives.
282  LoopBodyGenCallbackTy BodyGenCB,
283  Value *Start, Value *Stop, Value *Step,
284  bool IsSigned, bool InclusiveStop,
285  InsertPointTy ComputeIP = {},
286  const Twine &Name = "loop");
287 
288  /// Collapse a loop nest into a single loop.
289  ///
290  /// Merges loops of a loop nest into a single CanonicalLoopNest representation
291  /// that has the same number of innermost loop iterations as the origin loop
292  /// nest. The induction variables of the input loops are derived from the
293  /// collapsed loop's induction variable. This is intended to be used to
294  /// implement OpenMP's collapse clause. Before applying a directive,
295  /// collapseLoops normalizes a loop nest to contain only a single loop and the
296  /// directive's implementation does not need to handle multiple loops itself.
297  /// This does not remove the need to handle all loop nest handling by
298  /// directives, such as the ordered(<n>) clause or the simd schedule-clause
299  /// modifier of the worksharing-loop directive.
300  ///
301  /// Example:
302  /// \code
303  /// for (int i = 0; i < 7; ++i) // Canonical loop "i"
304  /// for (int j = 0; j < 9; ++j) // Canonical loop "j"
305  /// body(i, j);
306  /// \endcode
307  ///
308  /// After collapsing with Loops={i,j}, the loop is changed to
309  /// \code
310  /// for (int ij = 0; ij < 63; ++ij) {
311  /// int i = ij / 9;
312  /// int j = ij % 9;
313  /// body(i, j);
314  /// }
315  /// \endcode
316  ///
317  /// In the current implementation, the following limitations apply:
318  ///
319  /// * All input loops have an induction variable of the same type.
320  ///
321  /// * The collapsed loop will have the same trip count integer type as the
322  /// input loops. Therefore it is possible that the collapsed loop cannot
323  /// represent all iterations of the input loops. For instance, assuming a
324  /// 32 bit integer type, and two input loops both iterating 2^16 times, the
325  /// theoretical trip count of the collapsed loop would be 2^32 iteration,
326  /// which cannot be represented in an 32-bit integer. Behavior is undefined
327  /// in this case.
328  ///
329  /// * The trip counts of every input loop must be available at \p ComputeIP.
330  /// Non-rectangular loops are not yet supported.
331  ///
332  /// * At each nest level, code between a surrounding loop and its nested loop
333  /// is hoisted into the loop body, and such code will be executed more
334  /// often than before collapsing (or not at all if any inner loop iteration
335  /// has a trip count of 0). This is permitted by the OpenMP specification.
336  ///
337  /// \param DL Debug location for instructions added for collapsing,
338  /// such as instructions to compute derive the input loop's
339  /// induction variables.
340  /// \param Loops Loops in the loop nest to collapse. Loops are specified
341  /// from outermost-to-innermost and every control flow of a
342  /// loop's body must pass through its directly nested loop.
343  /// \param ComputeIP Where additional instruction that compute the collapsed
344  /// trip count. If not set, defaults to before the generated
345  /// loop.
346  ///
347  /// \returns The CanonicalLoopInfo object representing the collapsed loop.
350  InsertPointTy ComputeIP);
351 
352  /// Modifies the canonical loop to be a statically-scheduled workshare loop.
353  ///
354  /// This takes a \p LoopInfo representing a canonical loop, such as the one
355  /// created by \p createCanonicalLoop and emits additional instructions to
356  /// turn it into a workshare loop. In particular, it calls to an OpenMP
357  /// runtime function in the preheader to obtain the loop bounds to be used in
358  /// the current thread, updates the relevant instructions in the canonical
359  /// loop and calls to an OpenMP runtime finalization function after the loop.
360  ///
361  /// \param Loc The source location description, the insertion location
362  /// is not used.
363  /// \param CLI A descriptor of the canonical loop to workshare.
364  /// \param AllocaIP An insertion point for Alloca instructions usable in the
365  /// preheader of the loop.
366  /// \param NeedsBarrier Indicates whether a barrier must be inserted after
367  /// the loop.
368  /// \param Chunk The size of loop chunk considered as a unit when
369  /// scheduling. If \p nullptr, defaults to 1.
370  ///
371  /// \returns Updated CanonicalLoopInfo.
372  CanonicalLoopInfo *createStaticWorkshareLoop(const LocationDescription &Loc,
373  CanonicalLoopInfo *CLI,
374  InsertPointTy AllocaIP,
375  bool NeedsBarrier,
376  Value *Chunk = nullptr);
377 
378  /// Modifies the canonical loop to be a dynamically-scheduled workshare loop.
379  ///
380  /// This takes a \p LoopInfo representing a canonical loop, such as the one
381  /// created by \p createCanonicalLoop and emits additional instructions to
382  /// turn it into a workshare loop. In particular, it calls to an OpenMP
383  /// runtime function in the preheader to obtain, and then in each iteration
384  /// to update the loop counter.
385  /// \param Loc The source location description, the insertion location
386  /// is not used.
387  /// \param CLI A descriptor of the canonical loop to workshare.
388  /// \param AllocaIP An insertion point for Alloca instructions usable in the
389  /// preheader of the loop.
390  /// \param SchedType Type of scheduling to be passed to the init function.
391  /// \param NeedsBarrier Indicates whether a barrier must be insterted after
392  /// the loop.
393  /// \param Chunk The size of loop chunk considered as a unit when
394  /// scheduling. If \p nullptr, defaults to 1.
395  ///
396  /// \returns Point where to insert code after the loop.
397  InsertPointTy createDynamicWorkshareLoop(const LocationDescription &Loc,
398  CanonicalLoopInfo *CLI,
399  InsertPointTy AllocaIP,
400  omp::OMPScheduleType SchedType,
401  bool NeedsBarrier,
402  Value *Chunk = nullptr);
403 
404  /// Modifies the canonical loop to be a workshare loop.
405  ///
406  /// This takes a \p LoopInfo representing a canonical loop, such as the one
407  /// created by \p createCanonicalLoop and emits additional instructions to
408  /// turn it into a workshare loop. In particular, it calls to an OpenMP
409  /// runtime function in the preheader to obtain the loop bounds to be used in
410  /// the current thread, updates the relevant instructions in the canonical
411  /// loop and calls to an OpenMP runtime finalization function after the loop.
412  ///
413  /// \param Loc The source location description, the insertion location
414  /// is not used.
415  /// \param CLI A descriptor of the canonical loop to workshare.
416  /// \param AllocaIP An insertion point for Alloca instructions usable in the
417  /// preheader of the loop.
418  /// \param NeedsBarrier Indicates whether a barrier must be insterted after
419  /// the loop.
420  ///
421  /// \returns Updated CanonicalLoopInfo.
422  CanonicalLoopInfo *createWorkshareLoop(const LocationDescription &Loc,
423  CanonicalLoopInfo *CLI,
424  InsertPointTy AllocaIP,
425  bool NeedsBarrier);
426 
427  /// Tile a loop nest.
428  ///
429  /// Tiles the loops of \p Loops by the tile sizes in \p TileSizes. Loops in
430  /// \p/ Loops must be perfectly nested, from outermost to innermost loop
431  /// (i.e. Loops.front() is the outermost loop). The trip count llvm::Value
432  /// of every loop and every tile sizes must be usable in the outermost
433  /// loop's preheader. This implies that the loop nest is rectangular.
434  ///
435  /// Example:
436  /// \code
437  /// for (int i = 0; i < 15; ++i) // Canonical loop "i"
438  /// for (int j = 0; j < 14; ++j) // Canonical loop "j"
439  /// body(i, j);
440  /// \endcode
441  ///
442  /// After tiling with Loops={i,j} and TileSizes={5,7}, the loop is changed to
443  /// \code
444  /// for (int i1 = 0; i1 < 3; ++i1)
445  /// for (int j1 = 0; j1 < 2; ++j1)
446  /// for (int i2 = 0; i2 < 5; ++i2)
447  /// for (int j2 = 0; j2 < 7; ++j2)
448  /// body(i1*3+i2, j1*3+j2);
449  /// \endcode
450  ///
451  /// The returned vector are the loops {i1,j1,i2,j2}. The loops i1 and j1 are
452  /// referred to the floor, and the loops i2 and j2 are the tiles. Tiling also
453  /// handles non-constant trip counts, non-constant tile sizes and trip counts
454  /// that are not multiples of the tile size. In the latter case the tile loop
455  /// of the last floor-loop iteration will have fewer iterations than specified
456  /// as its tile size.
457  ///
458  ///
459  /// @param DL Debug location for instructions added by tiling, for
460  /// instance the floor- and tile trip count computation.
461  /// @param Loops Loops to tile. The CanonicalLoopInfo objects are
462  /// invalidated by this method, i.e. should not used after
463  /// tiling.
464  /// @param TileSizes For each loop in \p Loops, the tile size for that
465  /// dimensions.
466  ///
467  /// \returns A list of generated loops. Contains twice as many loops as the
468  /// input loop nest; the first half are the floor loops and the
469  /// second half are the tile loops.
470  std::vector<CanonicalLoopInfo *>
472  ArrayRef<Value *> TileSizes);
473 
474  /// Generator for '#omp flush'
475  ///
476  /// \param Loc The location where the flush directive was encountered
477  void createFlush(const LocationDescription &Loc);
478 
479  /// Generator for '#omp taskwait'
480  ///
481  /// \param Loc The location where the taskwait directive was encountered.
482  void createTaskwait(const LocationDescription &Loc);
483 
484  /// Generator for '#omp taskyield'
485  ///
486  /// \param Loc The location where the taskyield directive was encountered.
487  void createTaskyield(const LocationDescription &Loc);
488 
489  ///}
490 
491  /// Return the insertion point used by the underlying IRBuilder.
493 
494  /// Update the internal location to \p Loc.
496  Builder.restoreIP(Loc.IP);
498  return Loc.IP.getBlock() != nullptr;
499  }
500 
501  /// Return the function declaration for the runtime function with \p FnID.
503  omp::RuntimeFunction FnID);
504 
506 
507  /// Return the (LLVM-IR) string describing the source location \p LocStr.
509 
510  /// Return the (LLVM-IR) string describing the default source location.
512 
513  /// Return the (LLVM-IR) string describing the source location identified by
514  /// the arguments.
515  Constant *getOrCreateSrcLocStr(StringRef FunctionName, StringRef FileName,
516  unsigned Line, unsigned Column);
517 
518  /// Return the (LLVM-IR) string describing the source location \p Loc.
519  Constant *getOrCreateSrcLocStr(const LocationDescription &Loc);
520 
521  /// Return an ident_t* encoding the source location \p SrcLocStr and \p Flags.
522  /// TODO: Create a enum class for the Reserve2Flags
523  Value *getOrCreateIdent(Constant *SrcLocStr,
524  omp::IdentFlag Flags = omp::IdentFlag(0),
525  unsigned Reserve2Flags = 0);
526 
527  // Get the type corresponding to __kmpc_impl_lanemask_t from the deviceRTL
529 
530  /// Generate control flow and cleanup for cancellation.
531  ///
532  /// \param CancelFlag Flag indicating if the cancellation is performed.
533  /// \param CanceledDirective The kind of directive that is cancled.
534  /// \param ExitCB Extra code to be generated in the exit block.
535  void emitCancelationCheckImpl(Value *CancelFlag,
536  omp::Directive CanceledDirective,
537  FinalizeCallbackTy ExitCB = {});
538 
539  /// Generate a barrier runtime call.
540  ///
541  /// \param Loc The location at which the request originated and is fulfilled.
542  /// \param DK The directive which caused the barrier
543  /// \param ForceSimpleCall Flag to force a simple (=non-cancellation) barrier.
544  /// \param CheckCancelFlag Flag to indicate a cancel barrier return value
545  /// should be checked and acted upon.
546  ///
547  /// \returns The insertion point after the barrier.
548  InsertPointTy emitBarrierImpl(const LocationDescription &Loc,
549  omp::Directive DK, bool ForceSimpleCall,
550  bool CheckCancelFlag);
551 
552  /// Generate a flush runtime call.
553  ///
554  /// \param Loc The location at which the request originated and is fulfilled.
555  void emitFlush(const LocationDescription &Loc);
556 
557  /// The finalization stack made up of finalize callbacks currently in-flight,
558  /// wrapped into FinalizationInfo objects that reference also the finalization
559  /// target block and the kind of cancellable directive.
561 
562  /// Return true if the last entry in the finalization stack is of kind \p DK
563  /// and cancellable.
564  bool isLastFinalizationInfoCancellable(omp::Directive DK) {
565  return !FinalizationStack.empty() &&
566  FinalizationStack.back().IsCancellable &&
567  FinalizationStack.back().DK == DK;
568  }
569 
570  /// Generate a taskwait runtime call.
571  ///
572  /// \param Loc The location at which the request originated and is fulfilled.
573  void emitTaskwaitImpl(const LocationDescription &Loc);
574 
575  /// Generate a taskyield runtime call.
576  ///
577  /// \param Loc The location at which the request originated and is fulfilled.
578  void emitTaskyieldImpl(const LocationDescription &Loc);
579 
580  /// Return the current thread ID.
581  ///
582  /// \param Ident The ident (ident_t*) describing the query origin.
584 
585  /// The underlying LLVM-IR module
587 
588  /// The LLVM-IR Builder used to create IR.
590 
591  /// Map to remember source location strings
593 
594  /// Map to remember existing ident_t*.
596 
597  /// Helper that contains information about regions we need to outline
598  /// during finalization.
599  struct OutlineInfo {
603 
604  /// Collect all blocks in between EntryBB and ExitBB in both the given
605  /// vector and set.
607  SmallVectorImpl<BasicBlock *> &BlockVector);
608 
609  /// Return the function that contains the region to be outlined.
610  Function *getFunction() const { return EntryBB->getParent(); }
611  };
612 
613  /// Collection of regions that need to be outlined during finalization.
615 
616  /// Collection of owned canonical loop objects that eventually need to be
617  /// free'd.
618  std::forward_list<CanonicalLoopInfo> LoopInfos;
619 
620  /// Add a new region that will be outlined later.
621  void addOutlineInfo(OutlineInfo &&OI) { OutlineInfos.emplace_back(OI); }
622 
623  /// An ordered map of auto-generated variables to their unique names.
624  /// It stores variables with the following names: 1) ".gomp_critical_user_" +
625  /// <critical_section_name> + ".var" for "omp critical" directives; 2)
626  /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
627  /// variables.
629 
630  /// Create the global variable holding the offload mappings information.
632  std::string VarName);
633 
634  /// Create the global variable holding the offload names information.
637  std::string VarName);
638 
639 public:
640  /// Generator for __kmpc_copyprivate
641  ///
642  /// \param Loc The source location description.
643  /// \param BufSize Number of elements in the buffer.
644  /// \param CpyBuf List of pointers to data to be copied.
645  /// \param CpyFn function to call for copying data.
646  /// \param DidIt flag variable; 1 for 'single' thread, 0 otherwise.
647  ///
648  /// \return The insertion position *after* the CopyPrivate call.
649 
651  llvm::Value *BufSize, llvm::Value *CpyBuf,
652  llvm::Value *CpyFn, llvm::Value *DidIt);
653 
654  /// Generator for '#omp single'
655  ///
656  /// \param Loc The source location description.
657  /// \param BodyGenCB Callback that will generate the region code.
658  /// \param FiniCB Callback to finalize variable copies.
659  /// \param DidIt Local variable used as a flag to indicate 'single' thread
660  ///
661  /// \returns The insertion position *after* the single call.
663  BodyGenCallbackTy BodyGenCB,
664  FinalizeCallbackTy FiniCB, llvm::Value *DidIt);
665 
666  /// Generator for '#omp master'
667  ///
668  /// \param Loc The insert and source location description.
669  /// \param BodyGenCB Callback that will generate the region code.
670  /// \param FiniCB Callback to finalize variable copies.
671  ///
672  /// \returns The insertion position *after* the master.
674  BodyGenCallbackTy BodyGenCB,
675  FinalizeCallbackTy FiniCB);
676 
677  /// Generator for '#omp masked'
678  ///
679  /// \param Loc The insert and source location description.
680  /// \param BodyGenCB Callback that will generate the region code.
681  /// \param FiniCB Callback to finialize variable copies.
682  ///
683  /// \returns The insertion position *after* the master.
685  BodyGenCallbackTy BodyGenCB,
686  FinalizeCallbackTy FiniCB, Value *Filter);
687 
688  /// Generator for '#omp critical'
689  ///
690  /// \param Loc The insert and source location description.
691  /// \param BodyGenCB Callback that will generate the region body code.
692  /// \param FiniCB Callback to finalize variable copies.
693  /// \param CriticalName name of the lock used by the critical directive
694  /// \param HintInst Hint Instruction for hint clause associated with critical
695  ///
696  /// \returns The insertion position *after* the master.
698  BodyGenCallbackTy BodyGenCB,
699  FinalizeCallbackTy FiniCB,
700  StringRef CriticalName, Value *HintInst);
701 
702  /// Generator for '#omp sections'
703  ///
704  /// \param Loc The insert and source location description.
705  /// \param AllocaIP The insertion points to be used for alloca instructions.
706  /// \param SectionCBs Callbacks that will generate body of each section.
707  /// \param PrivCB Callback to copy a given variable (think copy constructor).
708  /// \param FiniCB Callback to finalize variable copies.
709  /// \param IsCancellable Flag to indicate a cancellable parallel region.
710  /// \param IsNowait If true, barrier - to ensure all sections are executed
711  /// before moving forward will not be generated.
712  /// \returns The insertion position *after* the sections.
714  InsertPointTy AllocaIP,
716  PrivatizeCallbackTy PrivCB,
717  FinalizeCallbackTy FiniCB, bool IsCancellable,
718  bool IsNowait);
719 
720  /// Generator for '#omp section'
721  ///
722  /// \param Loc The insert and source location description.
723  /// \param BodyGenCB Callback that will generate the region body code.
724  /// \param FiniCB Callback to finalize variable copies.
725  /// \returns The insertion position *after* the section.
727  BodyGenCallbackTy BodyGenCB,
728  FinalizeCallbackTy FiniCB);
729 
730  /// Generate conditional branch and relevant BasicBlocks through which private
731  /// threads copy the 'copyin' variables from Master copy to threadprivate
732  /// copies.
733  ///
734  /// \param IP insertion block for copyin conditional
735  /// \param MasterVarPtr a pointer to the master variable
736  /// \param PrivateVarPtr a pointer to the threadprivate variable
737  /// \param IntPtrTy Pointer size type
738  /// \param BranchtoEnd Create a branch between the copyin.not.master blocks
739  // and copy.in.end block
740  ///
741  /// \returns The insertion point where copying operation to be emitted.
743  Value *PrivateAddr,
744  llvm::IntegerType *IntPtrTy,
745  bool BranchtoEnd = true);
746 
747  /// Create a runtime call for kmpc_Alloc
748  ///
749  /// \param Loc The insert and source location description.
750  /// \param Size Size of allocated memory space
751  /// \param Allocator Allocator information instruction
752  /// \param Name Name of call Instruction for OMP_alloc
753  ///
754  /// \returns CallInst to the OMP_Alloc call
756  Value *Allocator, std::string Name = "");
757 
758  /// Create a runtime call for kmpc_free
759  ///
760  /// \param Loc The insert and source location description.
761  /// \param Addr Address of memory space to be freed
762  /// \param Allocator Allocator information instruction
763  /// \param Name Name of call Instruction for OMP_Free
764  ///
765  /// \returns CallInst to the OMP_Free call
767  Value *Allocator, std::string Name = "");
768 
769  /// Create a runtime call for kmpc_threadprivate_cached
770  ///
771  /// \param Loc The insert and source location description.
772  /// \param Pointer pointer to data to be cached
773  /// \param Size size of data to be cached
774  /// \param Name Name of call Instruction for callinst
775  ///
776  /// \returns CallInst to the thread private cache call.
778  llvm::Value *Pointer,
780  const llvm::Twine &Name = Twine(""));
781 
782  /// Declarations for LLVM-IR types (simple, array, function and structure) are
783  /// generated below. Their names are defined and used in OpenMPKinds.def. Here
784  /// we provide the declarations, the initializeTypes function will provide the
785  /// values.
786  ///
787  ///{
788 #define OMP_TYPE(VarName, InitValue) Type *VarName = nullptr;
789 #define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) \
790  ArrayType *VarName##Ty = nullptr; \
791  PointerType *VarName##PtrTy = nullptr;
792 #define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) \
793  FunctionType *VarName = nullptr; \
794  PointerType *VarName##Ptr = nullptr;
795 #define OMP_STRUCT_TYPE(VarName, StrName, ...) \
796  StructType *VarName = nullptr; \
797  PointerType *VarName##Ptr = nullptr;
798 #include "llvm/Frontend/OpenMP/OMPKinds.def"
799 
800  ///}
801 
802 private:
803  /// Create all simple and struct types exposed by the runtime and remember
804  /// the llvm::PointerTypes of them for easy access later.
805  void initializeTypes(Module &M);
806 
807  /// Common interface for generating entry calls for OMP Directives.
808  /// if the directive has a region/body, It will set the insertion
809  /// point to the body
810  ///
811  /// \param OMPD Directive to generate entry blocks for
812  /// \param EntryCall Call to the entry OMP Runtime Function
813  /// \param ExitBB block where the region ends.
814  /// \param Conditional indicate if the entry call result will be used
815  /// to evaluate a conditional of whether a thread will execute
816  /// body code or not.
817  ///
818  /// \return The insertion position in exit block
819  InsertPointTy emitCommonDirectiveEntry(omp::Directive OMPD, Value *EntryCall,
820  BasicBlock *ExitBB,
821  bool Conditional = false);
822 
823  /// Common interface to finalize the region
824  ///
825  /// \param OMPD Directive to generate exiting code for
826  /// \param FinIP Insertion point for emitting Finalization code and exit call
827  /// \param ExitCall Call to the ending OMP Runtime Function
828  /// \param HasFinalize indicate if the directive will require finalization
829  /// and has a finalization callback in the stack that
830  /// should be called.
831  ///
832  /// \return The insertion position in exit block
833  InsertPointTy emitCommonDirectiveExit(omp::Directive OMPD,
834  InsertPointTy FinIP,
835  Instruction *ExitCall,
836  bool HasFinalize = true);
837 
838  /// Common Interface to generate OMP inlined regions
839  ///
840  /// \param OMPD Directive to generate inlined region for
841  /// \param EntryCall Call to the entry OMP Runtime Function
842  /// \param ExitCall Call to the ending OMP Runtime Function
843  /// \param BodyGenCB Body code generation callback.
844  /// \param FiniCB Finalization Callback. Will be called when finalizing region
845  /// \param Conditional indicate if the entry call result will be used
846  /// to evaluate a conditional of whether a thread will execute
847  /// body code or not.
848  /// \param HasFinalize indicate if the directive will require finalization
849  /// and has a finalization callback in the stack that
850  /// should be called.
851  /// \param IsCancellable if HasFinalize is set to true, indicate if the
852  /// the directive should be cancellable.
853  /// \return The insertion point after the region
854 
856  EmitOMPInlinedRegion(omp::Directive OMPD, Instruction *EntryCall,
857  Instruction *ExitCall, BodyGenCallbackTy BodyGenCB,
858  FinalizeCallbackTy FiniCB, bool Conditional = false,
859  bool HasFinalize = true, bool IsCancellable = false);
860 
861  /// Get the platform-specific name separator.
862  /// \param Parts different parts of the final name that needs separation
863  /// \param FirstSeparator First separator used between the initial two
864  /// parts of the name.
865  /// \param Separator separator used between all of the rest consecutive
866  /// parts of the name
867  static std::string getNameWithSeparators(ArrayRef<StringRef> Parts,
868  StringRef FirstSeparator,
869  StringRef Separator);
870 
871  /// Gets (if variable with the given name already exist) or creates
872  /// internal global variable with the specified Name. The created variable has
873  /// linkage CommonLinkage by default and is initialized by null value.
874  /// \param Ty Type of the global variable. If it is exist already the type
875  /// must be the same.
876  /// \param Name Name of the variable.
877  Constant *getOrCreateOMPInternalVariable(Type *Ty, const Twine &Name,
878  unsigned AddressSpace = 0);
879 
880  /// Returns corresponding lock object for the specified critical region
881  /// name. If the lock object does not exist it is created, otherwise the
882  /// reference to the existing copy is returned.
883  /// \param CriticalName Name of the critical region.
884  ///
885  Value *getOMPCriticalRegionLock(StringRef CriticalName);
886 
887  /// Callback type for Atomic Expression update
888  /// ex:
889  /// \code{.cpp}
890  /// unsigned x = 0;
891  /// #pragma omp atomic update
892  /// x = Expr(x_old); //Expr() is any legal operation
893  /// \endcode
894  ///
895  /// \param XOld the value of the atomic memory address to use for update
896  /// \param IRB reference to the IRBuilder to use
897  ///
898  /// \returns Value to update X to.
899  using AtomicUpdateCallbackTy =
900  const function_ref<Value *(Value *XOld, IRBuilder<> &IRB)>;
901 
902 private:
903  enum AtomicKind { Read, Write, Update, Capture };
904 
905  /// Determine whether to emit flush or not
906  ///
907  /// \param Loc The insert and source location description.
908  /// \param AO The required atomic ordering
909  /// \param AK The OpenMP atomic operation kind used.
910  ///
911  /// \returns wether a flush was emitted or not
912  bool checkAndEmitFlushAfterAtomic(const LocationDescription &Loc,
913  AtomicOrdering AO, AtomicKind AK);
914 
915  /// Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X
916  /// For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X)
917  /// Only Scalar data types.
918  ///
919  /// \param AllocIP Instruction to create AllocaInst before.
920  /// \param X The target atomic pointer to be updated
921  /// \param Expr The value to update X with.
922  /// \param AO Atomic ordering of the generated atomic
923  /// instructions.
924  /// \param RMWOp The binary operation used for update. If
925  /// operation is not supported by atomicRMW,
926  /// or belong to {FADD, FSUB, BAD_BINOP}.
927  /// Then a `cmpExch` based atomic will be generated.
928  /// \param UpdateOp Code generator for complex expressions that cannot be
929  /// expressed through atomicrmw instruction.
930  /// \param VolatileX true if \a X volatile?
931  /// \param IsXLHSInRHSPart true if \a X is Left H.S. in Right H.S. part of
932  /// the update expression, false otherwise.
933  /// (e.g. true for X = X BinOp Expr)
934  ///
935  /// \returns A pair of the old value of X before the update, and the value
936  /// used for the update.
937  std::pair<Value *, Value *> emitAtomicUpdate(Instruction *AllocIP, Value *X,
938  Value *Expr, AtomicOrdering AO,
939  AtomicRMWInst::BinOp RMWOp,
940  AtomicUpdateCallbackTy &UpdateOp,
941  bool VolatileX,
942  bool IsXLHSInRHSPart);
943 
944  /// Emit the binary op. described by \p RMWOp, using \p Src1 and \p Src2 .
945  ///
946  /// \Return The instruction
947  Value *emitRMWOpAsInstruction(Value *Src1, Value *Src2,
948  AtomicRMWInst::BinOp RMWOp);
949 
950 public:
951  /// a struct to pack relevant information while generating atomic Ops
952  struct AtomicOpValue {
953  Value *Var = nullptr;
954  bool IsSigned = false;
955  bool IsVolatile = false;
956  };
957 
958  /// Emit atomic Read for : V = X --- Only Scalar data types.
959  ///
960  /// \param Loc The insert and source location description.
961  /// \param X The target pointer to be atomically read
962  /// \param V Memory address where to store atomically read
963  /// value
964  /// \param AO Atomic ordering of the generated atomic
965  /// instructions.
966  ///
967  /// \return Insertion point after generated atomic read IR.
970  AtomicOrdering AO);
971 
972  /// Emit atomic write for : X = Expr --- Only Scalar data types.
973  ///
974  /// \param Loc The insert and source location description.
975  /// \param X The target pointer to be atomically written to
976  /// \param Expr The value to store.
977  /// \param AO Atomic ordering of the generated atomic
978  /// instructions.
979  ///
980  /// \return Insertion point after generated atomic Write IR.
982  AtomicOpValue &X, Value *Expr,
983  AtomicOrdering AO);
984 
985  /// Emit atomic update for constructs: X = X BinOp Expr ,or X = Expr BinOp X
986  /// For complex Operations: X = UpdateOp(X) => CmpExch X, old_X, UpdateOp(X)
987  /// Only Scalar data types.
988  ///
989  /// \param Loc The insert and source location description.
990  /// \param AllocIP Instruction to create AllocaInst before.
991  /// \param X The target atomic pointer to be updated
992  /// \param Expr The value to update X with.
993  /// \param AO Atomic ordering of the generated atomic instructions.
994  /// \param RMWOp The binary operation used for update. If operation
995  /// is not supported by atomicRMW, or belong to
996  /// {FADD, FSUB, BAD_BINOP}. Then a `cmpExch` based
997  /// atomic will be generated.
998  /// \param UpdateOp Code generator for complex expressions that cannot be
999  /// expressed through atomicrmw instruction.
1000  /// \param IsXLHSInRHSPart true if \a X is Left H.S. in Right H.S. part of
1001  /// the update expression, false otherwise.
1002  /// (e.g. true for X = X BinOp Expr)
1003  ///
1004  /// \return Insertion point after generated atomic update IR.
1006  Instruction *AllocIP, AtomicOpValue &X,
1007  Value *Expr, AtomicOrdering AO,
1008  AtomicRMWInst::BinOp RMWOp,
1009  AtomicUpdateCallbackTy &UpdateOp,
1010  bool IsXLHSInRHSPart);
1011 
1012  /// Emit atomic update for constructs: --- Only Scalar data types
1013  /// V = X; X = X BinOp Expr ,
1014  /// X = X BinOp Expr; V = X,
1015  /// V = X; X = Expr BinOp X,
1016  /// X = Expr BinOp X; V = X,
1017  /// V = X; X = UpdateOp(X),
1018  /// X = UpdateOp(X); V = X,
1019  ///
1020  /// \param Loc The insert and source location description.
1021  /// \param AllocIP Instruction to create AllocaInst before.
1022  /// \param X The target atomic pointer to be updated
1023  /// \param V Memory address where to store captured value
1024  /// \param Expr The value to update X with.
1025  /// \param AO Atomic ordering of the generated atomic instructions
1026  /// \param RMWOp The binary operation used for update. If
1027  /// operation is not supported by atomicRMW, or belong to
1028  /// {FADD, FSUB, BAD_BINOP}. Then a cmpExch based
1029  /// atomic will be generated.
1030  /// \param UpdateOp Code generator for complex expressions that cannot be
1031  /// expressed through atomicrmw instruction.
1032  /// \param UpdateExpr true if X is an in place update of the form
1033  /// X = X BinOp Expr or X = Expr BinOp X
1034  /// \param IsXLHSInRHSPart true if X is Left H.S. in Right H.S. part of the
1035  /// update expression, false otherwise.
1036  /// (e.g. true for X = X BinOp Expr)
1037  /// \param IsPostfixUpdate true if original value of 'x' must be stored in
1038  /// 'v', not an updated one.
1039  ///
1040  /// \return Insertion point after generated atomic capture IR.
1043  AtomicOpValue &X, AtomicOpValue &V, Value *Expr,
1045  AtomicUpdateCallbackTy &UpdateOp, bool UpdateExpr,
1046  bool IsPostfixUpdate, bool IsXLHSInRHSPart);
1047 
1048  /// Create the control flow structure of a canonical OpenMP loop.
1049  ///
1050  /// The emitted loop will be disconnected, i.e. no edge to the loop's
1051  /// preheader and no terminator in the AfterBB. The OpenMPIRBuilder's
1052  /// IRBuilder location is not preserved.
1053  ///
1054  /// \param DL DebugLoc used for the instructions in the skeleton.
1055  /// \param TripCount Value to be used for the trip count.
1056  /// \param F Function in which to insert the BasicBlocks.
1057  /// \param PreInsertBefore Where to insert BBs that execute before the body,
1058  /// typically the body itself.
1059  /// \param PostInsertBefore Where to insert BBs that execute after the body.
1060  /// \param Name Base name used to derive BB
1061  /// and instruction names.
1062  ///
1063  /// \returns The CanonicalLoopInfo that represents the emitted loop.
1065  Function *F,
1066  BasicBlock *PreInsertBefore,
1067  BasicBlock *PostInsertBefore,
1068  const Twine &Name = {});
1069 };
1070 
1071 /// Class to represented the control flow structure of an OpenMP canonical loop.
1072 ///
1073 /// The control-flow structure is standardized for easy consumption by
1074 /// directives associated with loops. For instance, the worksharing-loop
1075 /// construct may change this control flow such that each loop iteration is
1076 /// executed on only one thread.
1077 ///
1078 /// The control flow can be described as follows:
1079 ///
1080 /// Preheader
1081 /// |
1082 /// /-> Header
1083 /// | |
1084 /// | Cond---\
1085 /// | | |
1086 /// | Body |
1087 /// | | | |
1088 /// | <...> |
1089 /// | | | |
1090 /// \--Latch |
1091 /// |
1092 /// Exit
1093 /// |
1094 /// After
1095 ///
1096 /// Code in the header, condition block, latch and exit block must not have any
1097 /// side-effect. The body block is the single entry point into the loop body,
1098 /// which may contain arbitrary control flow as long as all control paths
1099 /// eventually branch to the latch block.
1100 ///
1101 /// Defined outside OpenMPIRBuilder because one cannot forward-declare nested
1102 /// classes.
1104  friend class OpenMPIRBuilder;
1105 
1106 private:
1107  /// Whether this object currently represents a loop.
1108  bool IsValid = false;
1109 
1110  BasicBlock *Preheader;
1111  BasicBlock *Header;
1112  BasicBlock *Cond;
1113  BasicBlock *Body;
1114  BasicBlock *Latch;
1115  BasicBlock *Exit;
1116  BasicBlock *After;
1117 
1118  /// Add the control blocks of this loop to \p BBs.
1119  ///
1120  /// This does not include any block from the body, including the one returned
1121  /// by getBody().
1122  void collectControlBlocks(SmallVectorImpl<BasicBlock *> &BBs);
1123 
1124 public:
1125  /// The preheader ensures that there is only a single edge entering the loop.
1126  /// Code that must be execute before any loop iteration can be emitted here,
1127  /// such as computing the loop trip count and begin lifetime markers. Code in
1128  /// the preheader is not considered part of the canonical loop.
1129  BasicBlock *getPreheader() const { return Preheader; }
1130 
1131  /// The header is the entry for each iteration. In the canonical control flow,
1132  /// it only contains the PHINode for the induction variable.
1133  BasicBlock *getHeader() const { return Header; }
1134 
1135  /// The condition block computes whether there is another loop iteration. If
1136  /// yes, branches to the body; otherwise to the exit block.
1137  BasicBlock *getCond() const { return Cond; }
1138 
1139  /// The body block is the single entry for a loop iteration and not controlled
1140  /// by CanonicalLoopInfo. It can contain arbitrary control flow but must
1141  /// eventually branch to the \p Latch block.
1142  BasicBlock *getBody() const { return Body; }
1143 
1144  /// Reaching the latch indicates the end of the loop body code. In the
1145  /// canonical control flow, it only contains the increment of the induction
1146  /// variable.
1147  BasicBlock *getLatch() const { return Latch; }
1148 
1149  /// Reaching the exit indicates no more iterations are being executed.
1150  BasicBlock *getExit() const { return Exit; }
1151 
1152  /// The after block is intended for clean-up code such as lifetime end
1153  /// markers. It is separate from the exit block to ensure, analogous to the
1154  /// preheader, it having just a single entry edge and being free from PHI
1155  /// nodes should there be multiple loop exits (such as from break
1156  /// statements/cancellations).
1157  BasicBlock *getAfter() const { return After; }
1158 
1159  /// Returns the llvm::Value containing the number of loop iterations. It must
1160  /// be valid in the preheader and always interpreted as an unsigned integer of
1161  /// any bit-width.
1162  Value *getTripCount() const {
1163  Instruction *CmpI = &Cond->front();
1164  assert(isa<CmpInst>(CmpI) && "First inst must compare IV with TripCount");
1165  return CmpI->getOperand(1);
1166  }
1167 
1168  /// Returns the instruction representing the current logical induction
1169  /// variable. Always unsigned, always starting at 0 with an increment of one.
1171  Instruction *IndVarPHI = &Header->front();
1172  assert(isa<PHINode>(IndVarPHI) && "First inst must be the IV PHI");
1173  return IndVarPHI;
1174  }
1175 
1176  /// Return the type of the induction variable (and the trip count).
1177  Type *getIndVarType() const { return getIndVar()->getType(); }
1178 
1179  /// Return the insertion point for user code before the loop.
1181  return {Preheader, std::prev(Preheader->end())};
1182  };
1183 
1184  /// Return the insertion point for user code in the body.
1186  return {Body, Body->begin()};
1187  };
1188 
1189  /// Return the insertion point for user code after the loop.
1191  return {After, After->begin()};
1192  };
1193 
1194  Function *getFunction() const { return Header->getParent(); }
1195 
1196  /// Consistency self-check.
1197  void assertOK() const;
1198 };
1199 
1200 } // end namespace llvm
1201 
1202 #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:1180
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:2175
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:602
llvm
Definition: AllocatorList.h:23
llvm::OpenMPIRBuilder::createSection
InsertPointTy createSection(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB)
Generator for '#omp section'.
Definition: OMPIRBuilder.cpp:990
llvm::OpenMPIRBuilder::createCritical
InsertPointTy createCritical(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, StringRef CriticalName, Value *HintInst)
Generator for '#omp critical'.
Definition: OMPIRBuilder.cpp:1929
llvm::CanonicalLoopInfo::getAfter
BasicBlock * getAfter() const
The after block is intended for clean-up code such as lifetime end markers.
Definition: OMPIRBuilder.h:1157
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:1072
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:61
Loops
Hexagon Hardware Loops
Definition: HexagonHardwareLoops.cpp:372
llvm::AtomicRMWInst::BinOp
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:740
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1167
llvm::OpenMPIRBuilder::tileLoops
std::vector< CanonicalLoopInfo * > tileLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, ArrayRef< Value * > TileSizes)
Tile a loop nest.
Definition: OMPIRBuilder.cpp:1689
llvm::OpenMPIRBuilder::createWorkshareLoop
CanonicalLoopInfo * createWorkshareLoop(const LocationDescription &Loc, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier)
Modifies the canonical loop to be a workshare loop.
Definition: OMPIRBuilder.cpp:1358
llvm::OpenMPIRBuilder::getLanemaskType
Type * getLanemaskType()
Definition: OMPIRBuilder.cpp:263
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:2604
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::OpenMPIRBuilder::getOrCreateThreadID
Value * getOrCreateThreadID(Value *Ident)
Return the current thread ID.
Definition: OMPIRBuilder.cpp:328
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:46
llvm::OpenMPIRBuilder::AtomicOpValue
a struct to pack relevant information while generating atomic Ops
Definition: OMPIRBuilder.h:952
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:1190
llvm::OpenMPIRBuilder::LocationDescription::LocationDescription
LocationDescription(const IRBuilder< T, U > &IRB)
Definition: OMPIRBuilder.h:152
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:1194
llvm::OpenMPIRBuilder::AtomicOpValue::Var
Value * Var
Definition: OMPIRBuilder.h:953
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:2544
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:875
llvm::OpenMPIRBuilder::collapseLoops
CanonicalLoopInfo * collapseLoops(DebugLoc DL, ArrayRef< CanonicalLoopInfo * > Loops, InsertPointTy ComputeIP)
Collapse a loop nest into a single loop.
Definition: OMPIRBuilder.cpp:1568
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:1170
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::OpenMPIRBuilder::finalize
void finalize(Function *Fn=nullptr, bool AllowExtractorSinking=false)
Finalize the underlying module, e.g., by outlining regions.
Definition: OMPIRBuilder.cpp:141
Mappings
Inject TLI Mappings
Definition: InjectTLIMappings.cpp:172
llvm::OpenMPIRBuilder::createDynamicWorkshareLoop
InsertPointTy createDynamicWorkshareLoop(const LocationDescription &Loc, 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:1397
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:77
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:308
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:230
llvm::OpenMPIRBuilder::M
Module & M
The underlying LLVM-IR module.
Definition: OMPIRBuilder.h:586
llvm::CanonicalLoopInfo::assertOK
void assertOK() const
Consistency self-check.
Definition: OMPIRBuilder.cpp:2640
llvm::CanonicalLoopInfo::getCond
BasicBlock * getCond() const
The condition block computes whether there is another loop iteration.
Definition: OMPIRBuilder.h:1137
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:614
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:2161
llvm::BasicBlock::begin
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:296
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:335
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:2317
IP
Definition: NVPTXLowerArgs.cpp:166
llvm::OpenMPIRBuilder::getInsertionPoint
InsertPointTy getInsertionPoint()
}
Definition: OMPIRBuilder.h:492
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:226
llvm::IntegerType
Class to represent integer types.
Definition: DerivedTypes.h:40
llvm::OpenMPIRBuilder::IdentMap
DenseMap< std::pair< Constant *, uint64_t >, Value * > IdentMap
Map to remember existing ident_t*.
Definition: OMPIRBuilder.h:595
llvm::OpenMPIRBuilder::AtomicOpValue::IsSigned
bool IsSigned
Definition: OMPIRBuilder.h:954
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:1185
DebugLoc.h
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::emitTaskwaitImpl
void emitTaskwaitImpl(const LocationDescription &Loc)
Generate a taskwait runtime call.
Definition: OMPIRBuilder.cpp:857
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:2392
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:2145
llvm::OpenMPIRBuilder::addAttributes
void addAttributes(omp::RuntimeFunction FnID, Function &Fn)
Add attributes known for FnID to Fn.
Definition: OMPIRBuilder.cpp:41
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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:602
llvm::OpenMPIRBuilder::Builder
IRBuilder Builder
The LLVM-IR Builder used to create IR.
Definition: OMPIRBuilder.h:589
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:886
llvm::CanonicalLoopInfo::getPreheader
BasicBlock * getPreheader() const
The preheader ensures that there is only a single edge entering the loop.
Definition: OMPIRBuilder.h:1129
llvm::OpenMPIRBuilder::createOffloadMaptypes
GlobalVariable * createOffloadMaptypes(SmallVectorImpl< uint64_t > &Mappings, std::string VarName)
Create the global variable holding the offload mappings information.
Definition: OMPIRBuilder.cpp:2244
llvm::OpenMPIRBuilder::AtomicOpValue::IsVolatile
bool IsVolatile
Definition: OMPIRBuilder.h:955
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:892
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::OpenMPIRBuilder::OutlineInfo::getFunction
Function * getFunction() const
Return the function that contains the region to be outlined.
Definition: OMPIRBuilder.h:610
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:564
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:440
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:1144
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:479
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:64
llvm::OpenMPIRBuilder::LocationDescription::DL
DebugLoc DL
Definition: OMPIRBuilder.h:158
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr
Function * getOrCreateRuntimeFunctionPtr(omp::RuntimeFunction FnID)
Definition: OMPIRBuilder.cpp:132
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:1025
llvm::OpenMPIRBuilder::createFlush
void createFlush(const LocationDescription &Loc)
Generator for '#omp flush'.
Definition: OMPIRBuilder.cpp:851
llvm::OpenMPIRBuilder::OutlineInfo
Helper that contains information about regions we need to outline during finalization.
Definition: OMPIRBuilder.h:599
llvm::CanonicalLoopInfo
Class to represented the control flow structure of an OpenMP canonical loop.
Definition: OMPIRBuilder.h:1103
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:167
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:256
llvm::OpenMPIRBuilder::createOffloadMapnames
GlobalVariable * createOffloadMapnames(SmallVectorImpl< llvm::Constant * > &Names, std::string VarName)
Create the global variable holding the offload names information.
Definition: OMPIRBuilder.cpp:2579
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCB
PostOutlineCBTy PostOutlineCB
Definition: OMPIRBuilder.h:601
llvm::OpenMPIRBuilder::addOutlineInfo
void addOutlineInfo(OutlineInfo &&OI)
Add a new region that will be outlined later.
Definition: OMPIRBuilder.h:621
llvm::OpenMPIRBuilder::createMasked
InsertPointTy createMasked(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, Value *Filter)
Generator for '#omp masked'.
Definition: OMPIRBuilder.cpp:1049
llvm::OpenMPIRBuilder::updateToLocation
bool updateToLocation(const LocationDescription &Loc)
Update the internal location to Loc.
Definition: OMPIRBuilder.h:495
llvm::OpenMPIRBuilder::FinalizationStack
SmallVector< FinalizationInfo, 8 > FinalizationStack
The finalization stack made up of finalize callbacks currently in-flight, wrapped into FinalizationIn...
Definition: OMPIRBuilder.h:560
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:1150
llvm::OpenMPIRBuilder::createStaticWorkshareLoop
CanonicalLoopInfo * createStaticWorkshareLoop(const LocationDescription &Loc, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP, bool NeedsBarrier, Value *Chunk=nullptr)
Modifies the canonical loop to be a statically-scheduled workshare loop.
Definition: OMPIRBuilder.cpp:1273
llvm::OpenMPIRBuilder::LoopInfos
std::forward_list< CanonicalLoopInfo > LoopInfos
Collection of owned canonical loop objects that eventually need to be free'd.
Definition: OMPIRBuilder.h:618
llvm::OpenMPIRBuilder::createTaskwait
void createTaskwait(const LocationDescription &Loc)
Generator for '#omp taskwait'.
Definition: OMPIRBuilder.cpp:869
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
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:2359
llvm::OpenMPIRBuilder::createCancel
InsertPointTy createCancel(const LocationDescription &Loc, Value *IfCondition, omp::Directive CanceledDirective)
Generator for '#omp cancel'.
Definition: OMPIRBuilder.cpp:390
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::OpenMPIRBuilder::OutlineInfo::PostOutlineCBTy
std::function< void(Function &)> PostOutlineCBTy
Definition: OMPIRBuilder.h:600
llvm::CanonicalLoopInfo::getHeader
BasicBlock * getHeader() const
The header is the entry for each iteration.
Definition: OMPIRBuilder.h:1133
llvm::OpenMPIRBuilder::getOrCreateSrcLocStr
Constant * getOrCreateSrcLocStr(StringRef LocStr)
Return the (LLVM-IR) string describing the source location LocStr.
Definition: OMPIRBuilder.cpp:271
OMPConstants.h
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:139
llvm::CanonicalLoopInfo::getLatch
BasicBlock * getLatch() const
Reaching the latch indicates the end of the loop body code.
Definition: OMPIRBuilder.h:1147
llvm::OpenMPIRBuilder::FinalizationInfo
Definition: OMPIRBuilder.h:65
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
llvm::CanonicalLoopInfo::getIndVarType
Type * getIndVarType() const
Return the type of the induction variable (and the trip count).
Definition: OMPIRBuilder.h:1177
llvm::OpenMPIRBuilder::SrcLocStrMap
StringMap< Constant * > SrcLocStrMap
Map to remember source location strings.
Definition: OMPIRBuilder.h:592
llvm::OpenMPIRBuilder::emitBarrierImpl
InsertPointTy emitBarrierImpl(const LocationDescription &Loc, omp::Directive DK, bool ForceSimpleCall, bool CheckCancelFlag)
Generate a barrier runtime call.
Definition: OMPIRBuilder.cpp:343
llvm::OpenMPIRBuilder::InternalVars
StringMap< AssertingVH< Constant >, BumpPtrAllocator > InternalVars
An ordered map of auto-generated variables to their unique names.
Definition: OMPIRBuilder.h:628
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:164
llvm::SmallVectorImpl< BasicBlock * >
llvm::CanonicalLoopInfo::getTripCount
Value * getTripCount() const
Returns the llvm::Value containing the number of loop iterations.
Definition: OMPIRBuilder.h:1162
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:843
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1478
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:2613
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
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:1895
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:2095
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:1874
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:74
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:1142
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::OpenMPIRBuilder::LocationDescription::IP
InsertPointTy IP
Definition: OMPIRBuilder.h:157