diff options
| author | bors <bors@rust-lang.org> | 2022-03-02 08:48:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-02 08:48:33 +0000 |
| commit | c42d846add941a26bd254911e16f02c4a3f9346f (patch) | |
| tree | 8d1dc6001d9de975c088cb6b7f56c1a0891848e7 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 2a280de64fb34378174fa33b6866a7ee920ceb8d (diff) | |
| parent | dce14cfacc232e80dbed68430183085fd39dea02 (diff) | |
| download | rust-c42d846add941a26bd254911e16f02c4a3f9346f.tar.gz rust-c42d846add941a26bd254911e16f02c4a3f9346f.zip | |
Auto merge of #94229 - erikdesjardins:rem2, r=nikic
Remove LLVM attribute removal This was necessary before, because `declare_raw_fn` would always apply the default optimization attributes to every declared function. Then `attributes::from_fn_attrs` would have to remove the default attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build. (see [`src/test/codegen/optimize-attr-1.rs`](https://github.com/rust-lang/rust/blob/03a8cc7df1d65554a4d40825b0490c93ac0f0236/src/test/codegen/optimize-attr-1.rs#L33)) However, every relevant callsite of `declare_raw_fn` (i.e. where we actually generate code for the function, and not e.g. a call to an intrinsic, where optimization attributes don't [?] matter) calls `from_fn_attrs`, so we can remove the attribute setting from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct attributes all at once. r? `@ghost` (blocked on #94221) `@rustbot` label S-blocked
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index be3c1b02a05..919fe7cac5c 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -250,38 +250,12 @@ template<typename T> static inline void AddAttributes(T *t, unsigned Index, t->setAttributes(PALNew); } -template<typename T> static inline void RemoveAttributes(T *t, unsigned Index, - LLVMRustAttribute *RustAttrs, - size_t RustAttrsLen) { - AttributeList PAL = t->getAttributes(); - AttributeList PALNew; -#if LLVM_VERSION_LT(14, 0) - AttrBuilder B; - for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen)) - B.addAttribute(fromRust(RustAttr)); - PALNew = PAL.removeAttributes(t->getContext(), Index, B); -#else - AttributeMask Mask; - for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen)) - Mask.addAttribute(fromRust(RustAttr)); - PALNew = PAL.removeAttributesAtIndex(t->getContext(), Index, Mask); -#endif - t->setAttributes(PALNew); -} - extern "C" void LLVMRustAddFunctionAttributes(LLVMValueRef Fn, unsigned Index, LLVMAttributeRef *Attrs, size_t AttrsLen) { Function *F = unwrap<Function>(Fn); AddAttributes(F, Index, Attrs, AttrsLen); } -extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, unsigned Index, - LLVMRustAttribute *RustAttrs, - size_t RustAttrsLen) { - Function *F = unwrap<Function>(Fn); - RemoveAttributes(F, Index, RustAttrs, RustAttrsLen); -} - extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr, unsigned Index, LLVMAttributeRef *Attrs, size_t AttrsLen) { CallBase *Call = unwrap<CallBase>(Instr); |
