RustWrapper: remove some uses of AttrBuilder
Turns out we can also use Attribute::get*() methods here, and avoid the AttrBuilder and an extra helper method here.
This commit is contained in:
parent
484b79b950
commit
4d045406d1
1 changed files with 6 additions and 19 deletions
|
@ -225,41 +225,28 @@ extern "C" void LLVMRustAddCallSiteAttrString(LLVMValueRef Instr, unsigned Index
|
||||||
AddAttribute(Call, Index, Attr);
|
AddAttribute(Call, Index, Attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrBuilder& B) {
|
|
||||||
AttributeList Attrs = Call->getAttributes();
|
|
||||||
#if LLVM_VERSION_LT(14, 0)
|
|
||||||
Attrs = Attrs.addAttributes(Call->getContext(), Index, B);
|
|
||||||
#else
|
|
||||||
Attrs = Attrs.addAttributesAtIndex(Call->getContext(), Index, B);
|
|
||||||
#endif
|
|
||||||
Call->setAttributes(Attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr,
|
extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr,
|
||||||
unsigned Index,
|
unsigned Index,
|
||||||
uint32_t Bytes) {
|
uint32_t Bytes) {
|
||||||
CallBase *Call = unwrap<CallBase>(Instr);
|
CallBase *Call = unwrap<CallBase>(Instr);
|
||||||
AttrBuilder B;
|
Attribute Attr = Attribute::getWithAlignment(Call->getContext(), Align(Bytes));
|
||||||
B.addAlignmentAttr(Bytes);
|
AddAttribute(Call, Index, Attr);
|
||||||
AddCallAttributes(Call, Index, B);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
|
extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
|
||||||
unsigned Index,
|
unsigned Index,
|
||||||
uint64_t Bytes) {
|
uint64_t Bytes) {
|
||||||
CallBase *Call = unwrap<CallBase>(Instr);
|
CallBase *Call = unwrap<CallBase>(Instr);
|
||||||
AttrBuilder B;
|
Attribute Attr = Attribute::getWithDereferenceableBytes(Call->getContext(), Bytes);
|
||||||
B.addDereferenceableAttr(Bytes);
|
AddAttribute(Call, Index, Attr);
|
||||||
AddCallAttributes(Call, Index, B);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
|
extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
|
||||||
unsigned Index,
|
unsigned Index,
|
||||||
uint64_t Bytes) {
|
uint64_t Bytes) {
|
||||||
CallBase *Call = unwrap<CallBase>(Instr);
|
CallBase *Call = unwrap<CallBase>(Instr);
|
||||||
AttrBuilder B;
|
Attribute Attr = Attribute::getWithDereferenceableOrNullBytes(Call->getContext(), Bytes);
|
||||||
B.addDereferenceableOrNullAttr(Bytes);
|
AddAttribute(Call, Index, Attr);
|
||||||
AddCallAttributes(Call, Index, B);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,
|
extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue