authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-29 17:17:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-30 00:20:49-05:00
logdeda6b514691c3a7ffc7931469886d0e7be2f67e
treec71ae6f91304fc3d7e68da2fc04fc1fe4154e61f
parentb8473ae7d333ea2750e55e712722d446076e99d9

LLVM: fix canElideLoad behavior with loops

closes #13546

3 files changed, 28 insertions(+), 8 deletions(-)

ci/linux/build-x86_64-debug.sh+3-7
......@@ -51,9 +51,7 @@ stage3-debug/bin/zig fmt --check .. \
5151# simultaneously test building self-hosted without LLVM and with 32-bit arm
5252stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf
5353
54# building docs disabled due to:
55# https://github.com/ziglang/zig/issues/13546
56stage3-debug/bin/zig build test \
54stage3-debug/bin/zig build test docs \
5755 -fqemu \
5856 -fwasmtime \
5957 -Dstatic-llvm \
......@@ -61,10 +59,8 @@ stage3-debug/bin/zig build test \
6159 --search-prefix "$PREFIX" \
6260 --zig-lib-dir "$(pwd)/../lib"
6361
64# langref disabled due to:
65# https://github.com/ziglang/zig/issues/13546
66## Look for HTML errors.
67#tidy --drop-empty-elements no -qe ../zig-cache/langref.html
62# Look for HTML errors.
63tidy --drop-empty-elements no -qe ../zig-cache/langref.html
6864
6965# Produce the experimental std lib documentation.
7066stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
src/codegen/llvm.zig+4-1
......@@ -8136,7 +8136,10 @@ pub const FuncGen = struct {
81368136 .write, .noret, .complex => return false,
81378137 .tomb => return true,
81388138 }
8139 } else unreachable;
8139 }
8140 // The only way to get here is to hit the end of a loop instruction
8141 // (implicit repeat).
8142 return false;
81408143 }
81418144
81428145 fn airLoad(fg: *FuncGen, body_tail: []const Air.Inst.Index) !?*llvm.Value {
test/behavior/while.zig+21
......@@ -343,3 +343,24 @@ test "else continue outer while" {
343343 } else continue;
344344 }
345345}
346
347test "try terminating an infinite loop" {
348 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
349 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
350 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
351
352 // Test coverage for https://github.com/ziglang/zig/issues/13546
353 const Foo = struct {
354 trash: i32,
355
356 fn bar() anyerror!@This() {
357 return .{ .trash = 1234 };
358 }
359 };
360 var t = true;
361 errdefer t = false;
362 try expect(while (true) {
363 if (t) break t;
364 _ = try Foo.bar();
365 } else unreachable);
366}