Unverified Commit b5c75514 authored by Sergio Afonso's avatar Sergio Afonso Committed by GitHub
Browse files

[OMPIRBuilder] Add support for explicit deallocation points (#154752)

In this patch, some OMPIRBuilder codegen functions and callbacks are
updated to work with arrays of deallocation insertion points. The
purpose of this is to enable the replacement of `alloca`s with other
types of allocations that require explicit deallocations in a way that
makes it possible for `CodeExtractor` instances created during
OMPIRBuilder finalization to also use them.

The OpenMP to LLVM IR MLIR translation pass is updated to properly store
and forward deallocation points together with their matching allocation
point to the OMPIRBuilder.

Currently, only the `DeviceSharedMemCodeExtractor` uses this feature to
get the `CodeExtractor` to use device shared memory for intermediate
allocations when outlining a parallel region inside of a Generic kernel
(code path that is only used by Flang via MLIR, currently). However,
long term this might also be useful to refactor finalization of
variables with destructors, potentially reducing the use of callbacks
and simplifying privatization and reductions.

Instead of a single deallocation point, lists of those are used. This is
to cover cases where there are multiple exit blocks originating from a
single entry. If an allocation needing explicit deallocation is placed
in the entry block of such cases, it would need to be deallocated before
each of the exits.
parent 333f636c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -11680,8 +11680,8 @@ void CGOpenMPRuntime::emitTargetDataCalls(
  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
  llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
      cantFail(OMPBuilder.createTargetData(
          OmpLoc, AllocaIP, CodeGenIP, DeviceID, IfCondVal, Info, GenMapInfoCB,
          CustomMapperCB,
          OmpLoc, AllocaIP, CodeGenIP, /*DeallocBlocks=*/{}, DeviceID,
          IfCondVal, Info, GenMapInfoCB, CustomMapperCB,
          /*MapperFunc=*/nullptr, BodyCB, DeviceAddrCB, RTLoc));
  CGF.Builder.restoreIP(AfterIP);
}
+43 −34
Original line number Diff line number Diff line
@@ -2122,10 +2122,10 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
    const CapturedStmt *CS = S.getCapturedStmt(OMPD_parallel);
    const Stmt *ParallelRegionBodyStmt = CS->getCapturedStmt();

    auto BodyGenCB = [&, this](InsertPointTy AllocaIP,
                               InsertPointTy CodeGenIP) {
    auto BodyGenCB = [&, this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                               ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      OMPBuilderCBHelpers::EmitOMPOutlinedRegionBody(
          *this, ParallelRegionBodyStmt, AllocaIP, CodeGenIP, "parallel");
          *this, ParallelRegionBodyStmt, AllocIP, CodeGenIP, "parallel");
      return llvm::Error::success();
    };

@@ -2133,8 +2133,9 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
    CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
    llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
        AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
    llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(
        OMPBuilder.createParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
    llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
        cantFail(OMPBuilder.createParallel(
            Builder, AllocaIP, /*DeallocBlocks=*/{}, BodyGenCB, PrivCB, FiniCB,
            IfCond, NumThreads, ProcBind, S.hasCancel()));
    Builder.restoreIP(AfterIP);
    return;
@@ -4669,19 +4670,21 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
    llvm::SmallVector<BodyGenCallbackTy, 4> SectionCBVector;
    if (CS) {
      for (const Stmt *SubStmt : CS->children()) {
        auto SectionCB = [this, SubStmt](InsertPointTy AllocaIP,
                                         InsertPointTy CodeGenIP) {
          OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
              *this, SubStmt, AllocaIP, CodeGenIP, "section");
        auto SectionCB = [this, SubStmt](
                             InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                             ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
          OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(*this, SubStmt, AllocIP,
                                                        CodeGenIP, "section");
          return llvm::Error::success();
        };
        SectionCBVector.push_back(SectionCB);
      }
    } else {
      auto SectionCB = [this, CapturedStmt](InsertPointTy AllocaIP,
                                            InsertPointTy CodeGenIP) {
      auto SectionCB =
          [this, CapturedStmt](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                               ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
            OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
            *this, CapturedStmt, AllocaIP, CodeGenIP, "section");
                *this, CapturedStmt, AllocIP, CodeGenIP, "section");
            return llvm::Error::success();
          };
      SectionCBVector.push_back(SectionCB);
@@ -4737,10 +4740,11 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &S) {
      return llvm::Error::success();
    };

    auto BodyGenCB = [SectionRegionBodyStmt, this](InsertPointTy AllocaIP,
                                                   InsertPointTy CodeGenIP) {
    auto BodyGenCB = [SectionRegionBodyStmt,
                      this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                            ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
          *this, SectionRegionBodyStmt, AllocaIP, CodeGenIP, "section");
          *this, SectionRegionBodyStmt, AllocIP, CodeGenIP, "section");
      return llvm::Error::success();
    };

@@ -4822,10 +4826,11 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
      return llvm::Error::success();
    };

    auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
                                                  InsertPointTy CodeGenIP) {
    auto BodyGenCB = [MasterRegionBodyStmt,
                      this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                            ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
          *this, MasterRegionBodyStmt, AllocaIP, CodeGenIP, "master");
          *this, MasterRegionBodyStmt, AllocIP, CodeGenIP, "master");
      return llvm::Error::success();
    };

@@ -4872,10 +4877,11 @@ void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) {
      return llvm::Error::success();
    };

    auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP,
                                                  InsertPointTy CodeGenIP) {
    auto BodyGenCB = [MaskedRegionBodyStmt,
                      this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                            ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
          *this, MaskedRegionBodyStmt, AllocaIP, CodeGenIP, "masked");
          *this, MaskedRegionBodyStmt, AllocIP, CodeGenIP, "masked");
      return llvm::Error::success();
    };

@@ -4915,10 +4921,11 @@ void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
      return llvm::Error::success();
    };

    auto BodyGenCB = [CriticalRegionBodyStmt, this](InsertPointTy AllocaIP,
                                                    InsertPointTy CodeGenIP) {
    auto BodyGenCB = [CriticalRegionBodyStmt,
                      this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                            ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
          *this, CriticalRegionBodyStmt, AllocaIP, CodeGenIP, "critical");
          *this, CriticalRegionBodyStmt, AllocIP, CodeGenIP, "critical");
      return llvm::Error::success();
    };

@@ -5885,8 +5892,8 @@ void CodeGenFunction::EmitOMPTaskgroupDirective(
    InsertPointTy AllocaIP(AllocaInsertPt->getParent(),
                           AllocaInsertPt->getIterator());

    auto BodyGenCB = [&, this](InsertPointTy AllocaIP,
                               InsertPointTy CodeGenIP) {
    auto BodyGenCB = [&, this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                               ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
      Builder.restoreIP(CodeGenIP);
      EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
      return llvm::Error::success();
@@ -5895,7 +5902,8 @@ void CodeGenFunction::EmitOMPTaskgroupDirective(
    if (!CapturedStmtInfo)
      CapturedStmtInfo = &CapStmtInfo;
    llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
        cantFail(OMPBuilder.createTaskgroup(Builder, AllocaIP, BodyGenCB));
        cantFail(OMPBuilder.createTaskgroup(Builder, AllocaIP,
                                            /*DeallocBlocks=*/{}, BodyGenCB));
    Builder.restoreIP(AfterIP);
    return;
  }
@@ -6475,8 +6483,9 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) {
        return llvm::Error::success();
      };

      auto BodyGenCB = [&S, C, this](InsertPointTy AllocaIP,
                                     InsertPointTy CodeGenIP) {
      auto BodyGenCB = [&S, C,
                        this](InsertPointTy AllocIP, InsertPointTy CodeGenIP,
                              ArrayRef<llvm::BasicBlock *> DeallocBlocks) {
        Builder.restoreIP(CodeGenIP);

        const CapturedStmt *CS = S.getInnermostCapturedStmt();
@@ -6493,7 +6502,7 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) {
                                               OutlinedFn, CapturedVars);
        } else {
          OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(
              *this, CS->getCapturedStmt(), AllocaIP, CodeGenIP, "ordered");
              *this, CS->getCapturedStmt(), AllocIP, CodeGenIP, "ordered");
        }
        return llvm::Error::success();
      };
+54 −32
Original line number Diff line number Diff line
@@ -641,15 +641,17 @@ public:
  ///
  /// AllocaIP and CodeGenIP must not point to the same position.
  ///
  /// \param AllocaIP is the insertion point at which new alloca instructions
  ///                 should be placed. The BasicBlock it is pointing to must
  ///                 not be split.
  /// \param AllocaIP   is the insertion point at which new allocations should
  ///                   be placed. The BasicBlock it is pointing to must not be
  ///                   split.
  /// \param CodeGenIP  is the insertion point at which the body code should be
  ///                   placed.
  ///
  /// \param DeallocBlocks is the list of insertion blocks where explicit
  ///                      deallocations, if needed, should be placed.
  /// \return an error, if any were triggered during execution.
  using BodyGenCallbackTy =
      function_ref<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
      function_ref<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
                         ArrayRef<BasicBlock *> DeallocBlocks)>;

  /// Callback type for task duplication function code generation. This is the
  /// task duplication function passed to __kmpc_taskloop. It is expected that
@@ -690,7 +692,8 @@ public:
  ///
  /// \return an error, if any were triggered during execution.
  using StorableBodyGenCallbackTy =
      std::function<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
      std::function<Error(InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
                          ArrayRef<BasicBlock *> DeallocBlocks)>;

  /// Callback type for loop body code generation.
  ///
@@ -784,7 +787,9 @@ public:
  /// Generator for '#omp parallel'
  ///
  /// \param Loc The insert and source location description.
  /// \param AllocaIP The insertion points to be used for alloca instructions.
  /// \param AllocaIP The insertion point to be used for allocations.
  /// \param DeallocBlocks The insertion blocks to be used for explicit
  /// deallocations, if needed.
  /// \param BodyGenCB Callback that will generate the region code.
  /// \param PrivCB Callback to copy a given variable (think copy constructor).
  /// \param FiniCB Callback to finalize variable copies.
@@ -796,9 +801,9 @@ public:
  /// \returns The insertion position *after* the parallel.
  LLVM_ABI InsertPointOrErrorTy createParallel(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB,
      FinalizeCallbackTy FiniCB, Value *IfCondition, Value *NumThreads,
      omp::ProcBindKind ProcBind, bool IsCancellable);
      ArrayRef<BasicBlock *> DeallocBlocks, BodyGenCallbackTy BodyGenCB,
      PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, Value *IfCondition,
      Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable);

  /// Generator for the control flow structure of an OpenMP canonical loop.
  ///
@@ -1548,6 +1553,8 @@ public:
  ///
  /// \param Loc The location where the taskloop construct was encountered.
  /// \param AllocaIP The insertion point to be used for alloca instructions.
  /// \param DeallocBlocks The list of insertion blocks where explicit
  ///                      deallocations, if needed, should be placed.
  /// \param BodyGenCB Callback that will generate the region code.
  /// \param LoopInfo Callback that return the CLI
  /// \param LBVal Lowerbound value of loop
@@ -1579,7 +1586,7 @@ public:
  ///                                bound, step} values in the task data.
  LLVM_ABI InsertPointOrErrorTy createTaskloop(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      BodyGenCallbackTy BodyGenCB,
      ArrayRef<BasicBlock *> DeallocBlocks, BodyGenCallbackTy BodyGenCB,
      llvm::function_ref<llvm::Expected<llvm::CanonicalLoopInfo *>()> LoopInfo,
      Value *LBVal, Value *UBVal, Value *StepVal, bool Untied = false,
      Value *IfCond = nullptr, Value *GrainSize = nullptr, bool NoGroup = false,
@@ -1591,7 +1598,9 @@ public:
  /// Generator for `#omp task`
  ///
  /// \param Loc The location where the task construct was encountered.
  /// \param AllocaIP The insertion point to be used for alloca instructions.
  /// \param AllocaIP The insertion point to be used for allocations.
  /// \param DeallocBlocks The insertion blocks to be used for explicit
  ///                      deallocations, if needed.
  /// \param BodyGenCB Callback that will generate the region code.
  /// \param Tied True if the task is tied, false if the task is untied.
  /// \param Final i1 value which is `true` if the task is final, `false` if the
@@ -1613,19 +1622,22 @@ public:
  ///                 tasks that is generated by the construct
  LLVM_ABI InsertPointOrErrorTy createTask(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      BodyGenCallbackTy BodyGenCB, bool Tied = true, Value *Final = nullptr,
      Value *IfCondition = nullptr, const DependenciesInfo &Dependencies = {},
      ArrayRef<BasicBlock *> DeallocBlocks, BodyGenCallbackTy BodyGenCB,
      bool Tied = true, Value *Final = nullptr, Value *IfCondition = nullptr,
      const DependenciesInfo &Dependencies = {},
      const AffinityData &Affinities = {}, bool Mergeable = false,
      Value *EventHandle = nullptr, Value *Priority = nullptr);

  /// Generator for the taskgroup construct
  ///
  /// \param Loc The location where the taskgroup construct was encountered.
  /// \param AllocaIP The insertion point to be used for alloca instructions.
  /// \param AllocaIP The insertion point to be used for allocations.
  /// \param DeallocBlocks The insertion blocks to be used for explicit
  ///                      deallocation instructions, if needed.
  /// \param BodyGenCB Callback that will generate the region code.
  LLVM_ABI InsertPointOrErrorTy createTaskgroup(const LocationDescription &Loc,
                                                InsertPointTy AllocaIP,
                                                BodyGenCallbackTy BodyGenCB);
  LLVM_ABI InsertPointOrErrorTy createTaskgroup(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      ArrayRef<BasicBlock *> DeallocBlocks, BodyGenCallbackTy BodyGenCB);

  using FileIdentifierInfoCallbackTy =
      std::function<std::tuple<std::string, uint64_t>()>;
@@ -2551,7 +2563,8 @@ public:
  struct OutlineInfo {
    using PostOutlineCBTy = std::function<void(Function &)>;
    PostOutlineCBTy PostOutlineCB;
    BasicBlock *EntryBB, *ExitBB, *OuterAllocaBB;
    BasicBlock *EntryBB, *ExitBB, *OuterAllocBB;
    SmallVector<BasicBlock *> OuterDeallocBBs;
    SmallVector<Value *, 2> ExcludeArgsFromAggregate;
    SetVector<Value *> Inputs, Outputs;
    // TODO: this should be safe to enable by default
@@ -2627,7 +2640,8 @@ public:
  /// \return an error, if any were triggered during execution.
  LLVM_ABI Error emitIfClause(Value *Cond, BodyGenCallbackTy ThenGen,
                              BodyGenCallbackTy ElseGen,
                              InsertPointTy AllocaIP = {});
                              InsertPointTy AllocaIP = {},
                              ArrayRef<BasicBlock *> DeallocBlocks = {});

  /// Create the global variable holding the offload mappings information.
  LLVM_ABI GlobalVariable *
@@ -3190,11 +3204,13 @@ public:
  /// Generator for `#omp distribute`
  ///
  /// \param Loc The location where the distribute construct was encountered.
  /// \param AllocaIP The insertion points to be used for alloca instructions.
  /// \param AllocaIP The insertion point to be used for allocations.
  /// \param DeallocBlocks The insertion blocks to be used for explicit
  ///        deallocations, if needed.
  /// \param BodyGenCB Callback that will generate the region code.
  LLVM_ABI InsertPointOrErrorTy createDistribute(const LocationDescription &Loc,
                                                 InsertPointTy AllocaIP,
                                                 BodyGenCallbackTy BodyGenCB);
  LLVM_ABI InsertPointOrErrorTy createDistribute(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      ArrayRef<BasicBlock *> DeallocBlocks, BodyGenCallbackTy BodyGenCB);

  /// Generate conditional branch and relevant BasicBlocks through which private
  /// threads copy the 'copyin' variables from Master copy to threadprivate
@@ -3536,9 +3552,11 @@ public:
  /// Generator for '#omp target data'
  ///
  /// \param Loc The location where the target data construct was encountered.
  /// \param AllocaIP The insertion points to be used for alloca instructions.
  /// \param AllocaIP The insertion points to be used for allocations.
  /// \param CodeGenIP The insertion point at which the target directive code
  /// should be placed.
  /// \param DeallocBlocks The insertion blocks at which explicit deallocations
  /// should be placed, if needed.
  /// \param IsBegin If true then emits begin mapper call otherwise emits
  /// end mapper call.
  /// \param DeviceID Stores the DeviceID from the device clause.
@@ -3552,9 +3570,9 @@ public:
  /// use_device_ptr and use_device_addr.
  LLVM_ABI InsertPointOrErrorTy createTargetData(
      const LocationDescription &Loc, InsertPointTy AllocaIP,
      InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
      TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
      CustomMapperCallbackTy CustomMapperCB,
      InsertPointTy CodeGenIP, ArrayRef<BasicBlock *> DeallocBlocks,
      Value *DeviceID, Value *IfCond, TargetDataInfo &Info,
      GenMapInfoCallbackTy GenMapInfoCB, CustomMapperCallbackTy CustomMapperCB,
      omp::RuntimeFunction *MapperFunc = nullptr,
      function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
                                        BodyGenTy BodyGenType)>
@@ -3563,7 +3581,8 @@ public:
      Value *SrcLocInfo = nullptr);

  using TargetBodyGenCallbackTy = function_ref<InsertPointOrErrorTy(
      InsertPointTy AllocaIP, InsertPointTy CodeGenIP)>;
      InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
      ArrayRef<BasicBlock *> DeallocBlocks)>;

  using TargetGenArgAccessorsCallbackTy = function_ref<InsertPointOrErrorTy(
      Argument &Arg, Value *Input, Value *&RetVal, InsertPointTy AllocaIP,
@@ -3575,6 +3594,8 @@ public:
  /// \param IsOffloadEntry whether it is an offload entry.
  /// \param CodeGenIP The insertion point where the call to the outlined
  ///        function should be emitted.
  /// \param DeallocBlocks The insertion points at which explicit deallocations
  ///        should be placed, if needed.
  /// \param Info Stores all information realted to the Target directive.
  /// \param EntryInfo The entry information about the function.
  /// \param DefaultAttrs Structure containing the default attributes, including
@@ -3600,7 +3621,8 @@ public:
  LLVM_ABI InsertPointOrErrorTy createTarget(
      const LocationDescription &Loc, bool IsOffloadEntry,
      OpenMPIRBuilder::InsertPointTy AllocaIP,
      OpenMPIRBuilder::InsertPointTy CodeGenIP, TargetDataInfo &Info,
      OpenMPIRBuilder::InsertPointTy CodeGenIP,
      ArrayRef<BasicBlock *> DeallocBlocks, TargetDataInfo &Info,
      TargetRegionEntryInfo &EntryInfo,
      const TargetKernelDefaultAttrs &DefaultAttrs,
      const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
+13 −13
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/Compiler.h"
#include <limits>

@@ -100,13 +101,13 @@ class LLVM_ABI CodeExtractor {
  /// entry block of the function.
  BasicBlock *AllocationBlock;

  /// A block outside of the extraction set where deallocations for intermediate
  /// allocations can be placed inside. Not used for automatically deallocated
  /// memory (e.g. `alloca`), which is the default.
  /// A set of blocks outside of the extraction set where deallocations for
  /// intermediate allocations should be placed. Not used for automatically
  /// deallocated memory (e.g. `alloca`), which is the default.
  ///
  /// If it is null and needed, the end of the replacement basic block will be
  /// If it is empty and needed, the end of the replacement basic block will be
  /// used to place deallocations.
  BasicBlock *DeallocationBlock;
  SmallVector<BasicBlock *> DeallocationBlocks;

  /// If true, varargs functions can be extracted.
  bool AllowVarArgs;
@@ -162,9 +163,9 @@ public:
  /// allocations will be placed in the AllocationBlock, unless it is null, in
  /// which case it will be placed in the entry block of the function from which
  /// the code is being extracted. Explicit deallocations for the aforementioned
  /// allocations will be placed in the DeallocationBlock or the end of the
  /// replacement block, if needed. If ArgsInZeroAddressSpace param is set to
  /// true, then the aggregate param pointer of the outlined function is
  /// allocations will be placed, if needed, in all blocks in DeallocationBlocks
  /// or the end of the replacement block. If ArgsInZeroAddressSpace param is
  /// set to true, then the aggregate param pointer of the outlined function is
  /// declared in zero address space. If VoidReturnWithSingleOutput is set to
  /// true, then the return type of the outlined function is set void even if
  /// there is only one output.
@@ -173,7 +174,7 @@ public:
                BranchProbabilityInfo *BPI = nullptr,
                AssumptionCache *AC = nullptr, bool AllowVarArgs = false,
                bool AllowAlloca = false, BasicBlock *AllocationBlock = nullptr,
                BasicBlock *DeallocationBlock = nullptr,
                ArrayRef<BasicBlock *> DeallocationBlocks = {},
                std::string Suffix = "", bool ArgsInZeroAddressSpace = false,
                bool VoidReturnWithSingleOutput = true);

@@ -260,15 +261,14 @@ public:

protected:
  /// Allocate an intermediate variable at the specified point.
  virtual Instruction *allocateVar(BasicBlock *BB, BasicBlock::iterator AllocIP,
  virtual Instruction *allocateVar(IRBuilder<>::InsertPoint AllocaIP,
                                   Type *VarType, const Twine &Name = Twine(""),
                                   AddrSpaceCastInst **CastedAlloc = nullptr);

  /// Deallocate a previously-allocated intermediate variable at the specified
  /// point.
  virtual Instruction *deallocateVar(BasicBlock *BB,
                                     BasicBlock::iterator DeallocIP, Value *Var,
                                     Type *VarType);
  virtual Instruction *deallocateVar(IRBuilder<>::InsertPoint DeallocIP,
                                     Value *Var, Type *VarType);

private:
  struct LifetimeMarkerInfo {
+163 −187

File changed.

Preview size limit exceeded, changes collapsed.

Loading