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:
Andrew Kelley
2021-02-28 22:01:13 -07:00
parent 6af6c3c979
commit 72404db31f
3 changed files with 11 additions and 7 deletions

View File

@@ -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));
}