@@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer;
1818use rustc:: ty:: TyCtxt ;
1919use rustc:: ty:: layout:: HasTyCtxt ;
2020use rustc:: ty:: query:: Providers ;
21+ use rustc_data_structures:: small_c_str:: SmallCStr ;
2122use rustc_data_structures:: sync:: Lrc ;
2223use rustc_data_structures:: fx:: FxHashMap ;
2324use rustc_target:: spec:: PanicStrategy ;
@@ -129,8 +130,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
129130}
130131
131132pub fn apply_target_cpu_attr ( cx : & CodegenCx < ' ll , ' _ > , llfn : & ' ll Value ) {
132- let cpu = llvm_util:: target_cpu ( cx. tcx . sess ) ;
133- let target_cpu = CString :: new ( cpu) . unwrap ( ) ;
133+ let target_cpu = SmallCStr :: new ( llvm_util:: target_cpu ( cx. tcx . sess ) ) ;
134134 llvm:: AddFunctionAttrStringValue (
135135 llfn,
136136 llvm:: AttributePlace :: Function ,
@@ -220,11 +220,7 @@ pub fn from_fn_attrs(
220220 // Always annotate functions with the target-cpu they are compiled for.
221221 // Without this, ThinLTO won't inline Rust functions into Clang generated
222222 // functions (because Clang annotates functions this way too).
223- // NOTE: For now we just apply this if -Zcross-lang-lto is specified, since
224- // it introduce a little overhead and isn't really necessary otherwise.
225- if cx. tcx . sess . opts . debugging_opts . cross_lang_lto . enabled ( ) {
226- apply_target_cpu_attr ( cx, llfn) ;
227- }
223+ apply_target_cpu_attr ( cx, llfn) ;
228224
229225 let features = llvm_target_features ( cx. tcx . sess )
230226 . map ( |s| s. to_string ( ) )
0 commit comments