Skip to content

Commit 9176408

Browse files
committed
Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it consistently shows up in profiles of the compiler.
1 parent 16d78bc commit 9176408

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+400
-401
lines changed

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ fn addCmakeCfgOptionsToExe(
759759
use_zig_libcxx: bool,
760760
) !void {
761761
const mod = exe.root_module;
762-
const target = mod.resolved_target.?.result;
762+
const target = &mod.resolved_target.?.result;
763763

764764
if (target.os.tag.isDarwin()) {
765765
// useful for package maintainers

lib/compiler/resinator/main.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ fn getIncludePaths(arena: std.mem.Allocator, auto_includes_option: cli.Options.A
525525
};
526526
const target = std.zig.resolveTargetQueryOrFatal(target_query);
527527
const is_native_abi = target_query.isNativeAbi();
528-
const detected_libc = std.zig.LibCDirs.detect(arena, zig_lib_dir, target, is_native_abi, true, null) catch {
528+
const detected_libc = std.zig.LibCDirs.detect(arena, zig_lib_dir, &target, is_native_abi, true, null) catch {
529529
if (includes == .any) {
530530
// fall back to mingw
531531
includes = .gnu;
@@ -550,7 +550,7 @@ fn getIncludePaths(arena: std.mem.Allocator, auto_includes_option: cli.Options.A
550550
};
551551
const target = std.zig.resolveTargetQueryOrFatal(target_query);
552552
const is_native_abi = target_query.isNativeAbi();
553-
const detected_libc = std.zig.LibCDirs.detect(arena, zig_lib_dir, target, is_native_abi, true, null) catch |err| switch (err) {
553+
const detected_libc = std.zig.LibCDirs.detect(arena, zig_lib_dir, &target, is_native_abi, true, null) catch |err| switch (err) {
554554
error.OutOfMemory => |e| return e,
555555
else => return error.MingwIncludesNotFound,
556556
};

lib/compiler_rt/divmodei4.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn divmod(q: ?[]u32, r: ?[]u32, u: []u32, v: []u32) !void {
3535

3636
pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
3737
@setRuntimeSafety(builtin.is_test);
38-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
38+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
3939
const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
4040
const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
4141
const v: []u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
@@ -44,7 +44,7 @@ pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) vo
4444

4545
pub fn __modei4(r_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
4646
@setRuntimeSafety(builtin.is_test);
47-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
47+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
4848
const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
4949
const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
5050
const v: []u32 = @ptrCast(@alignCast(v_p[0..byte_size]));

lib/compiler_rt/fixdfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixdfei(r: [*]u8, bits: usize, a: f64) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.signed, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixhfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixhfei(r: [*]u8, bits: usize, a: f16) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.signed, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixsfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixsfei(r: [*]u8, bits: usize, a: f32) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.signed, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixtfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixtfei(r: [*]u8, bits: usize, a: f128) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.signed, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixunsdfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixunsdfei(r: [*]u8, bits: usize, a: f64) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.unsigned, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixunshfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixunshfei(r: [*]u8, bits: usize, a: f16) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.unsigned, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

lib/compiler_rt/fixunssfei.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ comptime {
1010
}
1111

1212
pub fn __fixunssfei(r: [*]u8, bits: usize, a: f32) callconv(.c) void {
13-
const byte_size = std.zig.target.intByteSize(builtin.target, @intCast(bits));
13+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
1414
return bigIntFromFloat(.unsigned, @ptrCast(@alignCast(r[0..byte_size])), a);
1515
}

0 commit comments

Comments
 (0)