| author | |
| committer | |
| log | 2c1e955de7a8f31666c751ce4f69c47d4c1b822e |
| tree | 24b0aa4cc7ec89c1e6402e58b854b41a68b1ec92 |
| parent | 05454123d45ca9a5fc4578d4ebffec9b158cf089 |
| signature |
3 files changed, 12 insertions(+), 1 deletions(-)
src/codegen.cpp+1-1| ... | ... | @@ -2216,7 +2216,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_ |
| 2216 | 2216 | assert(handle_is_ptr(ty)); |
| 2217 | 2217 | switch (fn_walk->id) { |
| 2218 | 2218 | case FnWalkIdAttrs: |
| 2219 | addLLVMArgAttr(llvm_fn, fn_walk->data.attrs.gen_i, "byval"); | |
| 2219 | ZigLLVMAddByValAttr(llvm_fn, fn_walk->data.attrs.gen_i + 1, get_llvm_type(g, ty)); | |
| 2220 | 2220 | addLLVMArgAttrInt(llvm_fn, fn_walk->data.attrs.gen_i, "align", get_abi_alignment(g, ty)); |
| 2221 | 2221 | // Byvalue parameters must not have address 0 |
| 2222 | 2222 | addLLVMArgAttr(llvm_fn, fn_walk->data.attrs.gen_i, "nonnull"); |
src/zig_llvm.cpp+10| ... | ... | @@ -723,6 +723,16 @@ void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) { |
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val) { | |
| 727 | Function *func = unwrap<Function>(fn_ref); | |
| 728 | const AttributeList attr_set = func->getAttributes(); | |
| 729 | AttrBuilder attr_builder; | |
| 730 | Type *llvm_type = unwrap<Type>(type_val); | |
| 731 | attr_builder.addByValAttr(llvm_type); | |
| 732 | const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), ArgNo, attr_builder); | |
| 733 | func->setAttributes(new_attr_set); | |
| 734 | } | |
| 735 | ||
| 726 | 736 | void ZigLLVMAddFunctionAttr(LLVMValueRef fn_ref, const char *attr_name, const char *attr_value) { |
| 727 | 737 | Function *func = unwrap<Function>(fn_ref); |
| 728 | 738 | const AttributeList attr_set = func->getAttributes(); |
src/zig_llvm.h+1| ... | ... | @@ -213,6 +213,7 @@ ZIG_EXTERN_C struct ZigLLVMDILocation *ZigLLVMGetDebugLoc(unsigned line, unsigne |
| 213 | 213 | ZIG_EXTERN_C void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); |
| 214 | 214 | |
| 215 | 215 | ZIG_EXTERN_C void ZigLLVMAddFunctionAttr(LLVMValueRef fn, const char *attr_name, const char *attr_value); |
| 216 | ZIG_EXTERN_C void ZigLLVMAddByValAttr(LLVMValueRef fn_ref, unsigned ArgNo, LLVMTypeRef type_val); | |
| 216 | 217 | ZIG_EXTERN_C void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn); |
| 217 | 218 | |
| 218 | 219 | ZIG_EXTERN_C void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv); |