Skip to content

Commit cb223c7

Browse files
committed
Gate bounds/precondition panic-entry detection to non-local core symbols
1 parent bf414e8 commit cb223c7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • crates/rustc_codegen_spirv/src/codegen_cx

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
1919
use rustc_middle::ty::{self, Instance, TypeVisitableExt, TypingEnv};
2020
use rustc_span::Span;
2121
use rustc_span::def_id::DefId;
22+
use rustc_span::symbol::sym;
2223

2324
fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
2425
let mut control = FunctionControl::NONE;
@@ -227,10 +228,11 @@ impl<'tcx> CodegenCx<'tcx> {
227228
{
228229
self.panic_entry_points.borrow_mut().insert(def_id);
229230
}
230-
if demangled_symbol_name.ends_with("::precondition_check") {
231+
let is_nonlocal_core = !def_id.is_local() && self.tcx.crate_name(def_id.krate) == sym::core;
232+
if is_nonlocal_core && demangled_symbol_name.ends_with("::precondition_check") {
231233
self.panic_entry_points.borrow_mut().insert(def_id);
232234
}
233-
if demangled_symbol_name.contains("::bounds_check") {
235+
if is_nonlocal_core && demangled_symbol_name.ends_with("::bounds_check") {
234236
self.panic_entry_points.borrow_mut().insert(def_id);
235237
}
236238
if let Some(pieces_len) = demangled_symbol_name

0 commit comments

Comments
 (0)