aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/llvm/mod.rs
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2021-09-22 22:38:41 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2021-09-22 22:38:41 +0200
commit96006e40ce34dcae0cdd3a94b1b329c9ff633831 (patch)
treec27313c6773d11ded56d73c2b756478922117c1b /src/llvm/mod.rs
parentcd62c3f8ccce0d834c333edafe2a825126c2bef6 (diff)
downloadllvm-kaleidoscope-rs-96006e40ce34dcae0cdd3a94b1b329c9ff633831.tar.gz
llvm-kaleidoscope-rs-96006e40ce34dcae0cdd3a94b1b329c9ff633831.zip
add llvm shutdown to free allocated memory
Diffstat (limited to 'src/llvm/mod.rs')
-rw-r--r--src/llvm/mod.rs9
1 files changed, 8 insertions, 1 deletions
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();
+ };
+}