Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
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
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/linker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L

{
let _timer = sess.timer("link_remove_zombies");
zombies::remove_zombies(sess, &mut output);
zombies::remove_zombies(sess, &mut output)?;
}

{
Expand Down
19 changes: 14 additions & 5 deletions crates/rustc_codegen_spirv/src/linker/zombies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ fn spread_zombie(module: &mut Module, zombie: &mut FxHashMap<Word, ZombieInfo<'_
// If an entry point references a zombie'd value, then the entry point would normally get removed.
// That's an absolutely horrible experience to debug, though, so instead, create a nice error
// message containing the stack trace of how the entry point got to the zombie value.
fn report_error_zombies(sess: &Session, module: &Module, zombie: &FxHashMap<Word, ZombieInfo<'_>>) {
fn report_error_zombies(
sess: &Session,
module: &Module,
zombie: &FxHashMap<Word, ZombieInfo<'_>>,
) -> super::Result<()> {
let mut result = Ok(());
let mut names = None;
for root in super::dce::collect_roots(module) {
if let Some(reason) = zombie.get(&root) {
Expand All @@ -120,14 +125,16 @@ fn report_error_zombies(sess: &Session, module: &Module, zombie: &FxHashMap<Word
.chain(stack)
.collect::<Vec<_>>()
.join("\n");
sess.struct_span_err(reason.span, reason.reason)
result = Err(sess
.struct_span_err(reason.span, reason.reason)
.note(&stack_note)
.emit();
.emit());
}
}
result
}

pub fn remove_zombies(sess: &Session, module: &mut Module) {
pub fn remove_zombies(sess: &Session, module: &mut Module) -> super::Result<()> {
let zombies_owned = ZombieDecoration::decode_all(module)
.map(|(id, zombie)| {
let ZombieDecoration { reason, span } = zombie.deserialize();
Expand All @@ -145,7 +152,7 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) {
// Note: This is O(n^2).
while spread_zombie(module, &mut zombies) {}

report_error_zombies(sess, module, &zombies);
let result = report_error_zombies(sess, module, &zombies);

if env::var("PRINT_ALL_ZOMBIE").is_ok() {
for (&zomb, reason) in &zombies {
Expand Down Expand Up @@ -208,4 +215,6 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) {
module
.functions
.retain(|f| is_zombie(f.def.as_ref().unwrap(), &zombies).is_none());

result
}
7 changes: 1 addition & 6 deletions tests/ui/lang/consts/nested-ref-in-composite.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,5 @@ error: constant arrays/structs cannot contain pointers to other constants
nested_ref_in_composite::main_array3
main_array3

error: error:0:0 - No OpEntryPoint instruction was found. This is only allowed if the Linkage capability is being used.
|
= note: spirv-val failed
= note: module `$TEST_BUILD_DIR/lang/consts/nested-ref-in-composite.stage-id.spv.dir/module`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

7 changes: 1 addition & 6 deletions tests/ui/lang/core/ptr/allocate_const_scalar.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ error: pointer has non-null integer address
allocate_const_scalar::main
main

error: error:0:0 - No OpEntryPoint instruction was found. This is only allowed if the Linkage capability is being used.
|
= note: spirv-val failed
= note: module `$TEST_BUILD_DIR/lang/core/ptr/allocate_const_scalar.stage-id.spv.dir/module`

error: aborting due to 2 previous errors
error: aborting due to previous error