Skip to content

Commit

Permalink
[ORC] Fix a memory leak in LLVMOrcIRTransformLayerSetTransform.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lhames committed Aug 5, 2022
1 parent 4246269 commit bc062e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down

0 comments on commit bc062e0

Please sign in to comment.