@@ -4,7 +4,6 @@ use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS
44use rustc_middle:: bug;
55use rustc_middle:: ty:: TyCtxt ;
66use rustc_session:: config:: { DebugInfo , OomStrategy } ;
7- use rustc_span:: symbol:: sym;
87
98use crate :: debuginfo;
109use crate :: llvm:: { self , False , True } ;
@@ -15,7 +14,6 @@ pub(crate) unsafe fn codegen(
1514 module_llvm : & mut ModuleLlvm ,
1615 module_name : & str ,
1716 kind : AllocatorKind ,
18- alloc_error_handler_kind : AllocatorKind ,
1917) {
2018 let llcx = & * module_llvm. llcx ;
2119 let llmod = module_llvm. llmod ( ) ;
@@ -100,52 +98,6 @@ pub(crate) unsafe fn codegen(
10098 llvm:: LLVMDisposeBuilder ( llbuilder) ;
10199 }
102100
103- // rust alloc error handler
104- let args = [ usize, usize] ; // size, align
105-
106- let ty = llvm:: LLVMFunctionType ( void, args. as_ptr ( ) , args. len ( ) as c_uint , False ) ;
107- let name = "__rust_alloc_error_handler" ;
108- let llfn = llvm:: LLVMRustGetOrInsertFunction ( llmod, name. as_ptr ( ) . cast ( ) , name. len ( ) , ty) ;
109- // -> ! DIFlagNoReturn
110- let no_return = llvm:: AttributeKind :: NoReturn . create_attr ( llcx) ;
111- attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Function , & [ no_return] ) ;
112-
113- if tcx. sess . target . default_hidden_visibility {
114- llvm:: LLVMRustSetVisibility ( llfn, llvm:: Visibility :: Hidden ) ;
115- }
116- if tcx. sess . must_emit_unwind_tables ( ) {
117- let uwtable = attributes:: uwtable_attr ( llcx) ;
118- attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Function , & [ uwtable] ) ;
119- }
120-
121- let callee = alloc_error_handler_kind. fn_name ( sym:: oom) ;
122- let callee = llvm:: LLVMRustGetOrInsertFunction ( llmod, callee. as_ptr ( ) . cast ( ) , callee. len ( ) , ty) ;
123- // -> ! DIFlagNoReturn
124- attributes:: apply_to_llfn ( callee, llvm:: AttributePlace :: Function , & [ no_return] ) ;
125- llvm:: LLVMRustSetVisibility ( callee, llvm:: Visibility :: Hidden ) ;
126-
127- let llbb = llvm:: LLVMAppendBasicBlockInContext ( llcx, llfn, "entry\0 " . as_ptr ( ) . cast ( ) ) ;
128-
129- let llbuilder = llvm:: LLVMCreateBuilderInContext ( llcx) ;
130- llvm:: LLVMPositionBuilderAtEnd ( llbuilder, llbb) ;
131- let args = args
132- . iter ( )
133- . enumerate ( )
134- . map ( |( i, _) | llvm:: LLVMGetParam ( llfn, i as c_uint ) )
135- . collect :: < Vec < _ > > ( ) ;
136- let ret = llvm:: LLVMRustBuildCall (
137- llbuilder,
138- ty,
139- callee,
140- args. as_ptr ( ) ,
141- args. len ( ) as c_uint ,
142- [ ] . as_ptr ( ) ,
143- 0 as c_uint ,
144- ) ;
145- llvm:: LLVMSetTailCall ( ret, True ) ;
146- llvm:: LLVMBuildRetVoid ( llbuilder) ;
147- llvm:: LLVMDisposeBuilder ( llbuilder) ;
148-
149101 // __rust_alloc_error_handler_should_panic
150102 let name = OomStrategy :: SYMBOL ;
151103 let ll_g = llvm:: LLVMRustGetOrInsertGlobal ( llmod, name. as_ptr ( ) . cast ( ) , name. len ( ) , i8) ;
0 commit comments