aboutsummaryrefslogtreecommitdiff
path: root/src/zig_llvm.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2021-02-26 15:24:08 +0100
committerAndrew Kelley <andrew@ziglang.org>2021-02-26 12:48:27 -0800
commitb706b9bce798666937b7cafde9d778085cbf4e2f (patch)
tree1961b24499f0be290cbb009f8553c0f62d8ccec2 /src/zig_llvm.cpp
parent431801707fa661a70660787ee499530d093d513b (diff)
downloadzig-b706b9bce798666937b7cafde9d778085cbf4e2f.tar.gz
zig-b706b9bce798666937b7cafde9d778085cbf4e2f.zip
stage1: Fix emission of sret annotation for LLVM
LLVM12 deprecated `sret` and replaced it with the `sret(<Ty>)` form. Closes #8075
Diffstat (limited to 'src/zig_llvm.cpp')
-rw-r--r--src/zig_llvm.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index b4bdf7c033..55e507c6d0 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -798,7 +798,17 @@ void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_v
AttrBuilder attr_builder;
Type *llvm_type = unwrap<Type>(type_val);
attr_builder.addByValAttr(llvm_type);
- const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo, attr_builder);
+ const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo + 1, attr_builder);
+ func->setAttributes(new_attr_set);
+}
+
+void ZigLLVMAddSretAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val) {
+ Function *func = unwrap<Function>(fn_ref);
+ const AttributeList attr_set = func->getAttributes();
+ AttrBuilder attr_builder;
+ Type *llvm_type = unwrap<Type>(type_val);
+ attr_builder.addStructRetAttr(llvm_type);
+ const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo + 1, attr_builder);
func->setAttributes(new_attr_set);
}