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...@@ -1754,11 +1754,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
1754 switch (zir_tags[inst]) {1754 switch (zir_tags[inst]) {
1755 // For some instructions, swap in a slightly different ZIR tag1755 // For some instructions, swap in a slightly different ZIR tag
1756 // so we can avoid a separate ensure_result_used instruction.1756 // 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 },
1762 .call_chkused => unreachable,1757 .call_chkused => unreachable,
1763 .call => {1758 .call => {
1764 zir_tags[inst] = .call_chkused;1759 zir_tags[inst] = .call_chkused;
...@@ -6760,10 +6755,7 @@ fn callExpr(...@@ -6760,10 +6755,7 @@ fn callExpr(
6760 };6755 };
6761 const result: Zir.Inst.Ref = res: {6756 const result: Zir.Inst.Ref = res: {
6762 const tag: Zir.Inst.Tag = switch (modifier) {6757 const tag: Zir.Inst.Tag = switch (modifier) {
6763 .auto => switch (args.len == 0) {6758 .auto => .call,
6764 true => break :res try gz.addUnNode(.call_none, lhs, node),
6765 false => .call,
6766 },
6767 .async_kw => .call_async,6759 .async_kw => .call_async,
6768 .never_tail => unreachable,6760 .never_tail => unreachable,
6769 .never_inline => unreachable,6761 .never_inline => unreachable,
src/Sema.zig-17
...@@ -163,8 +163,6 @@ pub fn analyzeBody(...@@ -163,8 +163,6 @@ pub fn analyzeBody(
163 .call_compile_time => try sema.zirCall(block, inst, .compile_time, false),163 .call_compile_time => try sema.zirCall(block, inst, .compile_time, false),
164 .call_nosuspend => try sema.zirCall(block, inst, .no_async, false),164 .call_nosuspend => try sema.zirCall(block, inst, .no_async, false),
165 .call_async => try sema.zirCall(block, inst, .async_kw, false),165 .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),
168 .cmp_eq => try sema.zirCmp(block, inst, .eq),166 .cmp_eq => try sema.zirCmp(block, inst, .eq),
169 .cmp_gt => try sema.zirCmp(block, inst, .gt),167 .cmp_gt => try sema.zirCmp(block, inst, .gt),
170 .cmp_gte => try sema.zirCmp(block, inst, .gte),168 .cmp_gte => try sema.zirCmp(block, inst, .gte),
...@@ -1937,21 +1935,6 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c...@@ -1937,21 +1935,6 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c
1937 return decl;1935 return decl;
1938}1936}
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
1955fn zirCall(1938fn zirCall(
1956 sema: *Sema,1939 sema: *Sema,
1957 block: *Scope.Block,1940 block: *Scope.Block,
src/Zir.zig-9
...@@ -242,11 +242,6 @@ pub const Inst = struct {...@@ -242,11 +242,6 @@ pub const Inst = struct {
242 call_nosuspend,242 call_nosuspend,
243 /// Same as `call` but with modifier `.async_kw`.243 /// Same as `call` but with modifier `.async_kw`.
244 call_async,244 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,
250 /// `<`245 /// `<`
251 /// Uses the `pl_node` union field. Payload is `Bin`.246 /// Uses the `pl_node` union field. Payload is `Bin`.
252 cmp_lt,247 cmp_lt,
...@@ -981,8 +976,6 @@ pub const Inst = struct {...@@ -981,8 +976,6 @@ pub const Inst = struct {
981 .call_compile_time,976 .call_compile_time,
982 .call_nosuspend,977 .call_nosuspend,
983 .call_async,978 .call_async,
984 .call_none,
985 .call_none_chkused,
986 .cmp_lt,979 .cmp_lt,
987 .cmp_lte,980 .cmp_lte,
988 .cmp_eq,981 .cmp_eq,
...@@ -2346,8 +2339,6 @@ const Writer = struct {...@@ -2346,8 +2339,6 @@ const Writer = struct {
2346 .bool_not,2339 .bool_not,
2347 .negate,2340 .negate,
2348 .negate_wrap,2341 .negate_wrap,
2349 .call_none,
2350 .call_none_chkused,
2351 .load,2342 .load,
2352 .ensure_result_used,2343 .ensure_result_used,
2353 .ensure_result_non_error,2344 .ensure_result_non_error,