diff options
| author | bors <bors@rust-lang.org> | 2022-02-27 09:23:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-27 09:23:24 +0000 |
| commit | 2bd9656c80ff06412c833bd9a6e7118a81bb95fc (patch) | |
| tree | 8bba3eafb54303880322970d5ef4a1d0e83d92c1 /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | 93230281562cd6b1b45eff070c473e3be20d9e72 (diff) | |
| parent | 0d0cc4f6a0cb48600f183c382986df1897bdb7dc (diff) | |
| download | rust-2bd9656c80ff06412c833bd9a6e7118a81bb95fc.tar.gz rust-2bd9656c80ff06412c833bd9a6e7118a81bb95fc.zip | |
Auto merge of #94221 - erikdesjardins:addattr, r=nikic
Add LLVM attributes in batches instead of individually This should improve performance. ~r? `@ghost` (blocked on #94127)~
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 780af5bc2af..5e78d6fc851 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -1,3 +1,4 @@ +use crate::attributes; use crate::common::Funclet; use crate::context::CodegenCx; use crate::llvm::{self, BasicBlock, False}; @@ -22,6 +23,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange}; use rustc_target::spec::{HasTargetSpec, Target}; +use smallvec::SmallVec; use std::borrow::Cow; use std::ffi::CStr; use std::iter; @@ -1174,14 +1176,18 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) { + let mut attrs = SmallVec::<[_; 2]>::new(); + // Cleanup is always the cold path. - llvm::Attribute::Cold.apply_callsite(llvm::AttributePlace::Function, llret); + attrs.push(llvm::AttributeKind::Cold.create_attr(self.llcx)); // In LLVM versions with deferred inlining (currently, system LLVM < 14), // inlining drop glue can lead to exponential size blowup, see #41696 and #92110. if !llvm_util::is_rust_llvm() && llvm_util::get_version() < (14, 0, 0) { - llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret); + attrs.push(llvm::AttributeKind::NoInline.create_attr(self.llcx)); } + + attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &attrs); } } |
