1*c0fdc748SLang Hames //===----- AllocationActions.gpp -- JITLink allocation support calls -----===// 2*c0fdc748SLang Hames // 3*c0fdc748SLang Hames // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*c0fdc748SLang Hames // See https://llvm.org/LICENSE.txt for license information. 5*c0fdc748SLang Hames // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*c0fdc748SLang Hames // 7*c0fdc748SLang Hames //===----------------------------------------------------------------------===// 8*c0fdc748SLang Hames 9*c0fdc748SLang Hames #include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h" 10*c0fdc748SLang Hames 11*c0fdc748SLang Hames namespace llvm { 12*c0fdc748SLang Hames namespace orc { 13*c0fdc748SLang Hames namespace shared { 14*c0fdc748SLang Hames 15*c0fdc748SLang Hames Expected<std::vector<WrapperFunctionCall>> runFinalizeActions(AllocActions & AAs)16*c0fdc748SLang HamesrunFinalizeActions(AllocActions &AAs) { 17*c0fdc748SLang Hames std::vector<WrapperFunctionCall> DeallocActions; 18*c0fdc748SLang Hames DeallocActions.reserve(numDeallocActions(AAs)); 19*c0fdc748SLang Hames 20*c0fdc748SLang Hames for (auto &AA : AAs) { 21*c0fdc748SLang Hames if (AA.Finalize) 22*c0fdc748SLang Hames if (auto Err = AA.Finalize.runWithSPSRetErrorMerged()) 23*c0fdc748SLang Hames return joinErrors(std::move(Err), runDeallocActions(DeallocActions)); 24*c0fdc748SLang Hames 25*c0fdc748SLang Hames if (AA.Dealloc) 26*c0fdc748SLang Hames DeallocActions.push_back(std::move(AA.Dealloc)); 27*c0fdc748SLang Hames } 28*c0fdc748SLang Hames 29*c0fdc748SLang Hames AAs.clear(); 30*c0fdc748SLang Hames return DeallocActions; 31*c0fdc748SLang Hames } 32*c0fdc748SLang Hames runDeallocActions(ArrayRef<WrapperFunctionCall> DAs)33*c0fdc748SLang HamesError runDeallocActions(ArrayRef<WrapperFunctionCall> DAs) { 34*c0fdc748SLang Hames Error Err = Error::success(); 35*c0fdc748SLang Hames while (!DAs.empty()) { 36*c0fdc748SLang Hames Err = joinErrors(std::move(Err), DAs.back().runWithSPSRetErrorMerged()); 37*c0fdc748SLang Hames DAs = DAs.drop_back(); 38*c0fdc748SLang Hames } 39*c0fdc748SLang Hames return Err; 40*c0fdc748SLang Hames } 41*c0fdc748SLang Hames 42*c0fdc748SLang Hames } // namespace shared 43*c0fdc748SLang Hames } // namespace orc 44*c0fdc748SLang Hames } // namespace llvm 45