| ... | ... | @@ -2015,6 +2015,7 @@ fn labeledBlockExpr( |
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | const zir_datas = gz.astgen.instructions.items(.data); |
| 2018 | const zir_tags = gz.astgen.instructions.items(.tag); |
| 2018 | 2019 | const strat = rl.strategy(&block_scope); |
| 2019 | 2020 | switch (strat.tag) { |
| 2020 | 2021 | .break_void => { |
| ... | ... | @@ -2029,6 +2030,31 @@ fn labeledBlockExpr( |
| 2029 | 2030 | }, |
| 2030 | 2031 | .break_operand => { |
| 2031 | 2032 | // All break operands are values that did not use the result location pointer. |
| 2033 | // The break instructions need to have their operands coerced if the |
| 2034 | // block's result location is a `ty`. In this case we overwrite the |
| 2035 | // `store_to_block_ptr` instruction with an `as` instruction and repurpose |
| 2036 | // it as the break operand. |
| 2037 | // This corresponds to similar code in `setCondBrPayloadElideBlockStorePtr`. |
| 2038 | if (block_scope.rl_ty_inst != .none) { |
| 2039 | for (block_scope.labeled_breaks.items) |br| { |
| 2040 | // We expect the `store_to_block_ptr` to be created between 1-3 instructions |
| 2041 | // prior to the break. |
| 2042 | var search_index = br -| 3; |
| 2043 | while (search_index < br) : (search_index += 1) { |
| 2044 | if (zir_tags[search_index] == .store_to_block_ptr and |
| 2045 | zir_datas[search_index].bin.lhs == block_scope.rl_ptr) |
| 2046 | { |
| 2047 | zir_tags[search_index] = .as; |
| 2048 | zir_datas[search_index].bin = .{ |
| 2049 | .lhs = block_scope.rl_ty_inst, |
| 2050 | .rhs = zir_datas[br].@"break".operand, |
| 2051 | }; |
| 2052 | zir_datas[br].@"break".operand = indexToRef(search_index); |
| 2053 | break; |
| 2054 | } |
| 2055 | } else unreachable; |
| 2056 | } |
| 2057 | } |
| 2032 | 2058 | try block_scope.setBlockBody(block_inst); |
| 2033 | 2059 | const block_ref = indexToRef(block_inst); |
| 2034 | 2060 | switch (rl) { |
| ... | ... | @@ -5366,6 +5392,7 @@ fn setCondBrPayloadElideBlockStorePtr( |
| 5366 | 5392 | // switch's result location is a `ty`. In this case we overwrite the |
| 5367 | 5393 | // `store_to_block_ptr` instruction with an `as` instruction and repurpose |
| 5368 | 5394 | // it as the break operand. |
| 5395 | // This corresponds to similar code in `labeledBlockExpr`. |
| 5369 | 5396 | for (then_body) |src_inst| { |
| 5370 | 5397 | if (zir_tags[src_inst] == .store_to_block_ptr and |
| 5371 | 5398 | zir_datas[src_inst].bin.lhs == block_ptr) |