mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
stage1: update to LLVM 12 sret callsite requirements
Without this, the LLVM IR that zig generates cannot be compiled by LLVM.
This commit is contained in:
parent
6af6c3c979
commit
72404db31f
@ -4037,12 +4037,6 @@ static void gen_set_stack_pointer(CodeGen *g, LLVMValueRef aligned_end_addr) {
|
||||
LLVMBuildCall(g->builder, write_register_fn_val, params, 2, "");
|
||||
}
|
||||
|
||||
static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) {
|
||||
unsigned attr_kind_id = LLVMGetEnumAttributeKindForName("sret", 4);
|
||||
LLVMAttributeRef sret_attr = LLVMCreateEnumAttribute(LLVMGetGlobalContext(), attr_kind_id, 0);
|
||||
LLVMAddCallSiteAttribute(call_instr, 1, sret_attr);
|
||||
}
|
||||
|
||||
static void render_async_spills(CodeGen *g) {
|
||||
ZigType *fn_type = g->cur_fn->type_entry;
|
||||
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
|
||||
} else if (!ret_has_bits) {
|
||||
return nullptr;
|
||||
} else if (first_arg_ret) {
|
||||
set_call_instr_sret(g, result);
|
||||
ZigLLVMSetCallSret(result, get_llvm_type(g, src_return_type));
|
||||
return result_loc;
|
||||
} else if (handle_is_ptr(g, src_return_type)) {
|
||||
LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc);
|
||||
|
||||
@ -940,6 +940,15 @@ void ZigLLVMSetTailCall(LLVMValueRef Call) {
|
||||
unwrap<CallInst>(Call)->setTailCallKind(CallInst::TCK_MustTail);
|
||||
}
|
||||
|
||||
void ZigLLVMSetCallSret(LLVMValueRef Call, LLVMTypeRef return_type) {
|
||||
const AttributeList attr_set = unwrap<CallInst>(Call)->getAttributes();
|
||||
AttrBuilder attr_builder;
|
||||
Type *llvm_type = unwrap<Type>(return_type);
|
||||
attr_builder.addStructRetAttr(llvm_type);
|
||||
const AttributeList new_attr_set = attr_set.addAttributes(unwrap<CallInst>(Call)->getContext(), 1, attr_builder);
|
||||
unwrap<CallInst>(Call)->setAttributes(new_attr_set);
|
||||
}
|
||||
|
||||
void ZigLLVMFunctionSetPrefixData(LLVMValueRef function, LLVMValueRef data) {
|
||||
unwrap<Function>(function)->setPrefixData(unwrap<Constant>(data));
|
||||
}
|
||||
|
||||
@ -264,6 +264,7 @@ ZIG_EXTERN_C struct ZigLLVMDILocation *ZigLLVMGetDebugLoc(unsigned line, unsigne
|
||||
|
||||
ZIG_EXTERN_C void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state);
|
||||
ZIG_EXTERN_C void ZigLLVMSetTailCall(LLVMValueRef Call);
|
||||
ZIG_EXTERN_C void ZigLLVMSetCallSret(LLVMValueRef Call, LLVMTypeRef return_type);
|
||||
ZIG_EXTERN_C void ZigLLVMFunctionSetPrefixData(LLVMValueRef fn, LLVMValueRef data);
|
||||
ZIG_EXTERN_C void ZigLLVMFunctionSetCallingConv(LLVMValueRef function, enum ZigLLVM_CallingConv cc);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user