aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-02-24 20:23:29 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-02-24 22:28:37 -0700
commitadb746a7017ba6f91974d5e940bc8a8f64bb45f5 (patch)
tree66cf6d6a07cea65dfb63e4602919b64fb2648695 /src/AstGen.zig
parent5d30e8016d2e29d84efb27ec2a4f7be8a63a4f49 (diff)
downloadzig-adb746a7017ba6f91974d5e940bc8a8f64bb45f5.tar.gz
zig-adb746a7017ba6f91974d5e940bc8a8f64bb45f5.zip
stage2: improved handling of store_to_block_ptr
* AstGen: remove the setBlockBodyEliding function. This is no longer needed after 63788b2a511eb87974065a052e2436b0c6202544. * Sema: store_to_block_ptr instruction is handled as store_to_inferred_ptr or store, as necessary.
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index dbb998dc71..74e3ae17b1 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -1964,11 +1964,7 @@ fn labeledBlockExpr(
},
.break_operand => {
// All break operands are values that did not use the result location pointer.
- if (strat.elide_store_to_block_ptr_instructions) {
- try block_scope.setBlockBodyEliding(block_inst);
- } else {
- try block_scope.setBlockBody(block_inst);
- }
+ try block_scope.setBlockBody(block_inst);
const block_ref = indexToRef(block_inst);
switch (rl) {
.ref => return block_ref,
@@ -9734,32 +9730,6 @@ const GenZir = struct {
gz.unstack();
}
- /// Same as `setBlockBody` except we don't copy instructions which are
- /// `store_to_block_ptr` instructions with lhs set to .none.
- /// Assumes nothing stacked on `gz`. Unstacks `gz`.
- fn setBlockBodyEliding(gz: *GenZir, inst: Zir.Inst.Index) !void {
- const gpa = gz.astgen.gpa;
- const body = gz.instructionsSlice();
- try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Block).Struct.fields.len + body.len);
- const zir_datas = gz.astgen.instructions.items(.data);
- const zir_tags = gz.astgen.instructions.items(.tag);
- const block_pl_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Block{
- .body_len = @intCast(u32, body.len),
- });
- zir_datas[inst].pl_node.payload_index = block_pl_index;
- for (body) |sub_inst| {
- if (zir_tags[sub_inst] == .store_to_block_ptr and
- zir_datas[sub_inst].bin.lhs == .none)
- {
- // Decrement `body_len`.
- gz.astgen.extra.items[block_pl_index] -= 1;
- continue;
- }
- gz.astgen.extra.appendAssumeCapacity(sub_inst);
- }
- gz.unstack();
- }
-
/// Supports `body_gz` stacked on `ret_gz` stacked on `gz`. Unstacks `body_gz` and `ret_gz`.
fn addFunc(gz: *GenZir, args: struct {
src_node: Ast.Node.Index,