Skip to content

Commit 027db5d

Browse files
committed
RustWrapper: adapt to LLVM change 0f45c16
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.
1 parent f66e825 commit 027db5d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+9-14
Original file line numberDiff line numberDiff line change
@@ -270,34 +270,30 @@ extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index,
270270
LLVMRustAttribute RustAttr) {
271271
Function *A = unwrap<Function>(Fn);
272272
Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr));
273-
AttrBuilder B(Attr);
274-
A->addAttributes(Index, B);
273+
A->addAttribute(Index, Attr);
275274
}
276275

277276
extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn,
278277
unsigned Index,
279278
uint32_t Bytes) {
280279
Function *A = unwrap<Function>(Fn);
281-
AttrBuilder B;
282-
B.addAlignmentAttr(Bytes);
283-
A->addAttributes(Index, B);
280+
A->addAttribute(Index, Attribute::getWithAlignment(
281+
A->getContext(), llvm::Align(Bytes)));
284282
}
285283

286284
extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index,
287285
uint64_t Bytes) {
288286
Function *A = unwrap<Function>(Fn);
289-
AttrBuilder B;
290-
B.addDereferenceableAttr(Bytes);
291-
A->addAttributes(Index, B);
287+
A->addAttribute(Index, Attribute::getWithDereferenceableBytes(A->getContext(),
288+
Bytes));
292289
}
293290

294291
extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
295292
unsigned Index,
296293
uint64_t Bytes) {
297294
Function *A = unwrap<Function>(Fn);
298-
AttrBuilder B;
299-
B.addDereferenceableOrNullAttr(Bytes);
300-
A->addAttributes(Index, B);
295+
A->addAttribute(Index, Attribute::getWithDereferenceableOrNullBytes(
296+
A->getContext(), Bytes));
301297
}
302298

303299
extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
@@ -323,9 +319,8 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
323319
const char *Name,
324320
const char *Value) {
325321
Function *F = unwrap<Function>(Fn);
326-
AttrBuilder B;
327-
B.addAttribute(Name, Value);
328-
F->addAttributes(Index, B);
322+
F->addAttribute(Index, Attribute::get(
323+
F->getContext(), StringRef(Name), StringRef(Value)));
329324
}
330325

331326
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,

0 commit comments

Comments
 (0)