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/llvm/ffi.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/llvm/ffi.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 657f1fcf31e..31d1460e178 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -155,7 +155,7 @@ pub enum DLLStorageClass { /// though it is not ABI compatible (since it's a C++ enum) #[repr(C)] #[derive(Copy, Clone, Debug)] -pub enum Attribute { +pub enum AttributeKind { AlwaysInline = 0, ByVal = 1, Cold = 2, @@ -644,6 +644,9 @@ extern "C" { pub type ConstantInt; } extern "C" { + pub type Attribute; +} +extern "C" { pub type Metadata; } extern "C" { @@ -1169,6 +1172,21 @@ extern "C" { ) -> Option<&Value>; pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); + // Operations on attributes + pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute; + pub fn LLVMRustCreateAttrString(C: &Context, Name: *const c_char) -> &Attribute; + pub fn LLVMRustCreateAttrStringValue( + C: &Context, + Name: *const c_char, + Value: *const c_char, + ) -> &Attribute; + pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; + pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; + pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute; + // Operations on functions pub fn LLVMRustGetOrInsertFunction<'a>( M: &'a Module, @@ -1177,20 +1195,18 @@ extern "C" { FunctionTy: &'a Type, ) -> &'a Value; pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint); - pub fn LLVMRustAddAlignmentAttr(Fn: &Value, index: c_uint, bytes: u32); - pub fn LLVMRustAddDereferenceableAttr(Fn: &Value, index: c_uint, bytes: u64); - pub fn LLVMRustAddDereferenceableOrNullAttr(Fn: &Value, index: c_uint, bytes: u64); - pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type); - pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type); - pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute); - pub fn LLVMRustEmitUWTableAttr(Fn: &Value, async_: bool); - pub fn LLVMRustAddFunctionAttrStringValue( + pub fn LLVMRustAddFunctionAttributes<'a>( + Fn: &'a Value, + index: c_uint, + Attrs: *const &'a Attribute, + AttrsLen: size_t, + ); + pub fn LLVMRustRemoveFunctionAttributes( Fn: &Value, index: c_uint, - Name: *const c_char, - Value: *const c_char, + Attrs: *const AttributeKind, + AttrsLen: size_t, ); - pub fn LLVMRustRemoveFunctionAttributes(Fn: &Value, index: c_uint, attr: Attribute); // Operations on parameters pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>; @@ -1211,13 +1227,12 @@ extern "C" { // Operations on call sites pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); - pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute); - pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char); - pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32); - pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); - pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); - pub fn LLVMRustAddByValCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type); - pub fn LLVMRustAddStructRetCallSiteAttr(Instr: &Value, index: c_uint, ty: &Type); + pub fn LLVMRustAddCallSiteAttributes<'a>( + Instr: &'a Value, + index: c_uint, + Attrs: *const &'a Attribute, + AttrsLen: size_t, + ); // Operations on load/store instructions (only) pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool); |
