LLVM 22.0.0git
AllocationActions.cpp
Go to the documentation of this file.
1//===----- AllocationActions.gpp -- JITLink allocation support calls -----===//
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
10
11namespace llvm {
12namespace orc {
13namespace shared {
14
17 std::vector<WrapperFunctionCall> DeallocActions;
18 DeallocActions.reserve(numDeallocActions(AAs));
19
20 for (auto &AA : AAs) {
21 if (AA.Finalize)
22
23 if (auto Err = AA.Finalize.runWithSPSRetErrorMerged()) {
24 while (!DeallocActions.empty()) {
25 Err = joinErrors(std::move(Err),
26 DeallocActions.back().runWithSPSRetErrorMerged());
27 DeallocActions.pop_back();
28 }
29 return OnComplete(std::move(Err));
30 }
31
32 if (AA.Dealloc)
33 DeallocActions.push_back(std::move(AA.Dealloc));
34 }
35
36 AAs.clear();
37 OnComplete(std::move(DeallocActions));
38}
39
42 Error Err = Error::success();
43 while (!DAs.empty()) {
44 Err = joinErrors(std::move(Err), DAs.back().runWithSPSRetErrorMerged());
45 DAs = DAs.drop_back();
46 }
47 OnComplete(std::move(Err));
48}
49
50} // namespace shared
51} // namespace orc
52} // namespace llvm
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:156
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:206
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:142
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
unique_function is a type-erasing functor similar to std::function.
size_t numDeallocActions(const AllocActions &AAs)
Returns the number of deallocaton actions in the given AllocActions array.
LLVM_ABI void runDeallocActions(ArrayRef< WrapperFunctionCall > DAs, OnRunDeallocActionsComeleteFn OnComplete)
Run deallocation actions.
LLVM_ABI void runFinalizeActions(AllocActions &AAs, OnRunFinalizeActionsCompleteFn OnComplete)
Run finalize actions.
std::vector< AllocActionCallPair > AllocActions
A vector of allocation actions to be run for this allocation.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Definition: Error.h:442