1
- use gccjit:: { Context , FunctionType , GlobalKind , ToRValue , Type } ;
1
+ use gccjit:: GlobalKind ;
2
2
#[ cfg( feature = "master" ) ]
3
- use gccjit:: { FnAttribute , VarAttribute } ;
4
- use rustc_ast:: expand:: allocator:: {
5
- AllocatorKind , NO_ALLOC_SHIM_IS_UNSTABLE , alloc_error_handler_name,
6
- } ;
7
- use rustc_middle:: bug;
3
+ use gccjit:: VarAttribute ;
4
+ use rustc_ast:: expand:: allocator:: NO_ALLOC_SHIM_IS_UNSTABLE ;
8
5
use rustc_middle:: ty:: TyCtxt ;
9
6
use rustc_session:: config:: OomStrategy ;
10
7
use rustc_symbol_mangling:: mangle_internal_symbol;
@@ -13,31 +10,10 @@ use crate::GccContext;
13
10
#[ cfg( feature = "master" ) ]
14
11
use crate :: base:: symbol_visibility_to_gcc;
15
12
16
- pub ( crate ) unsafe fn codegen (
17
- tcx : TyCtxt < ' _ > ,
18
- mods : & mut GccContext ,
19
- _module_name : & str ,
20
- alloc_error_handler_kind : AllocatorKind ,
21
- ) {
13
+ pub ( crate ) unsafe fn codegen ( tcx : TyCtxt < ' _ > , mods : & mut GccContext , _module_name : & str ) {
22
14
let context = & mods. context ;
23
- let usize = match tcx. sess . target . pointer_width {
24
- 16 => context. new_type :: < u16 > ( ) ,
25
- 32 => context. new_type :: < u32 > ( ) ,
26
- 64 => context. new_type :: < u64 > ( ) ,
27
- tws => bug ! ( "Unsupported target word size for int: {}" , tws) ,
28
- } ;
29
15
let i8 = context. new_type :: < i8 > ( ) ;
30
16
31
- // FIXME(bjorn3): Add noreturn attribute
32
- create_wrapper_function (
33
- tcx,
34
- context,
35
- & mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
36
- & mangle_internal_symbol ( tcx, alloc_error_handler_name ( alloc_error_handler_kind) ) ,
37
- & [ usize, usize] ,
38
- None ,
39
- ) ;
40
-
41
17
let name = mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ;
42
18
let global = context. new_global ( None , GlobalKind :: Exported , i8, name) ;
43
19
#[ cfg( feature = "master" ) ]
@@ -57,71 +33,3 @@ pub(crate) unsafe fn codegen(
57
33
let value = context. new_rvalue_from_int ( i8, 0 ) ;
58
34
global. global_set_initializer_rvalue ( value) ;
59
35
}
60
-
61
- fn create_wrapper_function (
62
- tcx : TyCtxt < ' _ > ,
63
- context : & Context < ' _ > ,
64
- from_name : & str ,
65
- to_name : & str ,
66
- types : & [ Type < ' _ > ] ,
67
- output : Option < Type < ' _ > > ,
68
- ) {
69
- let void = context. new_type :: < ( ) > ( ) ;
70
-
71
- let args: Vec < _ > = types
72
- . iter ( )
73
- . enumerate ( )
74
- . map ( |( index, typ) | context. new_parameter ( None , * typ, format ! ( "param{}" , index) ) )
75
- . collect ( ) ;
76
- let func = context. new_function (
77
- None ,
78
- FunctionType :: Exported ,
79
- output. unwrap_or ( void) ,
80
- & args,
81
- from_name,
82
- false ,
83
- ) ;
84
-
85
- #[ cfg( feature = "master" ) ]
86
- func. add_attribute ( FnAttribute :: Visibility ( symbol_visibility_to_gcc (
87
- tcx. sess . default_visibility ( ) ,
88
- ) ) ) ;
89
-
90
- if tcx. sess . must_emit_unwind_tables ( ) {
91
- // TODO(antoyo): emit unwind tables.
92
- }
93
-
94
- let args: Vec < _ > = types
95
- . iter ( )
96
- . enumerate ( )
97
- . map ( |( index, typ) | context. new_parameter ( None , * typ, format ! ( "param{}" , index) ) )
98
- . collect ( ) ;
99
- let callee = context. new_function (
100
- None ,
101
- FunctionType :: Extern ,
102
- output. unwrap_or ( void) ,
103
- & args,
104
- to_name,
105
- false ,
106
- ) ;
107
- #[ cfg( feature = "master" ) ]
108
- callee. add_attribute ( FnAttribute :: Visibility ( gccjit:: Visibility :: Hidden ) ) ;
109
-
110
- let block = func. new_block ( "entry" ) ;
111
-
112
- let args = args
113
- . iter ( )
114
- . enumerate ( )
115
- . map ( |( i, _) | func. get_param ( i as i32 ) . to_rvalue ( ) )
116
- . collect :: < Vec < _ > > ( ) ;
117
- let ret = context. new_call ( None , callee, & args) ;
118
- //llvm::LLVMSetTailCall(ret, True);
119
- if output. is_some ( ) {
120
- block. end_with_return ( None , ret) ;
121
- } else {
122
- block. end_with_void_return ( None ) ;
123
- }
124
-
125
- // TODO(@Commeownist): Check if we need to emit some extra debugging info in certain circumstances
126
- // as described in https://github.com/rust-lang/rust/commit/77a96ed5646f7c3ee8897693decc4626fe380643
127
- }
0 commit comments