| author | |
| committer | |
| log | e83cf6a4542b34e7fd64028a3b1b89dacdc2e166 |
| tree | ed192b102e4ca13145623216b0e808d7f1fd6059 |
| parent | b109daacddf54dbe4ffcbef9041443f2759511e3 |
It would be better if AstGen would actually omit these instructions
rather than only marking them as elided, but that can be solved
separately.3 files changed, 9 insertions(+), 0 deletions(-)
BRANCH_TODO+2| ... | @@ -65,3 +65,5 @@ | ... | @@ -65,3 +65,5 @@ |
| 65 | 65 | ||
| 66 | * in SwitchProng resolve, make sure AST tree gets loaded. | 66 | * in SwitchProng resolve, make sure AST tree gets loaded. |
| 67 | It will be unloaded if using cached ZIR. | 67 | It will be unloaded if using cached ZIR. |
| 68 | |||
| 69 | * make AstGen smart enough to omit elided store_to_block_ptr instructions |
src/Sema.zig+5| ... | @@ -1461,6 +1461,11 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -1461,6 +1461,11 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 1461 | defer tracy.end(); | 1461 | defer tracy.end(); |
| 1462 | 1462 | ||
| 1463 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 1463 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 1464 | if (bin_inst.lhs == .none) { | ||
| 1465 | // This is an elided instruction, but AstGen was not smart enough | ||
| 1466 | // to omit it. | ||
| 1467 | return; | ||
| 1468 | } | ||
| 1464 | const ptr = try sema.resolveInst(bin_inst.lhs); | 1469 | const ptr = try sema.resolveInst(bin_inst.lhs); |
| 1465 | const value = try sema.resolveInst(bin_inst.rhs); | 1470 | const value = try sema.resolveInst(bin_inst.rhs); |
| 1466 | const ptr_ty = try sema.mod.simplePtrType(sema.arena, value.ty, true, .One); | 1471 | const ptr_ty = try sema.mod.simplePtrType(sema.arena, value.ty, true, .One); |
src/Zir.zig+2| ... | @@ -484,6 +484,8 @@ pub const Inst = struct { | ... | @@ -484,6 +484,8 @@ pub const Inst = struct { |
| 484 | /// Same as `store` but the type of the value being stored will be used to infer | 484 | /// Same as `store` but the type of the value being stored will be used to infer |
| 485 | /// the block type. The LHS is the pointer to store to. | 485 | /// the block type. The LHS is the pointer to store to. |
| 486 | /// Uses the `bin` union field. | 486 | /// Uses the `bin` union field. |
| 487 | /// If the pointer is none, it means this instruction has been elided in | ||
| 488 | /// AstGen, but AstGen was unable to actually omit it from the ZIR code. | ||
| 487 | store_to_block_ptr, | 489 | store_to_block_ptr, |
| 488 | /// Same as `store` but the type of the value being stored will be used to infer | 490 | /// Same as `store` but the type of the value being stored will be used to infer |
| 489 | /// the pointer type. | 491 | /// the pointer type. |