Skip to content

spirv: refactor and remove deduplication ISel #24661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,6 @@ set(ZIG_STAGE2_SOURCES
src/codegen/c/Type.zig
src/codegen/llvm.zig
src/codegen/llvm/bindings.zig
src/codegen/spirv.zig
src/codegen/spirv/Assembler.zig
src/codegen/spirv/Module.zig
src/codegen/spirv/Section.zig
src/codegen/spirv/spec.zig
src/crash_report.zig
src/dev.zig
src/libs/freebsd.zig
Expand Down Expand Up @@ -620,11 +615,6 @@ set(ZIG_STAGE2_SOURCES
src/link/Plan9.zig
src/link/Plan9/aout.zig
src/link/Queue.zig
src/link/SpirV.zig
src/link/SpirV/BinaryModule.zig
src/link/SpirV/deduplicate.zig
src/link/SpirV/lower_invocation_globals.zig
src/link/SpirV/prune_unused.zig
src/link/StringTable.zig
src/link/Wasm.zig
src/link/Wasm/Archive.zig
Expand Down
8 changes: 7 additions & 1 deletion lib/std/Build/Watch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ const Os = switch (builtin.os.tag) {
const gop = try w.dir_table.getOrPut(gpa, path);
if (!gop.found_existing) {
var mount_id: MountId = undefined;
const dir_handle = try Os.getDirHandle(gpa, path, &mount_id);
const dir_handle = Os.getDirHandle(gpa, path, &mount_id) catch |err| switch (err) {
error.FileNotFound => {
std.debug.assert(w.dir_table.swapRemove(path));
continue;
},
else => return err,
};
Comment on lines +174 to +180
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, but can you please do this separately?

const fan_fd = blk: {
const fd_gop = try w.os.poll_fds.getOrPut(gpa, mount_id);
if (!fd_gop.found_existing) {
Expand Down
5 changes: 2 additions & 3 deletions src/Zcu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3646,9 +3646,8 @@ pub fn errorSetBits(zcu: *const Zcu) u16 {

if (zcu.error_limit == 0) return 0;
if (target.cpu.arch.isSpirV()) {
if (!target.cpu.has(.spirv, .storage_push_constant16)) {
return 32;
}
// As expected by https://github.com/Snektron/zig-spirv-test-executor
if (zcu.comp.config.is_test) return 32;
}

return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;
Expand Down
7 changes: 2 additions & 5 deletions src/Zcu/PerThread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4398,13 +4398,10 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e

const lf = comp.bin_file orelse return error.NoLinkFile;

// TODO: self-hosted codegen should always have a type of MIR; codegen should produce that MIR,
// and the linker should consume it. However, our SPIR-V backend is currently tightly coupled
// with our SPIR-V linker, so needs to work more like the LLVM backend. This should be fixed to
// unblock threaded codegen for SPIR-V.
// Just like LLVM, the SPIR-V backend can't multi-threaded due to SPIR-V design limitations.
if (lf.cast(.spirv)) |spirv_file| {
assert(pt.tid == .main); // SPIR-V has a lot of shared state
spirv_file.object.updateFunc(pt, func_index, air, &liveness) catch |err| {
spirv_file.updateFunc(pt, func_index, air, &liveness) catch |err| {
switch (err) {
error.OutOfMemory => comp.link_diags.setAllocFailure(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn importBackend(comptime backend: std.builtin.CompilerBackend) type {
.stage2_powerpc => unreachable,
.stage2_riscv64 => @import("arch/riscv64/CodeGen.zig"),
.stage2_sparc64 => @import("arch/sparc64/CodeGen.zig"),
.stage2_spirv => @import("codegen/spirv.zig"),
.stage2_spirv => @import("codegen/spirv/CodeGen.zig"),
.stage2_wasm => @import("arch/wasm/CodeGen.zig"),
.stage2_x86, .stage2_x86_64 => @import("arch/x86_64/CodeGen.zig"),
_ => unreachable,
Expand Down
Loading