@@ -225,41 +225,28 @@ extern "C" void LLVMRustAddCallSiteAttrString(LLVMValueRef Instr, unsigned Index
225225 AddAttribute (Call, Index, Attr);
226226}
227227
228- static inline void AddCallAttributes (CallBase *Call, unsigned Index, const AttrBuilder& B) {
229- AttributeList Attrs = Call->getAttributes ();
230- #if LLVM_VERSION_LT(14, 0)
231- Attrs = Attrs.addAttributes (Call->getContext (), Index, B);
232- #else
233- Attrs = Attrs.addAttributesAtIndex (Call->getContext (), Index, B);
234- #endif
235- Call->setAttributes (Attrs);
236- }
237-
238228extern " C" void LLVMRustAddAlignmentCallSiteAttr (LLVMValueRef Instr,
239229 unsigned Index,
240230 uint32_t Bytes) {
241231 CallBase *Call = unwrap<CallBase>(Instr);
242- AttrBuilder B;
243- B.addAlignmentAttr (Bytes);
244- AddCallAttributes (Call, Index, B);
232+ Attribute Attr = Attribute::getWithAlignment (Call->getContext (), Align (Bytes));
233+ AddAttribute (Call, Index, Attr);
245234}
246235
247236extern " C" void LLVMRustAddDereferenceableCallSiteAttr (LLVMValueRef Instr,
248237 unsigned Index,
249238 uint64_t Bytes) {
250239 CallBase *Call = unwrap<CallBase>(Instr);
251- AttrBuilder B;
252- B.addDereferenceableAttr (Bytes);
253- AddCallAttributes (Call, Index, B);
240+ Attribute Attr = Attribute::getWithDereferenceableBytes (Call->getContext (), Bytes);
241+ AddAttribute (Call, Index, Attr);
254242}
255243
256244extern " C" void LLVMRustAddDereferenceableOrNullCallSiteAttr (LLVMValueRef Instr,
257245 unsigned Index,
258246 uint64_t Bytes) {
259247 CallBase *Call = unwrap<CallBase>(Instr);
260- AttrBuilder B;
261- B.addDereferenceableOrNullAttr (Bytes);
262- AddCallAttributes (Call, Index, B);
248+ Attribute Attr = Attribute::getWithDereferenceableOrNullBytes (Call->getContext (), Bytes);
249+ AddAttribute (Call, Index, Attr);
263250}
264251
265252extern " C" void LLVMRustAddByValCallSiteAttr (LLVMValueRef Instr, unsigned Index,
0 commit comments