LLVM  16.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 
11 namespace llvm {
12 namespace orc {
13 namespace shared {
14 
15 Expected<std::vector<WrapperFunctionCall>>
17  std::vector<WrapperFunctionCall> DeallocActions;
18  DeallocActions.reserve(numDeallocActions(AAs));
19 
20  for (auto &AA : AAs) {
21  if (AA.Finalize)
22  if (auto Err = AA.Finalize.runWithSPSRetErrorMerged())
23  return joinErrors(std::move(Err), runDeallocActions(DeallocActions));
24 
25  if (AA.Dealloc)
26  DeallocActions.push_back(std::move(AA.Dealloc));
27  }
28 
29  AAs.clear();
30  return DeallocActions;
31 }
32 
34  Error Err = Error::success();
35  while (!DAs.empty()) {
37  DAs = DAs.drop_back();
38  }
39  return Err;
40 }
41 
42 } // namespace shared
43 } // namespace orc
44 } // namespace llvm
llvm::ArrayRef::drop_back
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:209
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
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::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:173
llvm::orc::shared::runFinalizeActions
Expected< std::vector< WrapperFunctionCall > > runFinalizeActions(AllocActions &AAs)
Run finalize actions.
Definition: AllocationActions.cpp:16
llvm::orc::shared::WrapperFunctionCall::runWithSPSRetErrorMerged
Error runWithSPSRetErrorMerged() const
Run call and deserialize an SPSError result.
Definition: WrapperFunctionUtils.h:696
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::joinErrors
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Definition: Error.h:426
llvm::orc::shared::runDeallocActions
Error runDeallocActions(ArrayRef< WrapperFunctionCall > DAs)
Run deallocation actions.
Definition: AllocationActions.cpp:33
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
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
AllocationActions.h