From 027db5d036768ba8b0e36cb1b9f3f0ed1e3da000 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 24 Aug 2021 09:44:17 -0400 Subject: [PATCH] RustWrapper: adapt to LLVM change 0f45c16f2caa The above-mentioned commit (part of the LLVM 14 development cycle) removes a method that rustc uses somewhat extensively. We mostly switch to lower-level methods that exist in all versions of LLVM we use, so no new ifdef logic is required in most cases. --- .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 4edfed0340187..4f07a0c67c13f 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -270,34 +270,30 @@ extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index, LLVMRustAttribute RustAttr) { Function *A = unwrap(Fn); Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr)); - AttrBuilder B(Attr); - A->addAttributes(Index, B); + A->addAttribute(Index, Attr); } extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn, unsigned Index, uint32_t Bytes) { Function *A = unwrap(Fn); - AttrBuilder B; - B.addAlignmentAttr(Bytes); - A->addAttributes(Index, B); + A->addAttribute(Index, Attribute::getWithAlignment( + A->getContext(), llvm::Align(Bytes))); } extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index, uint64_t Bytes) { Function *A = unwrap(Fn); - AttrBuilder B; - B.addDereferenceableAttr(Bytes); - A->addAttributes(Index, B); + A->addAttribute(Index, Attribute::getWithDereferenceableBytes(A->getContext(), + Bytes)); } extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn, unsigned Index, uint64_t Bytes) { Function *A = unwrap(Fn); - AttrBuilder B; - B.addDereferenceableOrNullAttr(Bytes); - A->addAttributes(Index, B); + A->addAttribute(Index, Attribute::getWithDereferenceableOrNullBytes( + A->getContext(), Bytes)); } extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index, @@ -323,9 +319,8 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn, const char *Name, const char *Value) { Function *F = unwrap(Fn); - AttrBuilder B; - B.addAttribute(Name, Value); - F->addAttributes(Index, B); + F->addAttribute(Index, Attribute::get( + F->getContext(), StringRef(Name), StringRef(Value))); } extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,