Update module to be held by Rc<RefCell<>> so that we can pass it to LLVMFunctionCodeGenerator.

Use that to generate distinct TBAA labels for distinct local variables.
This commit is contained in:
Nick Lewycky
2019-10-30 13:11:29 -07:00
parent f77d9bfe32
commit e7d1742c63
2 changed files with 59 additions and 20 deletions

View File

@ -9,12 +9,14 @@ use inkwell::{
use libc::c_char;
use std::{
any::Any,
cell::RefCell,
ffi::{c_void, CString},
fs::File,
io::Write,
mem,
ops::Deref,
ptr::{self, NonNull},
rc::Rc,
slice, str,
sync::{Arc, Once},
};
@ -167,14 +169,14 @@ pub struct LLVMBackend {
impl LLVMBackend {
pub fn new(
module: Module,
module: Rc<RefCell<Module>>,
_intrinsics: Intrinsics,
_stackmaps: &StackmapRegistry,
_module_info: &ModuleInfo,
target_machine: &TargetMachine,
) -> (Self, LLVMCache) {
let memory_buffer = target_machine
.write_to_memory_buffer(&module, FileType::Object)
.write_to_memory_buffer(&module.borrow_mut(), FileType::Object)
.unwrap();
let mem_buf_slice = memory_buffer.as_slice();