Skip to content

Commit

Permalink
Rollup merge of rust-lang#88289 - durin42:llvm-14-attrs, r=nikic
Browse files Browse the repository at this point in the history
Fixes for LLVM change 0f45c16

More details in the individual commit messages, but the summary is: LLVM deleted an unused-to-them method that we used, we worked around it to avoid annoying cleanup/restructuring in the Rust-side code.
  • Loading branch information
Dylan-DPC committed Aug 26, 2021
2 parents a4527ed + 027db5d commit bc669ac
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,30 @@ extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index,
LLVMRustAttribute RustAttr) {
Function *A = unwrap<Function>(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<Function>(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<Function>(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<Function>(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,
Expand All @@ -323,9 +319,8 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
const char *Name,
const char *Value) {
Function *F = unwrap<Function>(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,
Expand Down

0 comments on commit bc669ac

Please sign in to comment.