From 09e4035e79caea3174bb3f60ba005fe5838d82e5 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Thu, 6 Nov 2025 20:12:35 -0800 Subject: [PATCH 1/2] llvm: clobber `rdx` instead of `edx` for x86-64 valgrind request --- src/codegen/llvm.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 6b891c1ab5a9..2711deba5cfd 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -11735,7 +11735,7 @@ pub const FuncGen = struct { \\ rolq $$61, %rdi ; rolq $$51, %rdi \\ xchgq %rbx, %rbx , - .constraints = "={rdx},{rax},{edx},~{cc},~{memory}", + .constraints = "={rdx},{rax},{rdx},~{cc},~{memory}", }, else => unreachable, }; From 483f9bd3670a52242d799dd4eee4273bdc714e8a Mon Sep 17 00:00:00 2001 From: David Rubin Date: Thu, 6 Nov 2025 20:27:38 -0800 Subject: [PATCH 2/2] llvm: add extra clobbers to valgrind requests This seems to work around a very puzzling miscompilation first present in LLVM 21.x. We already unconditionally add these clobbers to inline assembly that came from the source, the valgrind requests should also contain them. --- src/codegen/llvm.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 2711deba5cfd..a56311b32542 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -11672,7 +11672,7 @@ pub const FuncGen = struct { \\ srl $$0, $$0, 19 \\ or $$13, $$13, $$13 , - .constraints = "={$11},{$12},{$11},~{memory}", + .constraints = "={$11},{$12},{$11},~{memory},~{$1}", }, .mips64, .mips64el => .{ .template = @@ -11680,7 +11680,7 @@ pub const FuncGen = struct { \\ dsll $$0, $$0, 29 ; dsll $$0, $$0, 19 \\ or $$13, $$13, $$13 , - .constraints = "={$11},{$12},{$11},~{memory}", + .constraints = "={$11},{$12},{$11},~{memory},~{$1}", }, .powerpc, .powerpcle => .{ .template = @@ -11727,7 +11727,7 @@ pub const FuncGen = struct { \\ roll $$61, %edi ; roll $$51, %edi \\ xchgl %ebx, %ebx , - .constraints = "={edx},{eax},{edx},~{cc},~{memory}", + .constraints = "={edx},{eax},{edx},~{cc},~{memory},~{dirflag},~{fpsr},~{flags}", }, .x86_64 => .{ .template = @@ -11735,7 +11735,7 @@ pub const FuncGen = struct { \\ rolq $$61, %rdi ; rolq $$51, %rdi \\ xchgq %rbx, %rbx , - .constraints = "={rdx},{rax},{rdx},~{cc},~{memory}", + .constraints = "={rdx},{rax},{rdx},~{cc},~{memory},~{dirflag},~{fpsr},~{flags}", }, else => unreachable, };