Skip to content

Commit 34a6b6c

Browse files
committed
RustWrapper: simplify removing attributes
Avoids some extra conversions. Spotted by nikic during review.
1 parent 2803fbc commit 34a6b6c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,12 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
341341
unsigned Index,
342342
LLVMRustAttribute RustAttr) {
343343
Function *F = unwrap<Function>(Fn);
344-
Attribute Attr = Attribute::get(F->getContext(), fromRust(RustAttr));
345-
auto PAL = F->getAttributes();
344+
AttributeList PAL = F->getAttributes();
346345
AttributeList PALNew;
347346
#if LLVM_VERSION_LT(14, 0)
348-
AttrBuilder B(Attr);
349-
PALNew = PAL.removeAttributes(F->getContext(), Index, B);
347+
PALNew = PAL.removeAttribute(F->getContext(), Index, fromRust(RustAttr));
350348
#else
351-
AttributeMask M;
352-
M.addAttribute(Attr);
353-
PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, M);
349+
PALNew = PAL.removeAttributeAtIndex(F->getContext(), Index, fromRust(RustAttr));
354350
#endif
355351
F->setAttributes(PALNew);
356352
}

0 commit comments

Comments
 (0)