File tree Expand file tree Collapse file tree 1 file changed +28
-13
lines changed Expand file tree Collapse file tree 1 file changed +28
-13
lines changed Original file line number Diff line number Diff line change @@ -84,19 +84,34 @@ fn codegen_inner(
84
84
& mangle_internal_symbol ( tcx, alloc_error_handler_name ( alloc_error_handler_kind) ) ,
85
85
) ;
86
86
87
- let data_id = module
88
- . declare_data (
89
- & mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
90
- Linkage :: Export ,
91
- false ,
92
- false ,
93
- )
94
- . unwrap ( ) ;
95
- let mut data = DataDescription :: new ( ) ;
96
- data. set_align ( 1 ) ;
97
- let val = oom_strategy. should_panic ( ) ;
98
- data. define ( Box :: new ( [ val] ) ) ;
99
- module. define_data ( data_id, & data) . unwrap ( ) ;
87
+ {
88
+ let sig = Signature {
89
+ call_conv : module. target_config ( ) . default_call_conv ,
90
+ params : vec ! [ ] ,
91
+ returns : vec ! [ AbiParam :: new( types:: I8 ) ] ,
92
+ } ;
93
+ let func_id = module
94
+ . declare_function (
95
+ & mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
96
+ Linkage :: Export ,
97
+ & sig,
98
+ )
99
+ . unwrap ( ) ;
100
+ let mut ctx = Context :: new ( ) ;
101
+ ctx. func . signature = sig;
102
+ {
103
+ let mut func_ctx = FunctionBuilderContext :: new ( ) ;
104
+ let mut bcx = FunctionBuilder :: new ( & mut ctx. func , & mut func_ctx) ;
105
+
106
+ let block = bcx. create_block ( ) ;
107
+ bcx. switch_to_block ( block) ;
108
+ let value = bcx. ins ( ) . iconst ( types:: I8 , oom_strategy. should_panic ( ) as i64 ) ;
109
+ bcx. ins ( ) . return_ ( & [ value] ) ;
110
+ bcx. seal_all_blocks ( ) ;
111
+ bcx. finalize ( ) ;
112
+ }
113
+ module. define_function ( func_id, & mut ctx) . unwrap ( ) ;
114
+ }
100
115
101
116
{
102
117
let sig = Signature {
You can’t perform that action at this time.
0 commit comments