From 96006e40ce34dcae0cdd3a94b1b329c9ff633831 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Wed, 22 Sep 2021 22:38:41 +0200 Subject: add llvm shutdown to free allocated memory --- src/llvm/mod.rs | 9 ++++++++- src/main.rs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/llvm/mod.rs b/src/llvm/mod.rs index f3e54a8..01ed3f2 100644 --- a/src/llvm/mod.rs +++ b/src/llvm/mod.rs @@ -8,7 +8,7 @@ //! For the scope of this tutorial we mainly use assertions to validate the results from the LLVM //! API calls. -use llvm_sys::prelude::LLVMBasicBlockRef; +use llvm_sys::{core::LLVMShutdown, prelude::LLVMBasicBlockRef}; use std::marker::PhantomData; @@ -27,3 +27,10 @@ pub use value::{FnValue, Value}; /// Wrapper for a LLVM Basic Block. #[derive(Copy, Clone)] pub struct BasicBlock<'llvm>(LLVMBasicBlockRef, PhantomData<&'llvm ()>); + +/// Deallocate and destroy all "ManagedStatic" variables. +pub fn shutdown() { + unsafe { + LLVMShutdown(); + }; +} diff --git a/src/main.rs b/src/main.rs index 7160e04..be3dede 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,4 +98,6 @@ fn main() { // Dump all the emitted LLVM IR to stdout. module.dump(); + + llvm::shutdown(); } -- cgit v1.2.3