[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / Shared / AllocationActions.cpp
blob91f2899449ef38d0aeb6849f1133af48db7bdeb6
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 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h"
11 namespace llvm {
12 namespace orc {
13 namespace shared {
15 Expected<std::vector<WrapperFunctionCall>>
16 runFinalizeActions(AllocActions &AAs) {
17 std::vector<WrapperFunctionCall> DeallocActions;
18 DeallocActions.reserve(numDeallocActions(AAs));
20 for (auto &AA : AAs) {
21 if (AA.Finalize)
22 if (auto Err = AA.Finalize.runWithSPSRetErrorMerged())
23 return joinErrors(std::move(Err), runDeallocActions(DeallocActions));
25 if (AA.Dealloc)
26 DeallocActions.push_back(std::move(AA.Dealloc));
29 AAs.clear();
30 return DeallocActions;
33 Error runDeallocActions(ArrayRef<WrapperFunctionCall> DAs) {
34 Error Err = Error::success();
35 while (!DAs.empty()) {
36 Err = joinErrors(std::move(Err), DAs.back().runWithSPSRetErrorMerged());
37 DAs = DAs.drop_back();
39 return Err;
42 } // namespace shared
43 } // namespace orc
44 } // namespace llvm