@@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer;
18
18
use rustc:: ty:: TyCtxt ;
19
19
use rustc:: ty:: layout:: HasTyCtxt ;
20
20
use rustc:: ty:: query:: Providers ;
21
+ use rustc_data_structures:: small_c_str:: SmallCStr ;
21
22
use rustc_data_structures:: sync:: Lrc ;
22
23
use rustc_data_structures:: fx:: FxHashMap ;
23
24
use rustc_target:: spec:: PanicStrategy ;
@@ -129,8 +130,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
129
130
}
130
131
131
132
pub 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 ) ) ;
134
134
llvm:: AddFunctionAttrStringValue (
135
135
llfn,
136
136
llvm:: AttributePlace :: Function ,
@@ -220,11 +220,7 @@ pub fn from_fn_attrs(
220
220
// Always annotate functions with the target-cpu they are compiled for.
221
221
// Without this, ThinLTO won't inline Rust functions into Clang generated
222
222
// 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) ;
228
224
229
225
let features = llvm_target_features ( cx. tcx . sess )
230
226
. map ( |s| s. to_string ( ) )
0 commit comments