[llvm] 4867382 - [ORC] Deallocate FinalizedAllocs on error paths in notifyEmitted.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 14:41:35 PST 2024
Author: Lang Hames
Date: 2024-03-07T14:41:30-08:00
New Revision: 48673825f47cbac9cd7c61299ca8d01579314ae0
URL: https://github.com/llvm/llvm-project/commit/48673825f47cbac9cd7c61299ca8d01579314ae0
DIFF: https://github.com/llvm/llvm-project/commit/48673825f47cbac9cd7c61299ca8d01579314ae0.diff
LOG: [ORC] Deallocate FinalizedAllocs on error paths in notifyEmitted.
If notifyEmitted encounters a failure (either because some plugin returned one,
or because the ResourceTracker was defunct) then we need to deallocate the
FinalizedAlloc manually.
No testcase yet: This requires a concurrent setup -- we'll need to build some
infrastructure to coordinate links and deliberately injected failures in order
to reliably test this.
Added:
Modified:
llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
index 6ac256dff9b436..131728fd7e7e4c 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
@@ -720,14 +720,22 @@ Error ObjectLinkingLayer::notifyEmitted(MaterializationResponsibility &MR,
for (auto &P : Plugins)
Err = joinErrors(std::move(Err), P->notifyEmitted(MR));
- if (Err)
+ if (Err) {
+ if (FA)
+ Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));
return Err;
+ }
if (!FA)
return Error::success();
- return MR.withResourceKeyDo(
+ Err = MR.withResourceKeyDo(
[&](ResourceKey K) { Allocs[K].push_back(std::move(FA)); });
+
+ if (Err)
+ Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));
+
+ return Err;
}
Error ObjectLinkingLayer::handleRemoveResources(JITDylib &JD, ResourceKey K) {
More information about the llvm-commits
mailing list