Skip to content

Commit 1ee244b

Browse files
committed
Support panic_nounwind_fmt as well (not just panic_nounwind).
1 parent 1932353 commit 1ee244b

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,22 +2818,34 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28182818
kind: SpirvValueKind::Def(b_id),
28192819
..
28202820
},
2821-
// NOTE(fee1-dead): the standard `panic` takes in a `Location` due to `track_caller`.
2822-
// but for `panic_nounwind` it does not, therefore we only look at the first two arguments.
2823-
] = args[..2]
2821+
ref other_args @ ..,
2822+
] = args[..]
28242823
{
2825-
if let Some(const_msg) = const_str_as_utf8(&[a_id, b_id]) {
2826-
decoded_format_args.const_pieces = Some([const_msg].into_iter().collect());
2827-
return Ok(decoded_format_args);
2824+
// Optional `&'static panic::Location<'static>`.
2825+
if other_args.len() <= 1 {
2826+
if let Some(const_msg) = const_str_as_utf8(&[a_id, b_id]) {
2827+
decoded_format_args.const_pieces =
2828+
Some([const_msg].into_iter().collect());
2829+
return Ok(decoded_format_args);
2830+
}
28282831
}
28292832
}
28302833

2831-
let format_args_id = match args {
2832-
&[
2834+
let format_args_id = match *args {
2835+
// HACK(eddyb) `panic_nounwind_fmt` takes an extra argument.
2836+
[
2837+
SpirvValue {
2838+
kind: SpirvValueKind::Def(format_args_id),
2839+
..
2840+
},
2841+
_, // `&'static panic::Location<'static>`
2842+
]
2843+
| [
28332844
SpirvValue {
28342845
kind: SpirvValueKind::Def(format_args_id),
28352846
..
28362847
},
2848+
_, // `force_no_backtrace: bool`
28372849
_, // `&'static panic::Location<'static>`
28382850
] => format_args_id,
28392851

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ impl<'tcx> CodegenCx<'tcx> {
190190

191191
// HACK(eddyb) there is no good way to identify these definitions
192192
// (e.g. no `#[lang = "..."]` attribute), but this works well enough.
193-
if [
194-
"<core::fmt::Arguments>::new_v1",
195-
"<core::fmt::Arguments>::new_const",
196-
]
197-
.contains(&&demangled_symbol_name[..])
198-
{
199-
self.fmt_args_new_fn_ids.borrow_mut().insert(fn_id);
193+
match &demangled_symbol_name[..] {
194+
"core::panicking::panic_nounwind_fmt" => {
195+
self.panic_entry_points.borrow_mut().insert(def_id);
196+
}
197+
"<core::fmt::Arguments>::new_v1" | "<core::fmt::Arguments>::new_const" => {
198+
self.fmt_args_new_fn_ids.borrow_mut().insert(fn_id);
199+
}
200+
_ => {}
200201
}
201202

202203
// HACK(eddyb) there is no good way to identify these definitions

0 commit comments

Comments
 (0)