authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2026-03-06 00:06:20+01:00
committergravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2026-03-06 10:09:06+01:00
log823f9039f1cad8093cd276cf003a42996d39b74a
tree866fa34fd1187e1825091f8a8b9a9f5d7cb78742
parent0e348d415f9039b44313232304aeea69c3228c0c

llvm: use atomic rmw to increment fuzzer pc counters

This change makes the fuzzer instrumentation emitted by Zig thread-safe.

1 files changed, 1 insertions(+), 3 deletions(-)

src/codegen/llvm.zig+1-3
...@@ -4872,10 +4872,8 @@ pub const FuncGen = struct {...@@ -4872,10 +4872,8 @@ pub const FuncGen = struct {
4872 const ptr = if (poi_index == 0) base_ptr else try self.wip.gep(.inbounds, .i8, base_ptr, &.{4872 const ptr = if (poi_index == 0) base_ptr else try self.wip.gep(.inbounds, .i8, base_ptr, &.{
4873 try o.builder.intValue(.i32, poi_index),4873 try o.builder.intValue(.i32, poi_index),
4874 }, "");4874 }, "");
4875 const counter = try self.wip.load(.normal, .i8, ptr, .default, "");
4876 const one = try o.builder.intValue(.i8, 1);4875 const one = try o.builder.intValue(.i8, 1);
4877 const counter_incremented = try self.wip.bin(.add, counter, one, "");4876 _ = try self.wip.atomicrmw(.normal, .add, ptr, one, self.sync_scope, .monotonic, .default, "");
4878 _ = try self.wip.store(.normal, counter_incremented, ptr, .default);
48794877
4880 // LLVM does not allow blockaddress on the entry block.4878 // LLVM does not allow blockaddress on the entry block.
4881 const pc = if (self.wip.cursor.block == .entry)4879 const pc = if (self.wip.cursor.block == .entry)