| ... | ... | @@ -10282,11 +10282,11 @@ const GenZir = struct { |
| 10282 | 10282 | try astgen.extra.ensureUnusedCapacity( |
| 10283 | 10283 | gpa, |
| 10284 | 10284 | @typeInfo(Zir.Inst.FuncFancy).Struct.fields.len + |
| 10285 | | fancyFnExprExtraLen(align_body, args.align_ref) + |
| 10286 | | fancyFnExprExtraLen(addrspace_body, args.addrspace_ref) + |
| 10287 | | fancyFnExprExtraLen(section_body, args.section_ref) + |
| 10288 | | fancyFnExprExtraLen(cc_body, args.cc_ref) + |
| 10289 | | fancyFnExprExtraLen(ret_body, ret_ref) + |
| 10285 | fancyFnExprExtraLen(astgen, align_body, args.align_ref) + |
| 10286 | fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) + |
| 10287 | fancyFnExprExtraLen(astgen, section_body, args.section_ref) + |
| 10288 | fancyFnExprExtraLen(astgen, cc_body, args.cc_ref) + |
| 10289 | fancyFnExprExtraLen(astgen, ret_body, ret_ref) + |
| 10290 | 10290 | body_len + src_locs.len + |
| 10291 | 10291 | @boolToInt(args.lib_name != 0) + |
| 10292 | 10292 | @boolToInt(args.noalias_bits != 0), |
| ... | ... | @@ -10322,36 +10322,36 @@ const GenZir = struct { |
| 10322 | 10322 | |
| 10323 | 10323 | const zir_datas = astgen.instructions.items(.data); |
| 10324 | 10324 | if (align_body.len != 0) { |
| 10325 | | astgen.extra.appendAssumeCapacity(@intCast(u32, align_body.len)); |
| 10326 | | astgen.extra.appendSliceAssumeCapacity(align_body); |
| 10325 | astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, align_body)); |
| 10326 | astgen.appendBodyWithFixups(align_body); |
| 10327 | 10327 | zir_datas[align_body[align_body.len - 1]].@"break".block_inst = new_index; |
| 10328 | 10328 | } else if (args.align_ref != .none) { |
| 10329 | 10329 | astgen.extra.appendAssumeCapacity(@enumToInt(args.align_ref)); |
| 10330 | 10330 | } |
| 10331 | 10331 | if (addrspace_body.len != 0) { |
| 10332 | | astgen.extra.appendAssumeCapacity(@intCast(u32, addrspace_body.len)); |
| 10333 | | astgen.extra.appendSliceAssumeCapacity(addrspace_body); |
| 10332 | astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, addrspace_body)); |
| 10333 | astgen.appendBodyWithFixups(addrspace_body); |
| 10334 | 10334 | zir_datas[addrspace_body[addrspace_body.len - 1]].@"break".block_inst = new_index; |
| 10335 | 10335 | } else if (args.addrspace_ref != .none) { |
| 10336 | 10336 | astgen.extra.appendAssumeCapacity(@enumToInt(args.addrspace_ref)); |
| 10337 | 10337 | } |
| 10338 | 10338 | if (section_body.len != 0) { |
| 10339 | | astgen.extra.appendAssumeCapacity(@intCast(u32, section_body.len)); |
| 10340 | | astgen.extra.appendSliceAssumeCapacity(section_body); |
| 10339 | astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, section_body)); |
| 10340 | astgen.appendBodyWithFixups(section_body); |
| 10341 | 10341 | zir_datas[section_body[section_body.len - 1]].@"break".block_inst = new_index; |
| 10342 | 10342 | } else if (args.section_ref != .none) { |
| 10343 | 10343 | astgen.extra.appendAssumeCapacity(@enumToInt(args.section_ref)); |
| 10344 | 10344 | } |
| 10345 | 10345 | if (cc_body.len != 0) { |
| 10346 | | astgen.extra.appendAssumeCapacity(@intCast(u32, cc_body.len)); |
| 10347 | | astgen.extra.appendSliceAssumeCapacity(cc_body); |
| 10346 | astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, cc_body)); |
| 10347 | astgen.appendBodyWithFixups(cc_body); |
| 10348 | 10348 | zir_datas[cc_body[cc_body.len - 1]].@"break".block_inst = new_index; |
| 10349 | 10349 | } else if (args.cc_ref != .none) { |
| 10350 | 10350 | astgen.extra.appendAssumeCapacity(@enumToInt(args.cc_ref)); |
| 10351 | 10351 | } |
| 10352 | 10352 | if (ret_body.len != 0) { |
| 10353 | | astgen.extra.appendAssumeCapacity(@intCast(u32, ret_body.len)); |
| 10354 | | astgen.extra.appendSliceAssumeCapacity(ret_body); |
| 10353 | astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, ret_body)); |
| 10354 | astgen.appendBodyWithFixups(ret_body); |
| 10355 | 10355 | zir_datas[ret_body[ret_body.len - 1]].@"break".block_inst = new_index; |
| 10356 | 10356 | } else if (ret_ref != .none) { |
| 10357 | 10357 | astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref)); |
| ... | ... | @@ -10389,11 +10389,12 @@ const GenZir = struct { |
| 10389 | 10389 | try astgen.extra.ensureUnusedCapacity( |
| 10390 | 10390 | gpa, |
| 10391 | 10391 | @typeInfo(Zir.Inst.Func).Struct.fields.len + 1 + |
| 10392 | | @maximum(ret_body.len, @boolToInt(ret_ref != .none)) + |
| 10392 | fancyFnExprExtraLen(astgen, ret_body, ret_ref) + |
| 10393 | 10393 | body_len + src_locs.len, |
| 10394 | 10394 | ); |
| 10395 | |
| 10395 | 10396 | const ret_body_len = if (ret_body.len != 0) |
| 10396 | | @intCast(u32, ret_body.len) |
| 10397 | countBodyLenAfterFixups(astgen, ret_body) |
| 10397 | 10398 | else |
| 10398 | 10399 | @boolToInt(ret_ref != .none); |
| 10399 | 10400 | |
| ... | ... | @@ -10404,7 +10405,7 @@ const GenZir = struct { |
| 10404 | 10405 | }); |
| 10405 | 10406 | const zir_datas = astgen.instructions.items(.data); |
| 10406 | 10407 | if (ret_body.len != 0) { |
| 10407 | | astgen.extra.appendSliceAssumeCapacity(ret_body); |
| 10408 | astgen.appendBodyWithFixups(ret_body); |
| 10408 | 10409 | zir_datas[ret_body[ret_body.len - 1]].@"break".block_inst = new_index; |
| 10409 | 10410 | } else if (ret_ref != .none) { |
| 10410 | 10411 | astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref)); |
| ... | ... | @@ -10435,10 +10436,10 @@ const GenZir = struct { |
| 10435 | 10436 | } |
| 10436 | 10437 | } |
| 10437 | 10438 | |
| 10438 | | fn fancyFnExprExtraLen(body: []Zir.Inst.Index, ref: Zir.Inst.Ref) usize { |
| 10439 | fn fancyFnExprExtraLen(astgen: *AstGen, body: []Zir.Inst.Index, ref: Zir.Inst.Ref) u32 { |
| 10439 | 10440 | // In the case of non-empty body, there is one for the body length, |
| 10440 | 10441 | // and then one for each instruction. |
| 10441 | | return body.len + @boolToInt(ref != .none); |
| 10442 | return countBodyLenAfterFixups(astgen, body) + @boolToInt(ref != .none); |
| 10442 | 10443 | } |
| 10443 | 10444 | |
| 10444 | 10445 | fn addVar(gz: *GenZir, args: struct { |