2
2
// Adapted from rustc
3
3
4
4
use cranelift_frontend:: { FunctionBuilder , FunctionBuilderContext } ;
5
- use rustc_ast:: expand:: allocator:: {
6
- AllocatorKind , NO_ALLOC_SHIM_IS_UNSTABLE , alloc_error_handler_name,
7
- } ;
5
+ use rustc_ast:: expand:: allocator:: NO_ALLOC_SHIM_IS_UNSTABLE ;
8
6
use rustc_codegen_ssa:: base:: needs_allocator_shim;
9
7
use rustc_session:: config:: OomStrategy ;
10
8
use rustc_symbol_mangling:: mangle_internal_symbol;
@@ -14,46 +12,15 @@ use crate::prelude::*;
14
12
/// Returns whether an allocator shim was created
15
13
pub ( crate ) fn codegen ( tcx : TyCtxt < ' _ > , module : & mut dyn Module ) -> bool {
16
14
if needs_allocator_shim ( tcx) {
17
- codegen_inner (
18
- tcx,
19
- module,
20
- tcx. alloc_error_handler_kind ( ( ) ) . unwrap ( ) ,
21
- tcx. sess . opts . unstable_opts . oom ,
22
- ) ;
15
+ codegen_inner ( tcx, module, tcx. sess . opts . unstable_opts . oom ) ;
23
16
true
24
17
} else {
25
18
false
26
19
}
27
20
}
28
21
29
- fn codegen_inner (
30
- tcx : TyCtxt < ' _ > ,
31
- module : & mut dyn Module ,
32
- alloc_error_handler_kind : AllocatorKind ,
33
- oom_strategy : OomStrategy ,
34
- ) {
35
- let usize_ty = module. target_config ( ) . pointer_type ( ) ;
36
-
37
- let sig = Signature {
38
- call_conv : module. target_config ( ) . default_call_conv ,
39
- params : vec ! [ AbiParam :: new( usize_ty) , AbiParam :: new( usize_ty) ] ,
40
- returns : vec ! [ ] ,
41
- } ;
42
- crate :: common:: create_wrapper_function (
43
- module,
44
- sig,
45
- & mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
46
- & mangle_internal_symbol ( tcx, alloc_error_handler_name ( alloc_error_handler_kind) ) ,
47
- ) ;
48
-
49
- let data_id = module
50
- . declare_data (
51
- & mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
52
- Linkage :: Export ,
53
- false ,
54
- false ,
55
- )
56
- . unwrap ( ) ;
22
+ fn codegen_inner ( tcx : TyCtxt < ' _ > , module : & mut dyn Module , oom_strategy : OomStrategy ) {
23
+ let data_id = module. declare_data ( OomStrategy :: SYMBOL , Linkage :: Export , false , false ) . unwrap ( ) ;
57
24
let mut data = DataDescription :: new ( ) ;
58
25
data. set_align ( 1 ) ;
59
26
let val = oom_strategy. should_panic ( ) ;
0 commit comments