| author | |
| committer | |
| log | b706b9bce798666937b7cafde9d778085cbf4e2f |
| tree | 1961b24499f0be290cbb009f8553c0f62d8ccec2 |
| parent | 431801707fa661a70660787ee499530d093d513b |
LLVM12 deprecated `sret` and replaced it with the `sret(<Ty>)` form.
Closes #80753 files changed, 14 insertions(+), 3 deletions(-)
src/stage1/codegen.cpp+2-2| ... | ... | @@ -549,7 +549,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { |
| 549 | 549 | } else if (want_first_arg_sret(g, &fn_type->data.fn.fn_type_id)) { |
| 550 | 550 | // Sret pointers must not be address 0 |
| 551 | 551 | addLLVMArgAttr(llvm_fn, 0, "nonnull"); |
| 552 | addLLVMArgAttr(llvm_fn, 0, "sret"); | |
| 552 | ZigLLVMAddSretAttr(llvm_fn, 0, get_llvm_type(g, return_type)); | |
| 553 | 553 | if (cc_want_sret_attr(cc)) { |
| 554 | 554 | addLLVMArgAttr(llvm_fn, 0, "noalias"); |
| 555 | 555 | } |
| ... | ... | @@ -1972,7 +1972,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_ |
| 1972 | 1972 | switch (fn_walk->id) { |
| 1973 | 1973 | case FnWalkIdAttrs: |
| 1974 | 1974 | if (abi_class != X64CABIClass_MEMORY_nobyval) { |
| 1975 | ZigLLVMAddByValAttr(llvm_fn, fn_walk->data.attrs.gen_i + 1, get_llvm_type(g, ty)); | |
| 1975 | ZigLLVMAddByValAttr(llvm_fn, fn_walk->data.attrs.gen_i, get_llvm_type(g, ty)); | |
| 1976 | 1976 | addLLVMArgAttrInt(llvm_fn, fn_walk->data.attrs.gen_i, "align", get_abi_alignment(g, ty)); |
| 1977 | 1977 | } else if (g->zig_target->arch == ZigLLVM_aarch64 || |
| 1978 | 1978 | g->zig_target->arch == ZigLLVM_aarch64_be) |
src/zig_llvm.cpp+11-1| ... | ... | @@ -798,7 +798,17 @@ void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_v |
| 798 | 798 | AttrBuilder attr_builder; |
| 799 | 799 | Type *llvm_type = unwrap<Type>(type_val); |
| 800 | 800 | attr_builder.addByValAttr(llvm_type); |
| 801 | const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo, attr_builder); | |
| 801 | const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo + 1, attr_builder); | |
| 802 | func->setAttributes(new_attr_set); | |
| 803 | } | |
| 804 | ||
| 805 | void ZigLLVMAddSretAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val) { | |
| 806 | Function *func = unwrap<Function>(fn_ref); | |
| 807 | const AttributeList attr_set = func->getAttributes(); | |
| 808 | AttrBuilder attr_builder; | |
| 809 | Type *llvm_type = unwrap<Type>(type_val); | |
| 810 | attr_builder.addStructRetAttr(llvm_type); | |
| 811 | const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo + 1, attr_builder); | |
| 802 | 812 | func->setAttributes(new_attr_set); |
| 803 | 813 | } |
| 804 | 814 |
src/zig_llvm.h+1| ... | ... | @@ -269,6 +269,7 @@ ZIG_EXTERN_C void ZigLLVMFunctionSetCallingConv(LLVMValueRef function, enum ZigL |
| 269 | 269 | |
| 270 | 270 | ZIG_EXTERN_C void ZigLLVMAddFunctionAttr(LLVMValueRef fn, const char *attr_name, const char *attr_value); |
| 271 | 271 | ZIG_EXTERN_C void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val); |
| 272 | ZIG_EXTERN_C void ZigLLVMAddSretAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val); | |
| 272 | 273 | ZIG_EXTERN_C void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn); |
| 273 | 274 | |
| 274 | 275 | ZIG_EXTERN_C void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv); |