44use std:: {
55 cell:: { Cell , RefCell } ,
66 path:: Path ,
7- rc :: Rc ,
7+ sync :: Arc ,
88} ;
99
1010use inkwell:: {
@@ -114,19 +114,19 @@ pub fn create_llvm_deps<'ctx>(
114114
115115#[ derive( Clone ) ]
116116pub struct LLVMBuilder < ' a , ' ctx > {
117- handle_table : Rc < RefCell < FxHashMap < ValueHandle , AnyValueEnum < ' ctx > > > > ,
118- handle_reverse_table : Rc < RefCell < FxHashMap < AnyValueEnum < ' ctx > , ValueHandle > > > ,
119- block_table : Rc < RefCell < FxHashMap < BlockHandle , BasicBlock < ' ctx > > > > ,
120- block_reverse_table : Rc < RefCell < FxHashMap < BasicBlock < ' ctx > , BlockHandle > > > ,
117+ handle_table : Arc < RefCell < FxHashMap < ValueHandle , AnyValueEnum < ' ctx > > > > ,
118+ handle_reverse_table : Arc < RefCell < FxHashMap < AnyValueEnum < ' ctx > , ValueHandle > > > ,
119+ block_table : Arc < RefCell < FxHashMap < BlockHandle , BasicBlock < ' ctx > > > > ,
120+ block_reverse_table : Arc < RefCell < FxHashMap < BasicBlock < ' ctx > , BlockHandle > > > ,
121121 context : & ' ctx Context , // llvm context
122122 builder : & ' a Builder < ' ctx > , // llvm builder
123123 module : & ' a Module < ' ctx > , // llvm module
124124 dibuilder : & ' a DebugInfoBuilder < ' ctx > , // debug info builder
125125 diunit : & ' a DICompileUnit < ' ctx > , // debug info unit
126126 targetmachine : & ' a TargetMachine , // might be used in debug info
127127 discope : Cell < DIScope < ' ctx > > , // debug info scope
128- ditypes_placeholder : Rc < RefCell < FxHashMap < String , RefCell < Vec < MemberType < ' ctx > > > > > > , // hold the generated debug info type place holder
129- ditypes : Rc < RefCell < FxHashMap < String , DIType < ' ctx > > > > , // hold the generated debug info type
128+ ditypes_placeholder : Arc < RefCell < FxHashMap < String , RefCell < Vec < MemberType < ' ctx > > > > > > , // hold the generated debug info type place holder
129+ ditypes : Arc < RefCell < FxHashMap < String , DIType < ' ctx > > > > , // hold the generated debug info type
130130}
131131
132132pub fn get_target_machine ( level : OptimizationLevel ) -> TargetMachine {
@@ -167,12 +167,12 @@ impl<'a, 'ctx> LLVMBuilder<'a, 'ctx> {
167167 diunit,
168168 targetmachine : tm,
169169 discope : Cell :: new ( diunit. get_file ( ) . as_debug_info_scope ( ) ) ,
170- ditypes : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
171- ditypes_placeholder : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
172- handle_table : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
173- handle_reverse_table : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
174- block_table : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
175- block_reverse_table : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
170+ ditypes : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
171+ ditypes_placeholder : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
172+ handle_table : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
173+ handle_reverse_table : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
174+ block_table : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
175+ block_reverse_table : Arc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
176176 }
177177 }
178178 fn get_llvm_value_handle ( & self , value : & AnyValueEnum < ' ctx > ) -> ValueHandle {
@@ -580,7 +580,7 @@ impl<'a, 'ctx> LLVMBuilder<'a, 'ctx> {
580580 fn get_or_add_global_value (
581581 & self ,
582582 name : & str ,
583- pltype : Rc < RefCell < PLType > > ,
583+ pltype : Arc < RefCell < PLType > > ,
584584 ctx : & mut Ctx < ' a > ,
585585 ) -> PointerValue < ' ctx > {
586586 let global = self . get_global_var_handle ( name) ;
@@ -776,7 +776,7 @@ impl<'a, 'ctx> IRBuilder<'a, 'ctx> for LLVMBuilder<'a, 'ctx> {
776776 fn get_or_add_global (
777777 & self ,
778778 name : & str ,
779- pltype : Rc < RefCell < PLType > > ,
779+ pltype : Arc < RefCell < PLType > > ,
780780 ctx : & mut Ctx < ' a > ,
781781 ) -> ValueHandle {
782782 self . get_llvm_value_handle (
@@ -796,9 +796,9 @@ impl<'a, 'ctx> IRBuilder<'a, 'ctx> for LLVMBuilder<'a, 'ctx> {
796796 & self ,
797797 range : Range ,
798798 v : ValueHandle ,
799- tp : Rc < RefCell < PLType > > ,
799+ tp : Arc < RefCell < PLType > > ,
800800 ctx : & mut Ctx < ' a > ,
801- ) -> Result < ( ValueHandle , Rc < RefCell < PLType > > ) , PLDiag > {
801+ ) -> Result < ( ValueHandle , Arc < RefCell < PLType > > ) , PLDiag > {
802802 let handle = v;
803803 let v = self . get_llvm_value ( handle) . unwrap ( ) ;
804804 if !v. is_pointer_value ( ) {
@@ -1335,7 +1335,7 @@ impl<'a, 'ctx> IRBuilder<'a, 'ctx> for LLVMBuilder<'a, 'ctx> {
13351335 fn add_global (
13361336 & self ,
13371337 name : & str ,
1338- pltype : Rc < RefCell < PLType > > ,
1338+ pltype : Arc < RefCell < PLType > > ,
13391339 ctx : & mut Ctx < ' a > ,
13401340 line : u32 ,
13411341 pltp : & PLType ,
0 commit comments