Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f05ba70
Erase explicit layout decorations (`Offset`/`ArrayStride`) when disal…
eddyb Sep 9, 2025
5a77372
ci: update Vulkan SDK to 1.4.321.0.
eddyb Sep 9, 2025
9c6c410
Revert "linker/inline: use `OpPhi` instead of `OpVariable` for return…
eddyb Sep 9, 2025
549795c
Revert "WIP: mem2reg speedup"
eddyb Sep 9, 2025
f396dfe
Revert "WIP: couple of inliner things that need to be disentangled"
eddyb Sep 9, 2025
fc34f4e
Revert "WIP: (TODO: finish bottom-up cleanups) bottom-up inlining"
eddyb Sep 9, 2025
19a5810
Revert "linker/inline: fix `OpVariable` debuginfo collection and inse…
eddyb Sep 9, 2025
a72c284
[2024] linker/inline: fix `OpVariable` debuginfo collection and inser…
eddyb Sep 9, 2025
0084931
[2024] linker/inline: use bottom-up inlining to minimize redundancy.
eddyb Sep 9, 2025
6efc59f
[2024] linker/mem2reg: index SPIR-V blocks by their label IDs for O(1…
eddyb Sep 9, 2025
4f22f35
[2024] linker/inline: use `OpPhi` instead of `OpVariable` for return …
eddyb Sep 9, 2025
92a517c
linker/inline: fix typos in comments.
eddyb Sep 9, 2025
f6b75ce
[TODO(eddyb) this is probably sound but requires looping for rewrites…
eddyb Sep 9, 2025
3d974fa
linker/inline: also run `remove_duplicate_debuginfo` on every fully-i…
eddyb Sep 9, 2025
925b8ab
linker/inline: also run `mem2reg` on every fully-inlined function.
eddyb Sep 9, 2025
0ddf92e
(placeholder)
eddyb Sep 9, 2025
279022e
Replace `SpirvValueKind::IllegalTypeUsed` with mere `undef`.
eddyb Sep 9, 2025
3523ba4
Always register zombie messages, only at most defer their `Span`s.
eddyb Sep 9, 2025
825804f
Remove `SpirvValueKind::IllegalConst`.
eddyb Sep 9, 2025
8395cee
Reduce `SpirvValue` lossiness around `strip_ptrcasts` and `const_fold…
eddyb Sep 9, 2025
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: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.309.0
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.309.0
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.309.0
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true
Expand All @@ -165,7 +165,7 @@ jobs:
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.309.0
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.309.0
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true
Expand Down
68 changes: 47 additions & 21 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2381,13 +2381,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {

#[instrument(level = "trace", skip(self), fields(ptr, ptr_ty = ?self.debug_type(ptr.ty), dest_ty = ?self.debug_type(dest_ty)))]
fn pointercast(&mut self, ptr: Self::Value, dest_ty: Self::Type) -> Self::Value {
// HACK(eddyb) reuse the special-casing in `const_bitcast`, which relies
// on adding a pointer type to an untyped pointer (to some const data).
if let SpirvValueKind::IllegalConst(_) = ptr.kind {
trace!("illegal const");
return self.const_bitcast(ptr, dest_ty);
}

if ptr.ty == dest_ty {
trace!("ptr.ty == dest_ty");
return ptr;
Expand Down Expand Up @@ -2446,13 +2439,43 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.debug_type(ptr_pointee),
self.debug_type(dest_pointee),
);

// HACK(eddyb) reuse the special-casing in `const_bitcast`, which relies
// on adding a pointer type to an untyped pointer (to some const data).
if self.builder.lookup_const(ptr).is_some() {
// FIXME(eddyb) remove the condition on `zombie_waiting_for_span`,
// and constant-fold all pointer bitcasts, regardless of "legality",
// once `strip_ptrcasts` can undo `const_bitcast`, as well.
if ptr.zombie_waiting_for_span {
trace!("illegal const");
return self.const_bitcast(ptr, dest_ty);
}
}

// Defer the cast so that it has a chance to be avoided.
let original_ptr = ptr.def(self);
let ptr_id = ptr.def(self);
let bitcast_result_id = self.emit().bitcast(dest_ty, None, ptr_id).unwrap();

self.zombie(
bitcast_result_id,
&format!(
"cannot cast between pointer types\
\nfrom `{}`\
\n to `{}`",
self.debug_type(ptr.ty),
self.debug_type(dest_ty)
),
);

SpirvValue {
kind: SpirvValueKind::LogicalPtrCast {
original_ptr,
original_ptr_ty: ptr.ty,
bitcast_result_id: self.emit().bitcast(dest_ty, None, original_ptr).unwrap(),
zombie_waiting_for_span: false,
kind: SpirvValueKind::Def {
id: bitcast_result_id,
original_ptr_before_casts: Some(SpirvValue {
zombie_waiting_for_span: ptr.zombie_waiting_for_span,
kind: ptr_id,
ty: ptr.ty,
}),
},
ty: dest_ty,
}
Expand Down Expand Up @@ -3269,7 +3292,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
return_type,
arguments,
} => (
if let SpirvValueKind::FnAddr { function } = callee.kind {
if let SpirvValueKind::FnAddr { function, .. } = callee.kind {
assert_ty_eq!(self, callee_ty, pointee);
function
}
Expand Down Expand Up @@ -3406,11 +3429,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// HACK(eddyb) some entry-points only take a `&str`, not `fmt::Arguments`.
if let [
SpirvValue {
kind: SpirvValueKind::Def(a_id),
kind: SpirvValueKind::Def { id: a_id, .. },
..
},
SpirvValue {
kind: SpirvValueKind::Def(b_id),
kind: SpirvValueKind::Def { id: b_id, .. },
..
},
ref other_args @ ..,
Expand All @@ -3429,14 +3452,20 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// HACK(eddyb) `panic_nounwind_fmt` takes an extra argument.
[
SpirvValue {
kind: SpirvValueKind::Def(format_args_id),
kind:
SpirvValueKind::Def {
id: format_args_id, ..
},
..
},
_, // `&'static panic::Location<'static>`
]
| [
SpirvValue {
kind: SpirvValueKind::Def(format_args_id),
kind:
SpirvValueKind::Def {
id: format_args_id, ..
},
..
},
_, // `force_no_backtrace: bool`
Expand Down Expand Up @@ -4110,10 +4139,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.codegen_buffer_store_intrinsic(args, mode);

let void_ty = SpirvType::Void.def(rustc_span::DUMMY_SP, self);
return SpirvValue {
kind: SpirvValueKind::IllegalTypeUsed(void_ty),
ty: void_ty,
};
return self.undef(void_ty);
}

if let Some((source_ty, target_ty)) = from_trait_impl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;

use super::Builder;
use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind};
use crate::builder_spirv::{SpirvValue, SpirvValueExt};
use crate::spirv_type::SpirvType;
use rspirv::spirv::{Decoration, Word};
use rustc_abi::{Align, Size};
Expand Down Expand Up @@ -186,12 +186,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pass_mode: &PassMode,
) -> SpirvValue {
match pass_mode {
PassMode::Ignore => {
return SpirvValue {
kind: SpirvValueKind::IllegalTypeUsed(result_type),
ty: result_type,
};
}
PassMode::Ignore => return self.undef(result_type),

// PassMode::Pair is identical to PassMode::Direct - it's returned as a struct
PassMode::Direct(_) | PassMode::Pair(_, _) => (),
PassMode::Cast { .. } => {
Expand Down
Loading
Loading