| ... | ... | @@ -673,6 +673,7 @@ pub const Object = struct { |
| 673 | 673 | ) !void { |
| 674 | 674 | const decl_index = func.owner_decl; |
| 675 | 675 | const decl = module.declPtr(decl_index); |
| 676 | const target = module.getTarget(); |
| 676 | 677 | |
| 677 | 678 | var dg: DeclGen = .{ |
| 678 | 679 | .context = o.context, |
| ... | ... | @@ -706,6 +707,17 @@ pub const Object = struct { |
| 706 | 707 | DeclGen.removeFnAttr(llvm_func, "noinline"); |
| 707 | 708 | } |
| 708 | 709 | |
| 710 | // TODO: port these over from stage1 |
| 711 | // addLLVMFnAttr(llvm_fn, "sspstrong"); |
| 712 | // addLLVMFnAttrStr(llvm_fn, "stack-protector-buffer-size", "4"); |
| 713 | |
| 714 | // TODO: disable this if safety is off for the function scope |
| 715 | if (module.comp.bin_file.options.stack_check) { |
| 716 | dg.addFnAttrString(llvm_func, "probe-stack", "__zig_probe_stack"); |
| 717 | } else if (target.os.tag == .uefi) { |
| 718 | dg.addFnAttrString(llvm_func, "no-stack-arg-probe", ""); |
| 719 | } |
| 720 | |
| 709 | 721 | // Remove all the basic blocks of a function in order to start over, generating |
| 710 | 722 | // LLVM IR from an empty function body. |
| 711 | 723 | while (llvm_func.getFirstBasicBlock()) |bb| { |
| ... | ... | @@ -719,7 +731,6 @@ pub const Object = struct { |
| 719 | 731 | |
| 720 | 732 | // This gets the LLVM values from the function and stores them in `dg.args`. |
| 721 | 733 | const fn_info = decl.ty.fnInfo(); |
| 722 | | const target = dg.module.getTarget(); |
| 723 | 734 | const sret = firstParamSRet(fn_info, target); |
| 724 | 735 | const ret_ptr = if (sret) llvm_func.getParam(0) else null; |
| 725 | 736 | const gpa = dg.gpa; |
| ... | ... | @@ -730,7 +741,7 @@ pub const Object = struct { |
| 730 | 741 | }; |
| 731 | 742 | |
| 732 | 743 | const err_return_tracing = fn_info.return_type.isError() and |
| 733 | | dg.module.comp.bin_file.options.error_return_tracing; |
| 744 | module.comp.bin_file.options.error_return_tracing; |
| 734 | 745 | |
| 735 | 746 | const err_ret_trace = if (err_return_tracing) |
| 736 | 747 | llvm_func.getParam(@boolToInt(ret_ptr != null)) |
| ... | ... | @@ -920,7 +931,7 @@ pub const Object = struct { |
| 920 | 931 | |
| 921 | 932 | const line_number = decl.src_line + 1; |
| 922 | 933 | const is_internal_linkage = decl.val.tag() != .extern_fn and |
| 923 | | !dg.module.decl_exports.contains(decl_index); |
| 934 | !module.decl_exports.contains(decl_index); |
| 924 | 935 | const noret_bit: c_uint = if (fn_info.return_type.isNoReturn()) |
| 925 | 936 | llvm.DIFlags.NoReturn |
| 926 | 937 | else |
| ... | ... | @@ -936,7 +947,7 @@ pub const Object = struct { |
| 936 | 947 | true, // is definition |
| 937 | 948 | line_number + func.lbrace_line, // scope line |
| 938 | 949 | llvm.DIFlags.StaticMember | noret_bit, |
| 939 | | dg.module.comp.bin_file.options.optimize_mode != .Debug, |
| 950 | module.comp.bin_file.options.optimize_mode != .Debug, |
| 940 | 951 | null, // decl_subprogram |
| 941 | 952 | ); |
| 942 | 953 | try dg.object.di_map.put(gpa, decl, subprogram.toNode()); |