AllocationActions.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h"
  9. namespace llvm {
  10. namespace orc {
  11. namespace shared {
  12. Expected<std::vector<WrapperFunctionCall>>
  13. runFinalizeActions(AllocActions &AAs) {
  14. std::vector<WrapperFunctionCall> DeallocActions;
  15. DeallocActions.reserve(numDeallocActions(AAs));
  16. for (auto &AA : AAs) {
  17. if (AA.Finalize)
  18. if (auto Err = AA.Finalize.runWithSPSRetErrorMerged())
  19. return joinErrors(std::move(Err), runDeallocActions(DeallocActions));
  20. if (AA.Dealloc)
  21. DeallocActions.push_back(std::move(AA.Dealloc));
  22. }
  23. AAs.clear();
  24. return DeallocActions;
  25. }
  26. Error runDeallocActions(ArrayRef<WrapperFunctionCall> DAs) {
  27. Error Err = Error::success();
  28. while (!DAs.empty()) {
  29. Err = joinErrors(std::move(Err), DAs.back().runWithSPSRetErrorMerged());
  30. DAs = DAs.drop_back();
  31. }
  32. return Err;
  33. }
  34. } // namespace shared
  35. } // namespace orc
  36. } // namespace llvm