@@ -8,11 +8,12 @@ use rustc_middle::bug;
8
8
use rustc_middle:: ty:: TyCtxt ;
9
9
use rustc_session:: config:: { DebugInfo , OomStrategy } ;
10
10
use rustc_symbol_mangling:: mangle_internal_symbol;
11
+ use smallvec:: SmallVec ;
11
12
12
13
use crate :: builder:: SBuilder ;
13
14
use crate :: declare:: declare_simple_fn;
14
15
use crate :: llvm:: { self , False , True , Type , Value } ;
15
- use crate :: { SimpleCx , attributes, debuginfo} ;
16
+ use crate :: { SimpleCx , attributes, debuginfo, llvm_util } ;
16
17
17
18
pub ( crate ) unsafe fn codegen (
18
19
tcx : TyCtxt < ' _ > ,
@@ -147,6 +148,20 @@ fn create_wrapper_function(
147
148
llvm:: Visibility :: from_generic ( tcx. sess . default_visibility ( ) ) ,
148
149
ty,
149
150
) ;
151
+
152
+ let mut attrs = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
153
+
154
+ let target_cpu = llvm_util:: target_cpu ( tcx. sess ) ;
155
+ let target_cpu_attr = llvm:: CreateAttrStringValue ( cx. llcx , "target-cpu" , target_cpu) ;
156
+
157
+ let tune_cpu_attr = llvm_util:: tune_cpu ( tcx. sess )
158
+ . map ( |tune_cpu| llvm:: CreateAttrStringValue ( cx. llcx , "tune-cpu" , tune_cpu) ) ;
159
+
160
+ attrs. push ( target_cpu_attr) ;
161
+ attrs. extend ( tune_cpu_attr) ;
162
+
163
+ attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Function , & attrs) ;
164
+
150
165
let no_return = if no_return {
151
166
// -> ! DIFlagNoReturn
152
167
let no_return = llvm:: AttributeKind :: NoReturn . create_attr ( cx. llcx ) ;
0 commit comments