diff options
| author | bors <bors@rust-lang.org> | 2025-09-05 20:49:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-05 20:49:13 +0000 |
| commit | 6c699a37235700ab749e3f14147fe41d49c056e8 (patch) | |
| tree | 0f9a359fdd990ba03da8f8aa6ba4ca82682dbda5 /compiler/rustc_codegen_llvm/src/attributes.rs | |
| parent | 99317ef14d0be42fa4039eea7c5ce50cb4e9aee7 (diff) | |
| parent | 55a62d57ed85c8e1cd412c368c72fc2e7dad48f5 (diff) | |
| download | rust-6c699a37235700ab749e3f14147fe41d49c056e8.tar.gz rust-6c699a37235700ab749e3f14147fe41d49c056e8.zip | |
Auto merge of #146255 - fmease:rollup-1v0kp8i, r=fmease
Rollup of 11 pull requests
Successful merges:
- rust-lang/rust#138944 (Add `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast` symbols)
- rust-lang/rust#139113 (unstable book: in a sanitizer example, check the code)
- rust-lang/rust#145735 (style-guide: Document absence of trailing whitespace)
- rust-lang/rust#146041 (tidy: --bless now makes escheck run with --fix)
- rust-lang/rust#146144 (compiler: Apply target features to the entry function)
- rust-lang/rust#146225 (Simplify `{f16, f32, f64, f128}::midpoint()`)
- rust-lang/rust#146234 (change file-is-generated doc comment to inner)
- rust-lang/rust#146241 (rustc_infer: change top-level doc comment to inner)
- rust-lang/rust#146242 (Ensure that `--html-after-content` option is used to check `scrape_examples_ice` rustdoc GUI test)
- rust-lang/rust#146243 (remove couple of redundant clones)
- rust-lang/rust#146250 (Bump stage0 rustfmt)
Failed merges:
- rust-lang/rust#146200 (Simplify rustdoc-gui tester by calling directly browser-ui-test)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 9f2d37d39d8..573c51a9539 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -296,6 +296,19 @@ pub(crate) fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu .map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu)) } +/// Get the `target-features` LLVM attribute. +pub(crate) fn target_features_attr<'ll>( + cx: &CodegenCx<'ll, '_>, + function_features: Vec<String>, +) -> Option<&'ll Attribute> { + let global_features = cx.tcx.global_backend_features(()).iter().map(String::as_str); + let function_features = function_features.iter().map(String::as_str); + let target_features = + global_features.chain(function_features).intersperse(",").collect::<String>(); + (!target_features.is_empty()) + .then(|| llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features)) +} + /// Get the `NonLazyBind` LLVM attribute, /// if the codegen options allow skipping the PLT. pub(crate) fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> { @@ -523,14 +536,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( } } - let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str()); - let function_features = function_features.iter().map(|s| s.as_str()); - let target_features: String = - global_features.chain(function_features).intersperse(",").collect(); - - if !target_features.is_empty() { - to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features)); - } + to_add.extend(target_features_attr(cx, function_features)); attributes::apply_to_llfn(llfn, Function, &to_add); } |
