Skip to content

Commit 34e1c90

Browse files
committed
Improve abort/panic messages to be more distinctive.
1 parent 883d5aa commit 34e1c90

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
26482648
// HACK(eddyb) redirect any possible panic call to an abort, to avoid
26492649
// needing to materialize `&core::panic::Location` or `format_args!`.
26502650
// FIXME(eddyb) find a way to extract the original message.
2651-
self.abort_with_message("panic!(...)".into());
2651+
self.abort_with_message("panicked: <unknown message>".into());
26522652
self.undef(result_type)
26532653
} else if let Some(mode) = buffer_load_intrinsic {
26542654
self.codegen_buffer_load_intrinsic(result_type, args, mode)

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
339339
}
340340

341341
fn abort(&mut self) {
342-
self.abort_with_message("intrinsics::abort()".into());
342+
self.abort_with_message("aborted: intrinsics::abort() called".into());
343343
}
344344

345345
fn assume(&mut self, _val: Self::Value) {

crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,16 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points(
330330
let mut fmt = String::new();
331331

332332
// HACK(eddyb) this improves readability w/ very verbose Vulkan loggers.
333-
fmt += "\n ";
333+
fmt += "\n";
334334

335+
fmt += "[RUST-GPU] ";
336+
fmt += &cx[const_str(message)].replace('%', "%%");
337+
338+
// FIXME(eddyb) deduplicate with "called at" form below
339+
// (not trivial becasue both closures would borrow `fmt`).
335340
if let Some((file, line, col)) = current_debug_src_loc.take() {
336-
fmt += &format!("{file}:{line}:{col}: ").replace('%', "%%");
341+
fmt += &format!("\n at {file}:{line}:{col}").replace('%', "%%");
337342
}
338-
fmt += &cx[const_str(message)].replace('%', "%%");
339343

340344
let mut innermost = true;
341345
let mut append_call = |callsite_debug_src_loc, callee: &str| {
@@ -360,6 +364,8 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points(
360364
}
361365
append_call(None, &debug_printf_context_fmt_str);
362366

367+
fmt += "\n";
368+
363369
let abort_inst_def = &mut func_def_body.data_insts[abort_inst];
364370
abort_inst_def.kind = DataInstKind::SpvExtInst {
365371
ext_set: cx.intern("NonSemantic.DebugPrintf"),

0 commit comments

Comments
 (0)