| author | |
| committer | |
| log | 72404db31f76635f11d0aa4dcc02c149ef885b3d |
| tree | 503a7b8732a3fa0b4fa408fd7dd63a579b16eb92 |
| parent | 6af6c3c9791b655b3adca08749baf89404b081ae |
Without this, the LLVM IR that zig generates cannot be compiled by LLVM.3 files changed, 11 insertions(+), 7 deletions(-)
src/stage1/codegen.cpp+1-7| ... | @@ -4037,12 +4037,6 @@ static void gen_set_stack_pointer(CodeGen *g, LLVMValueRef aligned_end_addr) { | ... | @@ -4037,12 +4037,6 @@ static void gen_set_stack_pointer(CodeGen *g, LLVMValueRef aligned_end_addr) { |
| 4037 | LLVMBuildCall(g->builder, write_register_fn_val, params, 2, ""); | 4037 | LLVMBuildCall(g->builder, write_register_fn_val, params, 2, ""); |
| 4038 | } | 4038 | } |
| 4039 | 4039 | ||
| 4040 | static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) { | ||
| 4041 | unsigned attr_kind_id = LLVMGetEnumAttributeKindForName("sret", 4); | ||
| 4042 | LLVMAttributeRef sret_attr = LLVMCreateEnumAttribute(LLVMGetGlobalContext(), attr_kind_id, 0); | ||
| 4043 | LLVMAddCallSiteAttribute(call_instr, 1, sret_attr); | ||
| 4044 | } | ||
| 4045 | |||
| 4046 | static void render_async_spills(CodeGen *g) { | 4040 | static void render_async_spills(CodeGen *g) { |
| 4047 | ZigType *fn_type = g->cur_fn->type_entry; | 4041 | ZigType *fn_type = g->cur_fn->type_entry; |
| 4048 | ZigType *import = get_scope_import(&g->cur_fn->fndef_scope->base); | 4042 | ZigType *import = get_scope_import(&g->cur_fn->fndef_scope->base); |
| ... | @@ -4558,7 +4552,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn | ... | @@ -4558,7 +4552,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn |
| 4558 | } else if (!ret_has_bits) { | 4552 | } else if (!ret_has_bits) { |
| 4559 | return nullptr; | 4553 | return nullptr; |
| 4560 | } else if (first_arg_ret) { | 4554 | } else if (first_arg_ret) { |
| 4561 | set_call_instr_sret(g, result); | 4555 | ZigLLVMSetCallSret(result, get_llvm_type(g, src_return_type)); |
| 4562 | return result_loc; | 4556 | return result_loc; |
| 4563 | } else if (handle_is_ptr(g, src_return_type)) { | 4557 | } else if (handle_is_ptr(g, src_return_type)) { |
| 4564 | LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc); | 4558 | LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc); |
src/zig_llvm.cpp+9| ... | @@ -940,6 +940,15 @@ void ZigLLVMSetTailCall(LLVMValueRef Call) { | ... | @@ -940,6 +940,15 @@ void ZigLLVMSetTailCall(LLVMValueRef Call) { |
| 940 | unwrap<CallInst>(Call)->setTailCallKind(CallInst::TCK_MustTail); | 940 | unwrap<CallInst>(Call)->setTailCallKind(CallInst::TCK_MustTail); |
| 941 | } | 941 | } |
| 942 | 942 | ||
| 943 | void ZigLLVMSetCallSret(LLVMValueRef Call, LLVMTypeRef return_type) { | ||
| 944 | const AttributeList attr_set = unwrap<CallInst>(Call)->getAttributes(); | ||
| 945 | AttrBuilder attr_builder; | ||
| 946 | Type *llvm_type = unwrap<Type>(return_type); | ||
| 947 | attr_builder.addStructRetAttr(llvm_type); | ||
| 948 | const AttributeList new_attr_set = attr_set.addAttributes(unwrap<CallInst>(Call)->getContext(), 1, attr_builder); | ||
| 949 | unwrap<CallInst>(Call)->setAttributes(new_attr_set); | ||
| 950 | } | ||
| 951 | |||
| 943 | void ZigLLVMFunctionSetPrefixData(LLVMValueRef function, LLVMValueRef data) { | 952 | void ZigLLVMFunctionSetPrefixData(LLVMValueRef function, LLVMValueRef data) { |
| 944 | unwrap<Function>(function)->setPrefixData(unwrap<Constant>(data)); | 953 | unwrap<Function>(function)->setPrefixData(unwrap<Constant>(data)); |
| 945 | } | 954 | } |
src/zig_llvm.h+1| ... | @@ -264,6 +264,7 @@ ZIG_EXTERN_C struct ZigLLVMDILocation *ZigLLVMGetDebugLoc(unsigned line, unsigne | ... | @@ -264,6 +264,7 @@ ZIG_EXTERN_C struct ZigLLVMDILocation *ZigLLVMGetDebugLoc(unsigned line, unsigne |
| 264 | 264 | ||
| 265 | ZIG_EXTERN_C void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); | 265 | ZIG_EXTERN_C void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); |
| 266 | ZIG_EXTERN_C void ZigLLVMSetTailCall(LLVMValueRef Call); | 266 | ZIG_EXTERN_C void ZigLLVMSetTailCall(LLVMValueRef Call); |
| 267 | ZIG_EXTERN_C void ZigLLVMSetCallSret(LLVMValueRef Call, LLVMTypeRef return_type); | ||
| 267 | ZIG_EXTERN_C void ZigLLVMFunctionSetPrefixData(LLVMValueRef fn, LLVMValueRef data); | 268 | ZIG_EXTERN_C void ZigLLVMFunctionSetPrefixData(LLVMValueRef fn, LLVMValueRef data); |
| 268 | ZIG_EXTERN_C void ZigLLVMFunctionSetCallingConv(LLVMValueRef function, enum ZigLLVM_CallingConv cc); | 269 | ZIG_EXTERN_C void ZigLLVMFunctionSetCallingConv(LLVMValueRef function, enum ZigLLVM_CallingConv cc); |
| 269 | 270 |