From 823f9039f1cad8093cd276cf003a42996d39b74a Mon Sep 17 00:00:00 2001 From: Justus Klausecker Date: Fri, 6 Mar 2026 00:06:20 +0100 Subject: [PATCH] llvm: use atomic rmw to increment fuzzer pc counters This change makes the fuzzer instrumentation emitted by Zig thread-safe. --- src/codegen/llvm.zig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4ef72e8ab7fed1786845aa5b8e08d1ddfe6091fa..2335c349297c888d4e1a9547f7fe8ca9ee4fe07c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -4872,10 +4872,8 @@ pub const FuncGen = struct { const ptr = if (poi_index == 0) base_ptr else try self.wip.gep(.inbounds, .i8, base_ptr, &.{ try o.builder.intValue(.i32, poi_index), }, ""); - const counter = try self.wip.load(.normal, .i8, ptr, .default, ""); const one = try o.builder.intValue(.i8, 1); - const counter_incremented = try self.wip.bin(.add, counter, one, ""); - _ = try self.wip.store(.normal, counter_incremented, ptr, .default); + _ = try self.wip.atomicrmw(.normal, .add, ptr, one, self.sync_scope, .monotonic, .default, ""); // LLVM does not allow blockaddress on the entry block. const pc = if (self.wip.cursor.block == .entry) -- 2.54.0