1
Fork 0

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.
This commit is contained in:
Augie Fackler 2021-08-24 09:44:17 -04:00
parent f66e825f73
commit 027db5d036

View file

@ -270,34 +270,30 @@ extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index,
LLVMRustAttribute RustAttr) { LLVMRustAttribute RustAttr) {
Function *A = unwrap<Function>(Fn); Function *A = unwrap<Function>(Fn);
Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr)); Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr));
AttrBuilder B(Attr); A->addAttribute(Index, Attr);
A->addAttributes(Index, B);
} }
extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn, extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn,
unsigned Index, unsigned Index,
uint32_t Bytes) { uint32_t Bytes) {
Function *A = unwrap<Function>(Fn); Function *A = unwrap<Function>(Fn);
AttrBuilder B; A->addAttribute(Index, Attribute::getWithAlignment(
B.addAlignmentAttr(Bytes); A->getContext(), llvm::Align(Bytes)));
A->addAttributes(Index, B);
} }
extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index, extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index,
uint64_t Bytes) { uint64_t Bytes) {
Function *A = unwrap<Function>(Fn); Function *A = unwrap<Function>(Fn);
AttrBuilder B; A->addAttribute(Index, Attribute::getWithDereferenceableBytes(A->getContext(),
B.addDereferenceableAttr(Bytes); Bytes));
A->addAttributes(Index, B);
} }
extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn, extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
unsigned Index, unsigned Index,
uint64_t Bytes) { uint64_t Bytes) {
Function *A = unwrap<Function>(Fn); Function *A = unwrap<Function>(Fn);
AttrBuilder B; A->addAttribute(Index, Attribute::getWithDereferenceableOrNullBytes(
B.addDereferenceableOrNullAttr(Bytes); A->getContext(), Bytes));
A->addAttributes(Index, B);
} }
extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index, extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
@ -323,9 +319,8 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
const char *Name, const char *Name,
const char *Value) { const char *Value) {
Function *F = unwrap<Function>(Fn); Function *F = unwrap<Function>(Fn);
AttrBuilder B; F->addAttribute(Index, Attribute::get(
B.addAttribute(Name, Value); F->getContext(), StringRef(Name), StringRef(Value)));
F->addAttributes(Index, B);
} }
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,