authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-23 22:43:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-23 22:43:20-07:00
logd2b06c2612fd3bf6d798373228d546c41ad76622
tree85b8af33e0910f3953422686b3b9e90ecc1ae098
parent6b98384e20e738dceabaad38dab1be12375f2a3d

stage2: remove call_none and call_none_chkused ZIR

These are unproven optimizations and we need some more room in the `Zir.Inst.Tag` enum for some more syntax.

3 files changed, 1 insertions(+), 35 deletions(-)

src/AstGen.zig+1-9
......@@ -1754,11 +1754,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
17541754 switch (zir_tags[inst]) {
17551755 // For some instructions, swap in a slightly different ZIR tag
17561756 // so we can avoid a separate ensure_result_used instruction.
1757 .call_none_chkused => unreachable,
1758 .call_none => {
1759 zir_tags[inst] = .call_none_chkused;
1760 break :b true;
1761 },
17621757 .call_chkused => unreachable,
17631758 .call => {
17641759 zir_tags[inst] = .call_chkused;
......@@ -6760,10 +6755,7 @@ fn callExpr(
67606755 };
67616756 const result: Zir.Inst.Ref = res: {
67626757 const tag: Zir.Inst.Tag = switch (modifier) {
6763 .auto => switch (args.len == 0) {
6764 true => break :res try gz.addUnNode(.call_none, lhs, node),
6765 false => .call,
6766 },
6758 .auto => .call,
67676759 .async_kw => .call_async,
67686760 .never_tail => unreachable,
67696761 .never_inline => unreachable,
src/Sema.zig-17
......@@ -163,8 +163,6 @@ pub fn analyzeBody(
163163 .call_compile_time => try sema.zirCall(block, inst, .compile_time, false),
164164 .call_nosuspend => try sema.zirCall(block, inst, .no_async, false),
165165 .call_async => try sema.zirCall(block, inst, .async_kw, false),
166 .call_none => try sema.zirCallNone(block, inst, false),
167 .call_none_chkused => try sema.zirCallNone(block, inst, true),
168166 .cmp_eq => try sema.zirCmp(block, inst, .eq),
169167 .cmp_gt => try sema.zirCmp(block, inst, .gt),
170168 .cmp_gte => try sema.zirCmp(block, inst, .gte),
......@@ -1937,21 +1935,6 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c
19371935 return decl;
19381936}
19391937
1940fn zirCallNone(
1941 sema: *Sema,
1942 block: *Scope.Block,
1943 inst: Zir.Inst.Index,
1944 ensure_result_used: bool,
1945) InnerError!*Inst {
1946 const tracy = trace(@src());
1947 defer tracy.end();
1948
1949 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1950 const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node };
1951
1952 return sema.analyzeCall(block, inst_data.operand, func_src, inst_data.src(), .auto, ensure_result_used, &.{});
1953}
1954
19551938fn zirCall(
19561939 sema: *Sema,
19571940 block: *Scope.Block,
src/Zir.zig-9
......@@ -242,11 +242,6 @@ pub const Inst = struct {
242242 call_nosuspend,
243243 /// Same as `call` but with modifier `.async_kw`.
244244 call_async,
245 /// Function call with modifier `.auto`, empty parameter list.
246 /// Uses the `un_node` field. Operand is callee. AST node is the function call.
247 call_none,
248 /// Same as `call_none` but it also does `ensure_result_used` on the return value.
249 call_none_chkused,
250245 /// `<`
251246 /// Uses the `pl_node` union field. Payload is `Bin`.
252247 cmp_lt,
......@@ -981,8 +976,6 @@ pub const Inst = struct {
981976 .call_compile_time,
982977 .call_nosuspend,
983978 .call_async,
984 .call_none,
985 .call_none_chkused,
986979 .cmp_lt,
987980 .cmp_lte,
988981 .cmp_eq,
......@@ -2346,8 +2339,6 @@ const Writer = struct {
23462339 .bool_not,
23472340 .negate,
23482341 .negate_wrap,
2349 .call_none,
2350 .call_none_chkused,
23512342 .load,
23522343 .ensure_result_used,
23532344 .ensure_result_non_error,