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.
This commit is contained in:
Andrew Kelley
2021-04-23 22:43:20 -07:00
parent 6b98384e20
commit d2b06c2612
3 changed files with 1 additions and 35 deletions

View File

@@ -1754,11 +1754,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
switch (zir_tags[inst]) {
// For some instructions, swap in a slightly different ZIR tag
// so we can avoid a separate ensure_result_used instruction.
.call_none_chkused => unreachable,
.call_none => {
zir_tags[inst] = .call_none_chkused;
break :b true;
},
.call_chkused => unreachable,
.call => {
zir_tags[inst] = .call_chkused;
@@ -6760,10 +6755,7 @@ fn callExpr(
};
const result: Zir.Inst.Ref = res: {
const tag: Zir.Inst.Tag = switch (modifier) {
.auto => switch (args.len == 0) {
true => break :res try gz.addUnNode(.call_none, lhs, node),
false => .call,
},
.auto => .call,
.async_kw => .call_async,
.never_tail => unreachable,
.never_inline => unreachable,

View File

@@ -163,8 +163,6 @@ pub fn analyzeBody(
.call_compile_time => try sema.zirCall(block, inst, .compile_time, false),
.call_nosuspend => try sema.zirCall(block, inst, .no_async, false),
.call_async => try sema.zirCall(block, inst, .async_kw, false),
.call_none => try sema.zirCallNone(block, inst, false),
.call_none_chkused => try sema.zirCallNone(block, inst, true),
.cmp_eq => try sema.zirCmp(block, inst, .eq),
.cmp_gt => try sema.zirCmp(block, inst, .gt),
.cmp_gte => try sema.zirCmp(block, inst, .gte),
@@ -1937,21 +1935,6 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c
return decl;
}
fn zirCallNone(
sema: *Sema,
block: *Scope.Block,
inst: Zir.Inst.Index,
ensure_result_used: bool,
) InnerError!*Inst {
const tracy = trace(@src());
defer tracy.end();
const inst_data = sema.code.instructions.items(.data)[inst].un_node;
const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node };
return sema.analyzeCall(block, inst_data.operand, func_src, inst_data.src(), .auto, ensure_result_used, &.{});
}
fn zirCall(
sema: *Sema,
block: *Scope.Block,

View File

@@ -242,11 +242,6 @@ pub const Inst = struct {
call_nosuspend,
/// Same as `call` but with modifier `.async_kw`.
call_async,
/// Function call with modifier `.auto`, empty parameter list.
/// Uses the `un_node` field. Operand is callee. AST node is the function call.
call_none,
/// Same as `call_none` but it also does `ensure_result_used` on the return value.
call_none_chkused,
/// `<`
/// Uses the `pl_node` union field. Payload is `Bin`.
cmp_lt,
@@ -981,8 +976,6 @@ pub const Inst = struct {
.call_compile_time,
.call_nosuspend,
.call_async,
.call_none,
.call_none_chkused,
.cmp_lt,
.cmp_lte,
.cmp_eq,
@@ -2346,8 +2339,6 @@ const Writer = struct {
.bool_not,
.negate,
.negate_wrap,
.call_none,
.call_none_chkused,
.load,
.ensure_result_used,
.ensure_result_non_error,