aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-04 21:59:01 -0500
committerGitHub <noreply@github.com>2022-12-04 21:59:01 -0500
commit70ad5bc3631c330eb41b9379d7e93f0647da2fd6 (patch)
tree8b9e7c78245891efee3cc8b4f0e3ad770704bb7e /src/codegen/llvm.zig
parentbdb6fb57639a4508dda523301c5eaf31e8d89edf (diff)
parent7d3cc3bc8d772519d390b7f13346eeab73bc0c21 (diff)
downloadzig-70ad5bc3631c330eb41b9379d7e93f0647da2fd6.tar.gz
zig-70ad5bc3631c330eb41b9379d7e93f0647da2fd6.zip
Merge pull request #13768 from ziglang/cbe-reuse-locals-2
C backend: reuse locals but respect loops to pass behavior tests
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 3fd1effc21..29d074ea1c 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -5346,7 +5346,8 @@ pub const FuncGen = struct {
const err_union_ty = self.air.typeOf(pl_op.operand);
const payload_ty = self.air.typeOfIndex(inst);
const can_elide_load = if (isByRef(payload_ty)) self.canElideLoad(body_tail) else false;
- return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, payload_ty);
+ const is_unused = self.liveness.isUnused(inst);
+ return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, is_unused, payload_ty);
}
fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
@@ -5356,7 +5357,8 @@ pub const FuncGen = struct {
const body = self.air.extra[extra.end..][0..extra.data.body_len];
const err_union_ty = self.air.typeOf(extra.data.ptr).childType();
const payload_ty = self.air.typeOfIndex(inst);
- return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, payload_ty);
+ const is_unused = self.liveness.isUnused(inst);
+ return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, is_unused, payload_ty);
}
fn lowerTry(
@@ -5366,6 +5368,7 @@ pub const FuncGen = struct {
err_union_ty: Type,
operand_is_ptr: bool,
can_elide_load: bool,
+ is_unused: bool,
result_ty: Type,
) !?*llvm.Value {
const payload_ty = err_union_ty.errorUnionPayload();
@@ -5405,6 +5408,9 @@ pub const FuncGen = struct {
fg.builder.positionBuilderAtEnd(continue_block);
}
+ if (is_unused) {
+ return null;
+ }
if (!payload_has_bits) {
if (!operand_is_ptr) return null;