authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-01 22:40:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-01 22:41:45-07:00
logaa79cc10aa38c2c3641d5a430aa33b8bfa6a3d61
tree48d3f28f52cc551d895a454c140146f4c26eab1a
parentbc2aaf18c86007ffb997513a57af29692777002f

fix bugs from previous two commits


2 files changed, 87 insertions(+), 69 deletions(-)

src/codegen/llvm.zig+18-18
......@@ -4622,7 +4622,7 @@ pub const FuncGen = struct {
46224622 const operand = try self.resolveInst(un_op);
46234623 const llvm_fn = try self.getCmpLtErrorsLenFunction();
46244624 const args: [1]*const llvm.Value = .{operand};
4625 return self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &args, args.len, .Fast, .Auto, "");
4625 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
46264626 }
46274627
46284628 fn cmp(
......@@ -5058,7 +5058,7 @@ pub const FuncGen = struct {
50585058 const libc_fn = self.getLibcFunction(fn_name, &param_types, dest_llvm_ty);
50595059 const params = [1]*const llvm.Value{extended};
50605060
5061 return self.builder.buildCall(libc_fn.typeOf(), libc_fn, &params, params.len, .C, .Auto, "");
5061 return self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
50625062 }
50635063
50645064 fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*const llvm.Value {
......@@ -5113,7 +5113,7 @@ pub const FuncGen = struct {
51135113 const libc_fn = self.getLibcFunction(fn_name, &param_types, libc_ret_ty);
51145114 const params = [1]*const llvm.Value{operand};
51155115
5116 var result = self.builder.buildCall(libc_fn.typeOf(), libc_fn, &params, params.len, .C, .Auto, "");
5116 var result = self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
51175117
51185118 if (libc_ret_ty != ret_ty) result = self.builder.buildBitCast(result, ret_ty, "");
51195119 if (ret_ty != dest_llvm_ty) result = self.builder.buildTrunc(result, dest_llvm_ty, "");
......@@ -6241,7 +6241,7 @@ pub const FuncGen = struct {
62416241 const llvm_u32 = self.context.intType(32);
62426242 const llvm_fn = self.getIntrinsic("llvm.wasm.memory.size", &.{llvm_u32});
62436243 const args: [1]*const llvm.Value = .{llvm_u32.constInt(index, .False)};
6244 return self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &args, args.len, .Fast, .Auto, "");
6244 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
62456245 }
62466246
62476247 fn airWasmMemoryGrow(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
......@@ -6254,7 +6254,7 @@ pub const FuncGen = struct {
62546254 llvm_u32.constInt(index, .False),
62556255 operand,
62566256 };
6257 return self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &args, args.len, .Fast, .Auto, "");
6257 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .Fast, .Auto, "");
62586258 }
62596259
62606260 fn airMin(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
......@@ -6619,7 +6619,7 @@ pub const FuncGen = struct {
66196619 const tg = self.dg.module.getTarget();
66206620
66216621 const llvm_fn = self.getIntrinsic(intrinsic_name, &.{llvm_lhs_ty});
6622 const result_struct = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &[_]*const llvm.Value{ lhs, rhs }, 2, .Fast, .Auto, "");
6622 const result_struct = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &[_]*const llvm.Value{ lhs, rhs }, 2, .Fast, .Auto, "");
66236623
66246624 const result = self.builder.buildExtractValue(result_struct, 0, "");
66256625 const overflow_bit = self.builder.buildExtractValue(result_struct, 1, "");
......@@ -6671,7 +6671,7 @@ pub const FuncGen = struct {
66716671 for (args_vectors) |arg_vector, k| {
66726672 args[k] = self.builder.buildExtractElement(arg_vector, index_i32, "");
66736673 }
6674 const result_elem = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &args, args_len, .C, .Auto, "");
6674 const result_elem = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args_len, .C, .Auto, "");
66756675 result = self.builder.buildInsertElement(result, result_elem, index_i32, "");
66766676 }
66776677 return result;
......@@ -6798,7 +6798,7 @@ pub const FuncGen = struct {
67986798 return self.builder.buildICmp(int_pred, result, zero_vector, "");
67996799 }
68006800
6801 const result = self.builder.buildCall(libc_fn.typeOf(), libc_fn, &params, params.len, .C, .Auto, "");
6801 const result = self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
68026802 return self.builder.buildICmp(int_pred, result, zero, "");
68036803 }
68046804
......@@ -6926,7 +6926,7 @@ pub const FuncGen = struct {
69266926 break :b libc_fn;
69276927 },
69286928 };
6929 return self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &params, params_len, .C, .Auto, "");
6929 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params_len, .C, .Auto, "");
69306930 }
69316931
69326932 fn airMulAdd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
......@@ -7537,7 +7537,7 @@ pub const FuncGen = struct {
75377537 fn airBreakpoint(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
75387538 _ = inst;
75397539 const llvm_fn = self.getIntrinsic("llvm.debugtrap", &.{});
7540 _ = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, undefined, 0, .C, .Auto, "");
7540 _ = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, undefined, 0, .C, .Auto, "");
75417541 return null;
75427542 }
75437543
......@@ -7554,7 +7554,7 @@ pub const FuncGen = struct {
75547554 const llvm_i32 = self.context.intType(32);
75557555 const llvm_fn = self.getIntrinsic("llvm.returnaddress", &.{});
75567556 const params = [_]*const llvm.Value{llvm_i32.constNull()};
7557 const ptr_val = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &params, params.len, .Fast, .Auto, "");
7557 const ptr_val = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
75587558 return self.builder.buildPtrToInt(ptr_val, llvm_usize, "");
75597559 }
75607560
......@@ -7571,7 +7571,7 @@ pub const FuncGen = struct {
75717571 };
75727572
75737573 const params = [_]*const llvm.Value{llvm_i32.constNull()};
7574 const ptr_val = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &params, params.len, .Fast, .Auto, "");
7574 const ptr_val = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
75757575 const llvm_usize = try self.dg.lowerType(Type.usize);
75767576 return self.builder.buildPtrToInt(ptr_val, llvm_usize, "");
75777577 }
......@@ -7863,7 +7863,7 @@ pub const FuncGen = struct {
78637863 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
78647864
78657865 const params = [_]*const llvm.Value{ operand, llvm_i1.constNull() };
7866 const wrong_size_result = self.builder.buildCall(fn_val.typeOf(), fn_val, &params, params.len, .C, .Auto, "");
7866 const wrong_size_result = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
78677867 const result_ty = self.air.typeOfIndex(inst);
78687868 const result_llvm_ty = try self.dg.lowerType(result_ty);
78697869
......@@ -7890,7 +7890,7 @@ pub const FuncGen = struct {
78907890 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
78917891 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
78927892
7893 const wrong_size_result = self.builder.buildCall(fn_val.typeOf(), fn_val, &params, params.len, .C, .Auto, "");
7893 const wrong_size_result = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
78947894 const result_ty = self.air.typeOfIndex(inst);
78957895 const result_llvm_ty = try self.dg.lowerType(result_ty);
78967896
......@@ -7947,7 +7947,7 @@ pub const FuncGen = struct {
79477947 const params = [_]*const llvm.Value{operand};
79487948 const fn_val = self.getIntrinsic(llvm_fn_name, &.{operand_llvm_ty});
79497949
7950 const wrong_size_result = self.builder.buildCall(fn_val.typeOf(), fn_val, &params, params.len, .C, .Auto, "");
7950 const wrong_size_result = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
79517951
79527952 const result_ty = self.air.typeOfIndex(inst);
79537953 const result_llvm_ty = try self.dg.lowerType(result_ty);
......@@ -7970,7 +7970,7 @@ pub const FuncGen = struct {
79707970
79717971 const llvm_fn = try self.getEnumTagNameFunction(enum_ty);
79727972 const params = [_]*const llvm.Value{operand};
7973 return self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &params, params.len, .Fast, .Auto, "");
7973 return self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &params, params.len, .Fast, .Auto, "");
79747974 }
79757975
79767976 fn getEnumTagNameFunction(self: *FuncGen, enum_ty: Type) !*const llvm.Value {
......@@ -8526,7 +8526,7 @@ pub const FuncGen = struct {
85268526 llvm_u32.constInt(prefetch.locality, .False),
85278527 llvm_u32.constInt(@enumToInt(prefetch.cache), .False),
85288528 };
8529 _ = self.builder.buildCall(fn_val.typeOf(), fn_val, &params, params.len, .C, .Auto, "");
8529 _ = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
85308530 return null;
85318531 }
85328532
......@@ -8606,7 +8606,7 @@ pub const FuncGen = struct {
86068606 };
86078607
86088608 var args: [1]*const llvm.Value = .{arg};
8609 const result = self.builder.buildCall(llvm_fn.typeOf(), llvm_fn, &args, args.len, .C, .Auto, "");
8609 const result = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, &args, args.len, .C, .Auto, "");
86108610 const final_cast_llvm_ty = final_cast orelse return result;
86118611 return self.builder.buildBitCast(result, final_cast_llvm_ty, "");
86128612 }
src/stage1/codegen.cpp+69-51
......@@ -1092,7 +1092,7 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace
10921092 msg_arg,
10931093 stack_trace_arg,
10941094 };
1095 ZigLLVMBuildCall(g->builder, LLVMTypeOf(fn_val), fn_val, args, 2, llvm_cc, ZigLLVM_CallAttrAuto, "");
1095 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, args, 2, llvm_cc, ZigLLVM_CallAttrAuto, "");
10961096 if (!stack_trace_is_llvm_alloca) {
10971097 // The stack trace argument is not in the stack of the caller, so
10981098 // we'd like to set tail call here, but because slices (the type of msg_arg) are
......@@ -1369,7 +1369,7 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {
13691369
13701370 LLVMPositionBuilderAtEnd(g->builder, dest_non_null_block);
13711371 LLVMValueRef args[] = { err_ret_trace_ptr, return_address };
1372 ZigLLVMBuildCall(g->builder, LLVMTypeOf(add_error_return_trace_addr_fn_val),
1372 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(add_error_return_trace_addr_fn_val),
13731373 add_error_return_trace_addr_fn_val, args, 2,
13741374 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAlwaysInline, "");
13751375 LLVMBuildRetVoid(g->builder);
......@@ -1546,14 +1546,14 @@ static void gen_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val, Scope *sc
15461546 err_ret_trace_val,
15471547 err_val,
15481548 };
1549 call_instruction = ZigLLVMBuildCall(g->builder, LLVMTypeOf(safety_crash_err_fn),
1549 call_instruction = ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(safety_crash_err_fn),
15501550 safety_crash_err_fn, args, 2,
15511551 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
15521552 } else {
15531553 LLVMValueRef args[] = {
15541554 err_val,
15551555 };
1556 call_instruction = ZigLLVMBuildCall(g->builder, LLVMTypeOf(safety_crash_err_fn),
1556 call_instruction = ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(safety_crash_err_fn),
15571557 safety_crash_err_fn, args, 1,
15581558 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
15591559 }
......@@ -1732,7 +1732,7 @@ static LLVMValueRef gen_soft_float_widen_or_shorten(CodeGen *g, ZigType *actual_
17321732 func_ref = LLVMAddFunction(g->module, fn_name, fn_type);
17331733 }
17341734
1735 result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, &expr_val, 1, "");
1735 result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, &expr_val, 1, "");
17361736
17371737 // On non-Arm platforms we need to bitcast __trunc<>fhf2 result back to f16
17381738 if (castTruncatedToF16) {
......@@ -1878,7 +1878,7 @@ static LLVMValueRef gen_overflow_op(CodeGen *g, ZigType *operand_type, AddSubMul
18781878 val1,
18791879 val2,
18801880 };
1881 LLVMValueRef result_struct = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, params, 2, "");
1881 LLVMValueRef result_struct = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, params, 2, "");
18821882 LLVMValueRef result = LLVMBuildExtractValue(g->builder, result_struct, 0, "");
18831883 LLVMValueRef overflow_bit = LLVMBuildExtractValue(g->builder, result_struct, 1, "");
18841884 if (operand_type->id == ZigTypeIdVector) {
......@@ -2663,7 +2663,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
26632663 LLVMValueRef this_addr_val = LLVMBuildLoad2(g->builder, LLVMGetGEPSourceElementType(addr_ptr),
26642664 addr_ptr, "");
26652665 LLVMValueRef args[] = {dest_stack_trace_ptr, this_addr_val};
2666 ZigLLVMBuildCall(g->builder, LLVMTypeOf(add_error_return_trace_addr_fn_val),
2666 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(add_error_return_trace_addr_fn_val),
26672667 add_error_return_trace_addr_fn_val, args, 2, get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAlwaysInline, "");
26682668 LLVMValueRef prev_frames_left = LLVMBuildLoad2(g->builder, usize_type_ref, frames_left_ptr, "");
26692669 LLVMValueRef new_frames_left = LLVMBuildNUWSub(g->builder, prev_frames_left, usize_one, "");
......@@ -2703,7 +2703,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executabl
27032703 bool is_llvm_alloca;
27042704 LLVMValueRef my_err_trace_val = get_cur_err_ret_trace_val(g, save_err_ret_addr_instruction->base.scope,
27052705 &is_llvm_alloca);
2706 ZigLLVMBuildCall(g->builder, LLVMTypeOf(return_err_fn), return_err_fn, &my_err_trace_val, 1,
2706 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(return_err_fn), return_err_fn, &my_err_trace_val, 1,
27072707 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
27082708
27092709 ZigType *ret_type = g->cur_fn->type_entry->data.fn.fn_type_id.return_type;
......@@ -2753,7 +2753,7 @@ static LLVMValueRef gen_resume(CodeGen *g, LLVMValueRef fn_val, LLVMValueRef tar
27532753 LLVMValueRef arg_val = LLVMConstSub(LLVMConstAllOnes(usize_type_ref),
27542754 LLVMConstInt(usize_type_ref, resume_id, false));
27552755 LLVMValueRef args[] = {target_frame_ptr, arg_val};
2756 return ZigLLVMBuildCall(g->builder, LLVMTypeOf(fn_val), fn_val, args, 2, ZigLLVM_Fast, ZigLLVM_CallAttrAuto, "");
2756 return ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, args, 2, ZigLLVM_Fast, ZigLLVM_CallAttrAuto, "");
27572757}
27582758
27592759static LLVMBasicBlockRef gen_suspend_begin(CodeGen *g, const char *name_hint) {
......@@ -2885,7 +2885,7 @@ static void gen_async_return(CodeGen *g, Stage1AirInstReturn *instruction) {
28852885 bool is_llvm_alloca;
28862886 LLVMValueRef my_err_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope, &is_llvm_alloca);
28872887 LLVMValueRef args[] = { dest_trace_ptr, my_err_trace_val };
2888 ZigLLVMBuildCall(g->builder, LLVMTypeOf(get_merge_err_ret_traces_fn_val(g)),
2888 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(get_merge_err_ret_traces_fn_val(g)),
28892889 get_merge_err_ret_traces_fn_val(g), args, 2,
28902890 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
28912891 }
......@@ -3057,14 +3057,14 @@ static LLVMValueRef gen_soft_float_un_op(CodeGen *g, LLVMValueRef op, ZigType *o
30573057 LLVMValueRef func_ref = get_soft_float_fn(g, fn_name, 1, scalar_type->llvm_type, scalar_type->llvm_type);
30583058
30593059 if (vector_len == 0) {
3060 return LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, &op, 1, "");
3060 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, &op, 1, "");
30613061 } else {
30623062 LLVMValueRef result = LLVMGetUndef(operand_type->llvm_type);
30633063 LLVMTypeRef usize_ref = g->builtin_types.entry_usize->llvm_type;
30643064 for (uint32_t i = 0; i < vector_len; i++) {
30653065 LLVMValueRef index_value = LLVMConstInt(usize_ref, i, false);
30663066 LLVMValueRef param = LLVMBuildExtractElement(g->builder, op, index_value, "");
3067 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, &param, 1, "");
3067 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, &param, 1, "");
30683068 result = LLVMBuildInsertElement(g->builder, result, call_result, index_value, "");
30693069 }
30703070 return result;
......@@ -3081,7 +3081,7 @@ static LLVMValueRef gen_float_un_op(CodeGen *g, LLVMValueRef operand, ZigType *o
30813081 return gen_soft_float_un_op(g, operand, operand_type, op);
30823082 }
30833083 LLVMValueRef float_op_fn = get_float_fn(g, operand_type, ZigLLVMFnIdFloatOp, op);
3084 return LLVMBuildCall2(g->builder, LLVMTypeOf(float_op_fn), float_op_fn, &operand, 1, "");
3084 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(float_op_fn), float_op_fn, &operand, 1, "");
30853085}
30863086
30873087enum DivKind {
......@@ -3447,7 +3447,7 @@ static LLVMValueRef gen_soft_int_to_float_op(CodeGen *g, LLVMValueRef value_ref,
34473447 }
34483448
34493449 LLVMValueRef params[1] = {value_ref};
3450 return LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, param_count, "");
3450 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, param_count, "");
34513451}
34523452
34533453static LLVMValueRef gen_soft_float_to_int_op(CodeGen *g, LLVMValueRef value_ref, ZigType *operand_type, ZigType *result_type) {
......@@ -3483,7 +3483,7 @@ static LLVMValueRef gen_soft_float_to_int_op(CodeGen *g, LLVMValueRef value_ref,
34833483 }
34843484
34853485 LLVMValueRef params[1] = {value_ref};
3486 LLVMValueRef result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, param_count, "");
3486 LLVMValueRef result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, param_count, "");
34873487
34883488 if ((wider_type->data.integral.bit_count == 128) && (g->zig_target->os == OsWindows) && (g->zig_target->arch == ZigLLVM_x86_64)) {
34893489 result = LLVMBuildBitCast(g->builder, result, wider_type->llvm_type, "");
......@@ -3596,7 +3596,7 @@ static LLVMValueRef gen_soft_float_bin_op(CodeGen *g, LLVMValueRef op1_value, LL
35963596 LLVMValueRef result;
35973597 if (vector_len == 0) {
35983598 LLVMValueRef params[2] = {op1_value, op2_value};
3599 result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, param_count, "");
3599 result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, param_count, "");
36003600 result = add_icmp(g, result, res_icmp);
36013601 } else {
36023602 ZigType *alloca_ty = operand_type;
......@@ -3610,7 +3610,7 @@ static LLVMValueRef gen_soft_float_bin_op(CodeGen *g, LLVMValueRef op1_value, LL
36103610 LLVMBuildExtractElement(g->builder, op1_value, index_value, ""),
36113611 LLVMBuildExtractElement(g->builder, op2_value, index_value, ""),
36123612 };
3613 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, param_count, "");
3613 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, param_count, "");
36143614 call_result = add_icmp(g, call_result, res_icmp);
36153615 result = LLVMBuildInsertElement(g->builder, result, call_result, index_value, "");
36163616 }
......@@ -4585,7 +4585,7 @@ static LLVMValueRef gen_valgrind_client_request(CodeGen *g, LLVMValueRef default
45854585 LLVMValueRef asm_fn = LLVMGetInlineAsm(function_type, buf_ptr(asm_template), buf_len(asm_template),
45864586 buf_ptr(asm_constraints), buf_len(asm_constraints), asm_has_side_effects, asm_is_alignstack,
45874587 LLVMInlineAsmDialectATT, false);
4588 return LLVMBuildCall2(g->builder, LLVMTypeOf(asm_fn), asm_fn, param_values, input_and_output_count, "");
4588 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(asm_fn), asm_fn, param_values, input_and_output_count, "");
45894589 }
45904590 }
45914591 zig_unreachable();
......@@ -4849,7 +4849,7 @@ static void gen_set_stack_pointer(CodeGen *g, LLVMValueRef aligned_end_addr) {
48494849 aligned_end_addr,
48504850 };
48514851
4852 LLVMBuildCall2(g->builder, LLVMTypeOf(write_register_fn_val), write_register_fn_val, params, 2, "");
4852 LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(write_register_fn_val), write_register_fn_val, params, 2, "");
48534853}
48544854
48554855static void render_async_spills(CodeGen *g) {
......@@ -4996,10 +4996,6 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
49964996 callee_is_async = fn_type->data.fn.fn_type_id.cc == CallingConventionAsync;
49974997 }
49984998
4999 LLVMTypeRef frame_struct_llvm_ty = (instruction->fn_entry != nullptr) ?
5000 get_llvm_type(g, get_fn_frame_type(g, instruction->fn_entry)) :
5001 g->any_frame_header_llvm_ty;
5002
50034999 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
50045000
50055001 ZigType *src_return_type = fn_type_id->return_type;
......@@ -5018,23 +5014,33 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
50185014 ZigType *anyframe_type = nullptr;
50195015 LLVMValueRef frame_result_loc_uncasted = nullptr;
50205016 LLVMValueRef frame_result_loc;
5017 LLVMTypeRef frame_struct_llvm_ty;
50215018 LLVMValueRef awaiter_init_val;
50225019 LLVMValueRef ret_ptr;
50235020 if (callee_is_async) {
50245021 if (instruction->new_stack == nullptr) {
50255022 if (instruction->modifier == CallModifierAsync) {
50265023 frame_result_loc = result_loc;
5024 if (result_loc != nullptr) {
5025 ir_assert(instruction->result_loc->value->type->id == ZigTypeIdPointer, &instruction->base);
5026 frame_struct_llvm_ty = get_llvm_type(g, instruction->result_loc->value->type->data.pointer.child_type);
5027 } else {
5028 frame_struct_llvm_ty = nullptr;
5029 }
50275030 } else {
50285031 ir_assert(instruction->frame_result_loc != nullptr, &instruction->base);
50295032 frame_result_loc_uncasted = ir_llvm_value(g, instruction->frame_result_loc);
50305033 ir_assert(instruction->fn_entry != nullptr, &instruction->base);
5031 frame_result_loc = frame_result_loc_uncasted;
5034 frame_struct_llvm_ty = get_llvm_type(g, instruction->fn_entry->frame_type);
5035 frame_result_loc = LLVMBuildBitCast(g->builder, frame_result_loc_uncasted,
5036 LLVMPointerType(frame_struct_llvm_ty, 0), "");
50325037 }
50335038 } else {
50345039 if (instruction->new_stack->value->type->id == ZigTypeIdPointer &&
50355040 instruction->new_stack->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
50365041 {
50375042 frame_result_loc = ir_llvm_value(g, instruction->new_stack);
5043 frame_struct_llvm_ty = get_llvm_type(g, instruction->new_stack->value->type->data.pointer.child_type);
50385044 } else {
50395045 LLVMValueRef frame_slice_ptr = ir_llvm_value(g, instruction->new_stack);
50405046 LLVMTypeRef frame_slice_llvm_ty =
......@@ -5063,12 +5069,16 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
50635069 LLVMGetGEPSourceElementType(frame_ptr_ptr), frame_ptr_ptr, "");
50645070 if (instruction->fn_entry == nullptr) {
50655071 anyframe_type = get_any_frame_type(g, src_return_type);
5066 frame_result_loc = frame_ptr;
5072 frame_result_loc = LLVMBuildBitCast(g->builder, frame_ptr, get_llvm_type(g, anyframe_type), "");
5073 frame_struct_llvm_ty = g->any_frame_header_llvm_ty;
50675074 } else {
50685075 ZigType *frame_type = get_fn_frame_type(g, instruction->fn_entry);
50695076 if ((err = type_resolve(g, frame_type, ResolveStatusLLVMFull)))
50705077 codegen_report_errors_and_exit(g);
5071 frame_result_loc = frame_ptr;
5078 ZigType *ptr_frame_type = get_pointer_to_type(g, frame_type, false);
5079 frame_result_loc = LLVMBuildBitCast(g->builder, frame_ptr,
5080 get_llvm_type(g, ptr_frame_type), "");
5081 frame_struct_llvm_ty = get_llvm_type(g, frame_type);
50725082 }
50735083 }
50745084 }
......@@ -5156,6 +5166,12 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
51565166 zig_panic("TODO @asyncCall of non-async function");
51575167 }
51585168 frame_result_loc = result_loc;
5169 if (result_loc != nullptr) {
5170 ir_assert(instruction->result_loc->value->type->id == ZigTypeIdPointer, &instruction->base);
5171 frame_struct_llvm_ty = get_llvm_type(g, instruction->result_loc->value->type->data.pointer.child_type);
5172 } else {
5173 frame_struct_llvm_ty = nullptr;
5174 }
51595175 awaiter_init_val = LLVMConstAllOnes(usize_type_ref);
51605176
51615177 LLVMValueRef awaiter_ptr = LLVMBuildStructGEP2(g->builder, frame_struct_llvm_ty, frame_result_loc, frame_awaiter_index, "");
......@@ -5352,11 +5368,13 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
53525368 }
53535369 if (frame_result_loc_uncasted != nullptr) {
53545370 if (instruction->fn_entry != nullptr) {
5371 frame_struct_llvm_ty = get_llvm_type(g, instruction->fn_entry->frame_type);
53555372 frame_result_loc = LLVMBuildBitCast(g->builder, frame_result_loc_uncasted,
5356 LLVMPointerType(get_llvm_type(g, instruction->fn_entry->frame_type), 0), "");
5373 LLVMPointerType(frame_struct_llvm_ty, 0), "");
53575374 } else {
53585375 frame_result_loc = LLVMBuildBitCast(g->builder, frame_result_loc_uncasted,
53595376 get_llvm_type(g, anyframe_type), "");
5377 frame_struct_llvm_ty = g->any_frame_header_llvm_ty;
53605378 }
53615379 }
53625380
......@@ -5369,7 +5387,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
53695387 }
53705388
53715389 if (instruction->new_stack == nullptr || instruction->is_async_call_builtin) {
5372 result = ZigLLVMBuildCall(g->builder, LLVMTypeOf(fn_val), fn_val,
5390 result = ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val,
53735391 gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, call_attr, "");
53745392 } else if (instruction->modifier == CallModifierAsync) {
53755393 zig_panic("TODO @asyncCall of non-async function");
......@@ -5380,14 +5398,14 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirI
53805398 LLVMValueRef old_stack_ref;
53815399 if (src_return_type->id != ZigTypeIdUnreachable) {
53825400 LLVMValueRef stacksave_fn_val = get_stacksave_fn_val(g);
5383 old_stack_ref = LLVMBuildCall2(g->builder, LLVMTypeOf(stacksave_fn_val), stacksave_fn_val, nullptr, 0, "");
5401 old_stack_ref = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(stacksave_fn_val), stacksave_fn_val, nullptr, 0, "");
53845402 }
53855403 gen_set_stack_pointer(g, new_stack_addr);
5386 result = ZigLLVMBuildCall(g->builder, LLVMTypeOf(fn_val), fn_val,
5404 result = ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val,
53875405 gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, call_attr, "");
53885406 if (src_return_type->id != ZigTypeIdUnreachable) {
53895407 LLVMValueRef stackrestore_fn_val = get_stackrestore_fn_val(g);
5390 LLVMBuildCall2(g->builder, LLVMTypeOf(stackrestore_fn_val), stackrestore_fn_val, &old_stack_ref, 1, "");
5408 LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(stackrestore_fn_val), stackrestore_fn_val, &old_stack_ref, 1, "");
53915409 }
53925410 }
53935411
......@@ -5735,7 +5753,7 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, Stage1A
57355753 LLVMValueRef asm_fn = LLVMGetInlineAsm(function_type, buf_ptr(&llvm_template), buf_len(&llvm_template),
57365754 buf_ptr(&constraint_buf), buf_len(&constraint_buf), is_volatile, false, LLVMInlineAsmDialectATT, false);
57375755
5738 LLVMValueRef built_call = LLVMBuildCall2(g->builder, LLVMTypeOf(asm_fn), asm_fn, param_values, (unsigned)input_and_output_count, "");
5756 LLVMValueRef built_call = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(asm_fn), asm_fn, param_values, (unsigned)input_and_output_count, "");
57395757
57405758 for (size_t i = 0; i < input_and_output_count; i += 1) {
57415759 if (param_needs_attr[i]) {
......@@ -5895,7 +5913,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, Stage1AirIn
58955913 operand,
58965914 LLVMConstNull(LLVMInt1Type()),
58975915 };
5898 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, params, 2, "");
5916 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, params, 2, "");
58995917 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
59005918}
59015919
......@@ -5907,7 +5925,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, Stage1AirIn
59075925 operand,
59085926 LLVMConstNull(LLVMInt1Type()),
59095927 };
5910 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, params, 2, "");
5928 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, params, 2, "");
59115929 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
59125930}
59135931
......@@ -5964,7 +5982,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, Stage
59645982 ZigType *int_type = instruction->op->value->type;
59655983 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
59665984 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
5967 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, &operand, 1, "");
5985 LLVMValueRef wrong_size_int = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, &operand, 1, "");
59685986 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
59695987}
59705988
......@@ -6180,7 +6198,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, Stage1Air *executable,
61806198 LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type);
61816199
61826200 LLVMValueRef enum_tag_value = ir_llvm_value(g, instruction->target);
6183 return ZigLLVMBuildCall(g->builder, LLVMTypeOf(enum_name_function), enum_name_function,
6201 return ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(enum_name_function), enum_name_function,
61846202 &enum_tag_value, 1,
61856203 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
61866204}
......@@ -6557,7 +6575,7 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, Stage1Ai
65576575static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, Stage1Air *executable, Stage1AirInstWasmMemorySize *instruction) {
65586576 // TODO adjust for wasm64
65596577 LLVMValueRef param = ir_llvm_value(g, instruction->index);
6560 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMTypeOf(gen_wasm_memory_size(g)), gen_wasm_memory_size(g), &param, 1, "");
6578 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(gen_wasm_memory_size(g)), gen_wasm_memory_size(g), &param, 1, "");
65616579 return val;
65626580}
65636581
......@@ -6567,7 +6585,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable
65676585 ir_llvm_value(g, instruction->index),
65686586 ir_llvm_value(g, instruction->delta),
65696587 };
6570 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMTypeOf(gen_wasm_memory_grow(g)), gen_wasm_memory_grow(g), params, 2, "");
6588 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(gen_wasm_memory_grow(g)), gen_wasm_memory_grow(g), params, 2, "");
65716589 return val;
65726590}
65736591
......@@ -6613,7 +6631,7 @@ static LLVMValueRef ir_render_prefetch(CodeGen *g, Stage1Air *executable, Stage1
66136631 LLVMConstInt(LLVMInt32Type(), instruction->locality, false),
66146632 LLVMConstInt(LLVMInt32Type(), instruction->cache, false),
66156633 };
6616 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMTypeOf(gen_prefetch(g)), gen_prefetch(g), params, 4, "");
6634 LLVMValueRef val = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(gen_prefetch(g)), gen_prefetch(g), params, 4, "");
66176635 return val;
66186636}
66196637
......@@ -6868,7 +6886,7 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) {
68686886
68696887
68706888static LLVMValueRef ir_render_breakpoint(CodeGen *g, Stage1Air *executable, Stage1AirInstBreakpoint *instruction) {
6871 LLVMBuildCall2(g->builder, LLVMTypeOf(get_trap_fn_val(g)), get_trap_fn_val(g), nullptr, 0, "");
6889 LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(get_trap_fn_val(g)), get_trap_fn_val(g), nullptr, 0, "");
68726890 return nullptr;
68736891}
68746892
......@@ -6882,7 +6900,7 @@ static LLVMValueRef ir_render_return_address(CodeGen *g, Stage1Air *executable,
68826900 }
68836901
68846902 LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type);
6885 LLVMValueRef ptr_val = LLVMBuildCall2(g->builder, LLVMTypeOf(get_return_address_fn_val(g)), get_return_address_fn_val(g), &zero, 1, "");
6903 LLVMValueRef ptr_val = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(get_return_address_fn_val(g)), get_return_address_fn_val(g), &zero, 1, "");
68866904 return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, "");
68876905}
68886906
......@@ -6904,7 +6922,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, Stage1Air *executable,
69046922 Stage1AirInstFrameAddress *instruction)
69056923{
69066924 LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type);
6907 LLVMValueRef ptr_val = LLVMBuildCall2(g->builder, LLVMTypeOf(get_frame_address_fn_val(g)), get_frame_address_fn_val(g), &zero, 1, "");
6925 LLVMValueRef ptr_val = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(get_frame_address_fn_val(g)), get_frame_address_fn_val(g), &zero, 1, "");
69086926 return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, "");
69096927}
69106928
......@@ -6967,7 +6985,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, Sta
69676985 op2,
69686986 };
69696987
6970 LLVMValueRef result_struct = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, params, 2, "");
6988 LLVMValueRef result_struct = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, params, 2, "");
69716989 LLVMValueRef result = LLVMBuildExtractValue(g->builder, result_struct, 0, "");
69726990 LLVMValueRef overflow_bit = LLVMBuildExtractValue(g->builder, result_struct, 1, "");
69736991 gen_store(g, result, ptr_result, instruction->result_ptr->value->type);
......@@ -7339,7 +7357,7 @@ static LLVMValueRef ir_render_soft_mul_add(CodeGen *g, Stage1Air *executable, St
73397357 LLVMValueRef op3 = ir_llvm_value(g, instruction->op3);
73407358 if (vector_len == 0) {
73417359 LLVMValueRef params[3] = { op1, op2, op3 };
7342 return LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, 3, "");
7360 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, 3, "");
73437361 }
73447362
73457363 LLVMValueRef result = LLVMGetUndef(get_llvm_type(g, instruction->op1->value->type));
......@@ -7352,7 +7370,7 @@ static LLVMValueRef ir_render_soft_mul_add(CodeGen *g, Stage1Air *executable, St
73527370 LLVMBuildExtractElement(g->builder, op2, index_value, ""),
73537371 LLVMBuildExtractElement(g->builder, op3, index_value, ""),
73547372 };
7355 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMTypeOf(func_ref), func_ref, params, 3, "");
7373 LLVMValueRef call_result = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(func_ref), func_ref, params, 3, "");
73567374 result = LLVMBuildInsertElement(g->builder, result, call_result, index_value, "");
73577375 }
73587376 return result;
......@@ -7372,7 +7390,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, Stage1A
73727390 instruction->base.value->type->id == ZigTypeIdVector);
73737391 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFMA, BuiltinFnIdMulAdd);
73747392 LLVMValueRef args[3] = { op1, op2, op3 };
7375 return LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, args, 3, "");
7393 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, args, 3, "");
73767394}
73777395
73787396static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, Stage1AirInstBswap *instruction) {
......@@ -7383,7 +7401,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, Stage1Air
73837401 assert(int_type->id == ZigTypeIdInt);
73847402 if (int_type->data.integral.bit_count % 16 == 0) {
73857403 LLVMValueRef fn_val = get_int_builtin_fn(g, expr_type, BuiltinFnIdBswap);
7386 return LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, &op, 1, "");
7404 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, &op, 1, "");
73877405 }
73887406 // Not an even number of bytes, so we zext 1 byte, then bswap, shift right 1 byte, truncate
73897407 ZigType *extended_type = get_int_type(g, int_type->data.integral.is_signed,
......@@ -7402,7 +7420,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, Stage1Air
74027420 LLVMValueRef extended = LLVMBuildZExt(g->builder, op, get_llvm_type(g, extended_type), "");
74037421 // 00aabbcc
74047422 LLVMValueRef fn_val = get_int_builtin_fn(g, extended_type, BuiltinFnIdBswap);
7405 LLVMValueRef swapped = LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, &extended, 1, "");
7423 LLVMValueRef swapped = LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, &extended, 1, "");
74067424 // ccbbaa00
74077425 LLVMValueRef shifted = ZigLLVMBuildLShrExact(g->builder, swapped, shift_amt, "");
74087426 // 00ccbbaa
......@@ -7438,7 +7456,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, Sta
74387456 ZigType *int_type = instruction->base.value->type;
74397457 assert(int_type->id == ZigTypeIdInt);
74407458 LLVMValueRef fn_val = get_int_builtin_fn(g, instruction->base.value->type, BuiltinFnIdBitReverse);
7441 return LLVMBuildCall2(g->builder, LLVMTypeOf(fn_val), fn_val, &op, 1, "");
7459 return LLVMBuildCall2(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, &op, 1, "");
74427460}
74437461
74447462static LLVMValueRef ir_render_vector_to_array(CodeGen *g, Stage1Air *executable,
......@@ -7603,7 +7621,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, Stage1AirInst *source_ins
76037621 bool is_llvm_alloca;
76047622 LLVMValueRef dest_trace_ptr = get_cur_err_ret_trace_val(g, source_instr->scope, &is_llvm_alloca);
76057623 LLVMValueRef args[] = { dest_trace_ptr, src_trace_ptr };
7606 ZigLLVMBuildCall(g->builder, LLVMTypeOf(get_merge_err_ret_traces_fn_val(g)),
7624 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(get_merge_err_ret_traces_fn_val(g)),
76077625 get_merge_err_ret_traces_fn_val(g), args, 2,
76087626 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
76097627 }
......@@ -9337,7 +9355,7 @@ static void do_code_gen(CodeGen *g) {
93379355 LLVMValueRef zero = LLVMConstNull(usize->llvm_type);
93389356 LLVMValueRef indices[] = {zero, zero};
93399357 LLVMValueRef err_ret_array_val_elem0_ptr = LLVMBuildInBoundsGEP2(g->builder,
9340 usize_type_ref, err_ret_array_val, indices, 2, "");
9358 LLVMGetAllocatedType(err_ret_array_val), err_ret_array_val, indices, 2, "");
93419359 ZigType *ptr_ptr_usize_type = get_pointer_to_type(g, get_pointer_to_type(g, usize, false), false);
93429360 gen_store(g, err_ret_array_val_elem0_ptr, ptr_field_ptr, ptr_ptr_usize_type);
93439361