From 2803fbc44758a795d48a0c2d3a8ee06045dc9efb Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 4 Jan 2022 13:41:36 -0500 Subject: [PATCH 1/2] RustWrapper: adapt to new AttributeMask API Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use AttributeMask instead of AttrBuilder, so we need to follow suit here. --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 025a0ee376e..84db11efe30 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -342,13 +342,15 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, LLVMRustAttribute RustAttr) { Function *F = unwrap(Fn); Attribute Attr = Attribute::get(F->getContext(), fromRust(RustAttr)); - AttrBuilder B(Attr); auto PAL = F->getAttributes(); AttributeList PALNew; #if LLVM_VERSION_LT(14, 0) + AttrBuilder B(Attr); PALNew = PAL.removeAttributes(F->getContext(), Index, B); #else - PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, B); + AttributeMask M; + M.addAttribute(Attr); + PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, M); #endif F->setAttributes(PALNew); } From 34a6b6c4235972a715b03612905913d98ab899fd Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Wed, 5 Jan 2022 13:51:59 -0500 Subject: [PATCH 2/2] RustWrapper: simplify removing attributes Avoids some extra conversions. Spotted by nikic during review. --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 84db11efe30..dd249bd17fc 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -341,16 +341,12 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, unsigned Index, LLVMRustAttribute RustAttr) { Function *F = unwrap(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); }