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/asm.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/asm.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/asm.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index e22bec24951..96c7d884b7b 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -1,3 +1,4 @@ +use crate::attributes; use crate::builder::Builder; use crate::common::Funclet; use crate::context::CodegenCx; @@ -18,6 +19,7 @@ use rustc_target::abi::*; use rustc_target::asm::*; use libc::{c_char, c_uint}; +use smallvec::SmallVec; use tracing::debug; impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { @@ -273,19 +275,20 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { ) .unwrap_or_else(|| span_bug!(line_spans[0], "LLVM asm constraint validation failed")); + let mut attrs = SmallVec::<[_; 2]>::new(); if options.contains(InlineAsmOptions::PURE) { if options.contains(InlineAsmOptions::NOMEM) { - llvm::Attribute::ReadNone.apply_callsite(llvm::AttributePlace::Function, result); + attrs.push(llvm::AttributeKind::ReadNone.create_attr(self.cx.llcx)); } else if options.contains(InlineAsmOptions::READONLY) { - llvm::Attribute::ReadOnly.apply_callsite(llvm::AttributePlace::Function, result); + attrs.push(llvm::AttributeKind::ReadOnly.create_attr(self.cx.llcx)); } - llvm::Attribute::WillReturn.apply_callsite(llvm::AttributePlace::Function, result); + attrs.push(llvm::AttributeKind::WillReturn.create_attr(self.cx.llcx)); } else if options.contains(InlineAsmOptions::NOMEM) { - llvm::Attribute::InaccessibleMemOnly - .apply_callsite(llvm::AttributePlace::Function, result); + attrs.push(llvm::AttributeKind::InaccessibleMemOnly.create_attr(self.cx.llcx)); } else { // LLVM doesn't have an attribute to represent ReadOnly + SideEffect } + attributes::apply_to_callsite(result, llvm::AttributePlace::Function, &{ attrs }); // Write results to outputs for (idx, op) in operands.iter().enumerate() { |
