Skip to content

Commit 86822eb

Browse files
Unconditionally emit the target-cpu LLVM attribute.
1 parent 58e9832 commit 86822eb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/librustc_codegen_llvm/attributes.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer;
1818
use rustc::ty::TyCtxt;
1919
use rustc::ty::layout::HasTyCtxt;
2020
use rustc::ty::query::Providers;
21+
use rustc_data_structures::small_c_str::SmallCStr;
2122
use rustc_data_structures::sync::Lrc;
2223
use rustc_data_structures::fx::FxHashMap;
2324
use rustc_target::spec::PanicStrategy;
@@ -129,8 +130,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
129130
}
130131

131132
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));
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

Comments
 (0)