Skip to content

Commit

Permalink
RustWrapper: simplify removing attributes
Browse files Browse the repository at this point in the history
Avoids some extra conversions. Spotted by nikic during review.
  • Loading branch information
durin42 committed Jan 5, 2022
1 parent 2803fbc commit 34a6b6c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,12 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
unsigned Index,
LLVMRustAttribute RustAttr) {
Function *F = unwrap<Function>(Fn);
Attribute Attr = Attribute::get(F->getContext(), fromRust(RustAttr));
auto PAL = F->getAttributes();
AttributeList PAL = F->getAttributes();
AttributeList PALNew;
#if LLVM_VERSION_LT(14, 0)
AttrBuilder B(Attr);
PALNew = PAL.removeAttributes(F->getContext(), Index, B);
PALNew = PAL.removeAttribute(F->getContext(), Index, fromRust(RustAttr));
#else
AttributeMask M;
M.addAttribute(Attr);
PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, M);
PALNew = PAL.removeAttributeAtIndex(F->getContext(), Index, fromRust(RustAttr));
#endif
F->setAttributes(PALNew);
}
Expand Down

0 comments on commit 34a6b6c

Please sign in to comment.