authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 12:45:27+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 12:59:41+01:00
log515c97065a5352448747fbaf1f5ea43173a4457a
tree0fad021c1bb9b55e55648108583dec055b25a686
parent97583714191588347210fa2426a6eb8d757089a2
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

Revert "work around llvm failing to lower memcpy"

This reverts commit acf70439551fc3f49b2d292ff93ee519901cdf42. Fixed as of ec768b7fa2f9c7dea6b92651bef59a7eea3299f2.

1 files changed, 2 insertions(+), 26 deletions(-)

lib/compiler_rt/memcpy.zig+2-26
......@@ -9,36 +9,12 @@ comptime {
99 }
1010}
1111
12const llvm_cannot_lower = switch (builtin.cpu.arch) {
13 .arm, .armeb, .thumb, .thumbeb => builtin.zig_backend == .stage2_llvm,
14 else => false,
15};
16
1712fn memcpy(noalias opt_dest: ?[*]u8, noalias opt_src: ?[*]const u8, len: usize) callconv(.C) ?[*]u8 {
18 if (llvm_cannot_lower) {
19 for (0..len) |i| opt_dest.?[i] = opt_src.?[i];
20 return opt_dest;
21 } else {
22 return memmove(opt_dest, opt_src, len);
23 }
13 return memmove(opt_dest, opt_src, len);
2414}
2515
26/// A port of https://github.com/facebook/folly/blob/1c8bc50e88804e2a7361a57cd9b551dd10f6c5fd/folly/memcpy.S
2716fn memmove(opt_dest: ?[*]u8, opt_src: ?[*]const u8, len: usize) callconv(.C) ?[*]u8 {
28 if (llvm_cannot_lower) {
29 if (@intFromPtr(opt_dest) < @intFromPtr(opt_src)) {
30 for (0..len) |i| opt_dest.?[i] = opt_src.?[i];
31 return opt_dest;
32 } else {
33 var index = len;
34 while (index != 0) {
35 index -= 1;
36 opt_dest.?[index] = opt_src.?[index];
37 }
38 return opt_dest;
39 }
40 }
41
17 // a port of https://github.com/facebook/folly/blob/1c8bc50e88804e2a7361a57cd9b551dd10f6c5fd/folly/memcpy.S
4218 if (len == 0) {
4319 @branchHint(.unlikely);
4420 return opt_dest;