LLVM  16.0.0git
AllocationActions.h
Go to the documentation of this file.
1 //===- AllocationActions.h -- JITLink allocation support calls -*- 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 // Structures for making memory allocation support calls.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H
14 #define LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H
15 
18 #include "llvm/Support/Memory.h"
19 
20 #include <vector>
21 
22 namespace llvm {
23 namespace orc {
24 namespace shared {
25 
26 /// A pair of WrapperFunctionCalls, one to be run at finalization time, one to
27 /// be run at deallocation time.
28 ///
29 /// AllocActionCallPairs should be constructed for paired operations (e.g.
30 /// __register_ehframe and __deregister_ehframe for eh-frame registration).
31 /// See comments for AllocActions for execution ordering.
32 ///
33 /// For unpaired operations one or the other member can be left unused, as
34 /// AllocationActionCalls with an FnAddr of zero will be skipped.
38 };
39 
40 /// A vector of allocation actions to be run for this allocation.
41 ///
42 /// Finalize allocations will be run in order at finalize time. Dealloc
43 /// actions will be run in reverse order at deallocation time.
44 using AllocActions = std::vector<AllocActionCallPair>;
45 
46 /// Returns the number of deallocaton actions in the given AllocActions array.
47 ///
48 /// This can be useful if clients want to pre-allocate room for deallocation
49 /// actions with the rest of their memory.
50 inline size_t numDeallocActions(const AllocActions &AAs) {
51  return llvm::count_if(
52  AAs, [](const AllocActionCallPair &P) { return !!P.Dealloc; });
53 }
54 
55 /// Run finalize actions.
56 ///
57 /// If any finalize action fails then the corresponding dealloc actions will be
58 /// run in reverse order (not including the deallocation action for the failed
59 /// finalize action), and the error for the failing action will be returned.
60 ///
61 /// If all finalize actions succeed then a vector of deallocation actions will
62 /// be returned. The dealloc actions should be run by calling
63 /// runDeallocationActions. If this function succeeds then the AA argument will
64 /// be cleared before the function returns.
67 
68 /// Run deallocation actions.
69 /// Dealloc actions will be run in reverse order (from last element of DAs to
70 /// first).
72 
75 
76 template <>
80 
81 public:
82  static size_t size(const AllocActionCallPair &AAP) {
83  return AL::size(AAP.Finalize, AAP.Dealloc);
84  }
85 
87  const AllocActionCallPair &AAP) {
88  return AL::serialize(OB, AAP.Finalize, AAP.Dealloc);
89  }
90 
92  AllocActionCallPair &AAP) {
93  return AL::deserialize(IB, AAP.Finalize, AAP.Dealloc);
94  }
95 };
96 
97 } // end namespace shared
98 } // end namespace orc
99 } // end namespace llvm
100 
101 #endif // LLVM_EXECUTIONENGINE_ORC_SHARED_ALLOCATIONACTIONS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::orc::shared::SPSSerializationTraits
Specialize to describe how to serialize/deserialize to/from the given concrete type.
Definition: SimplePackedSerialization.h:105
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::orc::shared::SPSOutputBuffer
Output char buffer with overflow check.
Definition: SimplePackedSerialization.h:54
llvm::orc::shared::SPSSerializationTraits< SPSAllocActionCallPair, AllocActionCallPair >::size
static size_t size(const AllocActionCallPair &AAP)
Definition: AllocationActions.h:82
WrapperFunctionUtils.h
llvm::orc::shared::numDeallocActions
size_t numDeallocActions(const AllocActions &AAs)
Returns the number of deallocaton actions in the given AllocActions array.
Definition: AllocationActions.h:50
llvm::orc::shared::SPSInputBuffer
Input char buffer with underflow check.
Definition: SimplePackedSerialization.h:74
llvm::orc::shared::AllocActionCallPair::Dealloc
WrapperFunctionCall Dealloc
Definition: AllocationActions.h:37
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:195
llvm::count_if
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
Definition: STLExtras.h:1877
llvm::orc::shared::SPSSerializationTraits< SPSAllocActionCallPair, AllocActionCallPair >::deserialize
static bool deserialize(SPSInputBuffer &IB, AllocActionCallPair &AAP)
Definition: AllocationActions.h:91
llvm::orc::shared::SPSAllocActionCallPair
SPSTuple< SPSWrapperFunctionCall, SPSWrapperFunctionCall > SPSAllocActionCallPair
Definition: AllocationActions.h:74
llvm::orc::shared::runFinalizeActions
Expected< std::vector< WrapperFunctionCall > > runFinalizeActions(AllocActions &AAs)
Run finalize actions.
Definition: AllocationActions.cpp:16
llvm::orc::shared::AllocActionCallPair::Finalize
WrapperFunctionCall Finalize
Definition: AllocationActions.h:36
llvm::AArch64PACKey::IB
@ IB
Definition: AArch64BaseInfo.h:820
size
i< reg-> size
Definition: README.txt:166
llvm::orc::shared::runDeallocActions
Error runDeallocActions(ArrayRef< WrapperFunctionCall > DAs)
Run deallocation actions.
Definition: AllocationActions.cpp:33
llvm::orc::shared::WrapperFunctionCall
Represents a serialized wrapper function call.
Definition: WrapperFunctionUtils.h:628
llvm::orc::shared::AllocActionCallPair
A pair of WrapperFunctionCalls, one to be run at finalization time, one to be run at deallocation tim...
Definition: AllocationActions.h:35
llvm::X86II::OB
@ OB
Definition: X86BaseInfo.h:806
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::orc::shared::AllocActions
std::vector< AllocActionCallPair > AllocActions
A vector of allocation actions to be run for this allocation.
Definition: AllocationActions.h:44
Memory.h
llvm::orc::shared::SPSTuple::AsArgList
SPSArgList< SPSTagTs... > AsArgList
Convenience typedef of the corresponding arg list.
Definition: SimplePackedSerialization.h:198
ExecutorAddress.h
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::orc::shared::SPSSerializationTraits< SPSAllocActionCallPair, AllocActionCallPair >::serialize
static bool serialize(SPSOutputBuffer &OB, const AllocActionCallPair &AAP)
Definition: AllocationActions.h:86
llvm::orc::shared::SPSArgList
A utility class for serializing to a blob from a variadic list.
Definition: SimplePackedSerialization.h:108