11use std:: cell:: { Cell , RefCell } ;
22
3- use gccjit:: { Block , CType , Context , Function , FunctionPtrType , FunctionType , LValue , RValue , Type , FnAttribute } ;
3+ use gccjit:: { Block , CType , Context , Function , FunctionPtrType , FunctionType , LValue , RValue , Type } ;
44use rustc_codegen_ssa:: base:: wants_msvc_seh;
55use rustc_codegen_ssa:: traits:: {
66 BackendTypes ,
@@ -259,8 +259,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
259259 pub fn rvalue_as_function ( & self , value : RValue < ' gcc > ) -> Function < ' gcc > {
260260 let function: Function < ' gcc > = unsafe { std:: mem:: transmute ( value) } ;
261261 // FIXME: seems like self.functions get overwritten for rust_eh_personality.
262- /* debug_assert!(self.functions.borrow().values().find(|value| **value == function).is_some(),
263- "{:?} is not a function", function);*/
262+ debug_assert ! ( self . functions. borrow( ) . values( ) . find( |value| * * value == function) . is_some( ) ,
263+ "{:?} is not a function" , function) ;
264264 function
265265 }
266266
@@ -332,7 +332,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
332332 }
333333
334334 fn get_fn ( & self , instance : Instance < ' tcx > ) -> RValue < ' gcc > {
335- let func = get_fn ( self , instance, false ) ;
335+ let func = get_fn ( self , instance) ;
336336 * self . current_func . borrow_mut ( ) = Some ( func) ;
337337 unsafe { std:: mem:: transmute ( func) }
338338 }
@@ -345,7 +345,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
345345 self . intrinsics . borrow ( ) [ func_name] . clone ( )
346346 }
347347 else {
348- get_fn ( self , instance, false )
348+ get_fn ( self , instance)
349349 } ;
350350 let ptr = func. get_address ( None ) ;
351351
@@ -386,8 +386,6 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
386386 let func =
387387 match tcx. lang_items ( ) . eh_personality ( ) {
388388 Some ( def_id) if !wants_msvc_seh ( self . sess ( ) ) => {
389- // FIXME: this create an instance into self.functions and prevent the creating
390- // of the function defined in std.
391389 let instance =
392390 ty:: Instance :: resolve (
393391 tcx,
@@ -400,45 +398,19 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
400398 let symbol_name = tcx. symbol_name ( instance) . name ;
401399 let fn_abi = self . fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
402400 self . linkage . set ( FunctionType :: Extern ) ;
403- let func = self . declare_fn ( symbol_name, & fn_abi, false ) ;
404- //func.add_attribute(FnAttribute::Weak);
405-
406- /*let block = func.new_block("eh_personality_block");
407- // NOTE: it seems this function is overwritten by the standard library, so just
408- // return a dummy value in this version.
409- let zero = self.context.new_rvalue_zero(self.type_u32());
410- block.end_with_return(None, zero);*/
411-
412- //*self.current_func.borrow_mut() = Some(func);
401+ let func = self . declare_fn ( symbol_name, & fn_abi) ;
413402 let func: RValue < ' gcc > = unsafe { std:: mem:: transmute ( func) } ;
414403 func
415- /*self.get_fn(
416- ty::Instance::resolve(
417- tcx,
418- ty::ParamEnv::reveal_all(),
419- def_id,
420- tcx.intern_substs(&[]),
421- )
422- .unwrap().unwrap(),
423- )*/
424404 } ,
425405 _ => {
426- let name = if wants_msvc_seh ( self . sess ( ) ) {
427- "__CxxFrameHandler3"
428- } else {
429- "rust_eh_personality"
430- } ;
406+ let name =
407+ if wants_msvc_seh ( self . sess ( ) ) {
408+ "__CxxFrameHandler3"
409+ }
410+ else {
411+ "rust_eh_personality"
412+ } ;
431413 let func = self . declare_func ( name, self . type_i32 ( ) , & [ ] , true ) ;
432- //*self.current_func.borrow_mut() = Some(func);
433- // NOTE: this function is created multiple times and is overwritten by the
434- // standard library, so mark it as weak.
435- //func.add_attribute(FnAttribute::Weak);
436- //self.functions.borrow_mut().insert(name.to_string(), func);
437- /*let block = func.new_block("eh_personality_block");
438- // NOTE: it seems this function is overwritten by the standard library, so just
439- // return a dummy value in this version.
440- let zero = self.context.new_rvalue_zero(self.type_i32());
441- block.end_with_return(None, zero);*/
442414 unsafe { std:: mem:: transmute ( func) }
443415 }
444416 } ;
0 commit comments