[llvm] bc062e0 - [ORC] Fix a memory leak in LLVMOrcIRTransformLayerSetTransform.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 13:52:12 PDT 2022
Author: Lang Hames
Date: 2022-08-05T13:52:03-07:00
New Revision: bc062e034fbdb5674fc26d354ef5b4c236aab640
URL: https://github.com/llvm/llvm-project/commit/bc062e034fbdb5674fc26d354ef5b4c236aab640
DIFF: https://github.com/llvm/llvm-project/commit/bc062e034fbdb5674fc26d354ef5b4c236aab640.diff
LOG: [ORC] Fix a memory leak in LLVMOrcIRTransformLayerSetTransform.
This function heap-allocates a ThreadSafeModule (the current C bindings assume
that TSMs are always heap-allocated), but was failing to free it.
Should fix http://llvm.org/PR56953.
Added:
Modified:
llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
index b7eab6b85ecf7..6575bf3e89235 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
@@ -892,7 +892,10 @@ void LLVMOrcIRTransformLayerSetTransform(
assert(!TSMRef && "TSMRef was not reset to null on error");
return unwrap(Err);
}
- return std::move(*unwrap(TSMRef));
+ assert(TSMRef && "Transform succeeded, but TSMRef was set to null");
+ ThreadSafeModule Result = std::move(*unwrap(TSMRef));
+ LLVMOrcDisposeThreadSafeModule(TSMRef);
+ return std::move(Result);
});
}
More information about the llvm-commits
mailing list