CBE and LLVM: handle unused try instructions

In both backends they did not observe the Liveness information for try
instructions. Now they do. For the C backend this is necessary for
correctness; for the LLVM backend, it improves code generation.
This commit is contained in:
Andrew Kelley
2022-12-03 19:30:08 -07:00
parent f2e59e41c1
commit 4aae0b09cf
2 changed files with 14 additions and 3 deletions

View File

@@ -4092,9 +4092,14 @@ fn lowerTry(
}
}
try reap(f, inst, &.{operand});
if (f.liveness.isUnused(inst)) {
return CValue.none;
}
const target = f.object.dg.module.getTarget();
const is_array = lowersToArray(payload_ty, target);
try reap(f, inst, &.{operand});
const local = try f.allocLocal(inst, result_ty);
if (is_array) {
try writer.writeAll("memcpy(");