Skip to content

Commit de1914a

Browse files
committed
Avoid an unnecessary use of SmallStr.
I don't know why `SmallStr` was used here; some ad hoc profiling showed this code is not that hot, the string is usually empty, and when it's not empty it's usually very short. However, the use of a `SmallStr<1024>` does result in 1024 byte `memcpy` call on each execution, which shows up when I do `memcpy` profiling. So using a normal string makes the code both simpler and very slightly faster.
1 parent 45fcd1d commit de1914a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Set and unset common attributes on LLVM values.
22
33
use rustc_codegen_ssa::traits::*;
4-
use rustc_data_structures::small_str::SmallStr;
54
use rustc_hir::def_id::DefId;
65
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
76
use rustc_middle::ty::{self, TyCtxt};
@@ -481,8 +480,8 @@ pub fn from_fn_attrs<'ll, 'tcx>(
481480

482481
let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());
483482
let function_features = function_features.iter().map(|s| s.as_str());
484-
let target_features =
485-
global_features.chain(function_features).intersperse(",").collect::<SmallStr<1024>>();
483+
let target_features: String =
484+
global_features.chain(function_features).intersperse(",").collect();
486485
if !target_features.is_empty() {
487486
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
488487
}

0 commit comments

Comments
 (0)