aboutsummaryrefslogtreecommitdiff
path: root/src/zig_llvm.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-02-28 22:01:13 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-02-28 22:01:13 -0700
commit72404db31f76635f11d0aa4dcc02c149ef885b3d (patch)
tree503a7b8732a3fa0b4fa408fd7dd63a579b16eb92 /src/zig_llvm.cpp
parent6af6c3c9791b655b3adca08749baf89404b081ae (diff)
downloadzig-72404db31f76635f11d0aa4dcc02c149ef885b3d.tar.gz
zig-72404db31f76635f11d0aa4dcc02c149ef885b3d.zip
stage1: update to LLVM 12 sret callsite requirements
Without this, the LLVM IR that zig generates cannot be compiled by LLVM.
Diffstat (limited to 'src/zig_llvm.cpp')
-rw-r--r--src/zig_llvm.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index 55e507c6d0..5a7d60f83b 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -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));
}