@@ -4639,6 +4639,10 @@ fn analyzeCall(
46394639 // comptime state.
46404640 var should_memoize = true;
46414641
4642+ var new_fn_info = module_fn.owner_decl.ty.fnInfo();
4643+ new_fn_info.param_types = try sema.arena.alloc(Type, new_fn_info.param_types.len);
4644+ new_fn_info.comptime_params = (try sema.arena.alloc(bool, new_fn_info.param_types.len)).ptr;
4645+
46424646 // This will have return instructions analyzed as break instructions to
46434647 // the block_inst above. Here we are performing "comptime/inline semantic analysis"
46444648 // for a function body, which means we must map the parameter ZIR instructions to
@@ -4658,6 +4662,7 @@ fn analyzeCall(
46584662 const param_body = sema.code.extra[extra.end..][0..extra.data.body_len];
46594663 const param_ty_inst = try sema.resolveBody(&child_block, param_body, inst);
46604664 const param_ty = try sema.analyzeAsType(&child_block, param_src, param_ty_inst);
4665+ new_fn_info.param_types[arg_i] = param_ty;
46614666 const arg_src = call_src; // TODO: better source location
46624667 const casted_arg = try sema.coerce(&child_block, param_ty, uncasted_args[arg_i], arg_src);
46634668 try sema.inst_map.putNoClobber(gpa, inst, casted_arg);
@@ -4685,6 +4690,7 @@ fn analyzeCall(
46854690 .param_anytype, .param_anytype_comptime => {
46864691 // No coercion needed.
46874692 const uncasted_arg = uncasted_args[arg_i];
4693+ new_fn_info.param_types[arg_i] = sema.typeOf(uncasted_arg);
46884694 try sema.inst_map.putNoClobber(gpa, inst, uncasted_arg);
46894695
46904696 if (is_comptime_call) {
@@ -4735,6 +4741,7 @@ fn analyzeCall(
47354741 }
47364742 break :blk bare_return_type;
47374743 };
4744+ new_fn_info.return_type = fn_ret_ty;
47384745 const parent_fn_ret_ty = sema.fn_ret_ty;
47394746 sema.fn_ret_ty = fn_ret_ty;
47404747 defer sema.fn_ret_ty = parent_fn_ret_ty;
@@ -4757,6 +4764,11 @@ fn analyzeCall(
47574764 }
47584765 }
47594766
4767+ const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);
4768+ if (!is_comptime_call) {
4769+ try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);
4770+ }
4771+
47604772 const result = result: {
47614773 sema.analyzeBody(&child_block, fn_info.body) catch |err| switch (err) {
47624774 error.ComptimeReturn => break :result inlining.comptime_result,
@@ -4771,6 +4783,10 @@ fn analyzeCall(
47714783 break :result try sema.analyzeBlockBody(block, call_src, &child_block, merges);
47724784 };
47734785
4786+ if (!is_comptime_call) {
4787+ try sema.emitDbgInline(block, module_fn, parent_func.?, parent_func.?.owner_decl.ty, .dbg_inline_end);
4788+ }
4789+
47744790 if (should_memoize and is_comptime_call) {
47754791 const result_val = try sema.resolveConstMaybeUndefVal(block, call_src, result);
47764792
@@ -5175,6 +5191,27 @@ fn instantiateGenericCall(
51755191 return func_inst;
51765192}
51775193
5194+ fn emitDbgInline(
5195+ sema: *Sema,
5196+ block: *Block,
5197+ old_func: *Module.Fn,
5198+ new_func: *Module.Fn,
5199+ new_func_ty: Type,
5200+ tag: Air.Inst.Tag,
5201+ ) CompileError!void {
5202+ // No change of file; no dbg_inline needed.
5203+ if (old_func == new_func) return;
5204+
5205+ try sema.air_values.append(sema.gpa, try Value.Tag.function.create(sema.arena, new_func));
5206+ _ = try block.addInst(.{
5207+ .tag = tag,
5208+ .data = .{ .ty_pl = .{
5209+ .ty = try sema.addType(new_func_ty),
5210+ .payload = @intCast(u32, sema.air_values.items.len - 1),
5211+ } },
5212+ });
5213+ }
5214+
51785215fn zirIntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
51795216 _ = block;
51805217 const tracy = trace(@src());
0 commit comments