@@ -8,10 +8,12 @@ use rustc_middle::bug;
88use rustc_middle:: ty:: TyCtxt ;
99use rustc_session:: config:: { DebugInfo , OomStrategy } ;
1010use rustc_symbol_mangling:: mangle_internal_symbol;
11+ use smallvec:: SmallVec ;
1112
1213use crate :: builder:: SBuilder ;
1314use crate :: declare:: declare_simple_fn;
1415use crate :: llvm:: { self , False , True , Type , Value } ;
16+ use crate :: llvm_util;
1517use crate :: { SimpleCx , attributes, debuginfo} ;
1618
1719pub ( crate ) unsafe fn codegen (
@@ -147,6 +149,20 @@ fn create_wrapper_function(
147149 llvm:: Visibility :: from_generic ( tcx. sess . default_visibility ( ) ) ,
148150 ty,
149151 ) ;
152+
153+ let mut attrs = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
154+
155+ let target_cpu = llvm_util:: target_cpu ( tcx. sess ) ;
156+ let target_cpu_attr = llvm:: CreateAttrStringValue ( cx. llcx , "target-cpu" , target_cpu) ;
157+
158+ let tune_cpu_attr = llvm_util:: tune_cpu ( tcx. sess )
159+ . map ( |tune_cpu| llvm:: CreateAttrStringValue ( cx. llcx , "tune-cpu" , tune_cpu) ) ;
160+
161+ attrs. push ( target_cpu_attr) ;
162+ attrs. extend ( tune_cpu_attr) ;
163+
164+ attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Function , & attrs) ;
165+
150166 let no_return = if no_return {
151167 // -> ! DIFlagNoReturn
152168 let no_return = llvm:: AttributeKind :: NoReturn . create_attr ( cx. llcx ) ;
0 commit comments