@@ -474,9 +474,10 @@ fn fn_abi_new_uncached<'tcx>(
474474 let ( caller_location, determined_fn_def_id, is_virtual_call) = if let Some ( instance) = instance
475475 {
476476 let is_virtual_call = matches ! ( instance. def, ty:: InstanceKind :: Virtual ( ..) ) ;
477+ let is_tls_shim_call = matches ! ( instance. def, ty:: InstanceKind :: ThreadLocalShim ( _) ) ;
477478 (
478479 instance. def . requires_caller_location ( tcx) . then ( || tcx. caller_location_ty ( ) ) ,
479- if is_virtual_call { None } else { Some ( instance. def_id ( ) ) } ,
480+ if is_virtual_call || is_tls_shim_call { None } else { Some ( instance. def_id ( ) ) } ,
480481 is_virtual_call,
481482 )
482483 } else {
@@ -556,6 +557,7 @@ fn fn_abi_new_uncached<'tcx>(
556557 c_variadic : sig. c_variadic ,
557558 fixed_count : inputs. len ( ) as u32 ,
558559 conv,
560+ // FIXME return false for tls shim
559561 can_unwind : fn_can_unwind (
560562 tcx,
561563 // Since `#[rustc_nounwind]` can change unwinding, we cannot infer unwinding by `fn_def_id` for a virtual call.
@@ -568,8 +570,9 @@ fn fn_abi_new_uncached<'tcx>(
568570 & mut fn_abi,
569571 sig. abi ,
570572 // If this is a virtual call, we cannot pass the `fn_def_id`, as it might call other
571- // functions from vtable. Internally, `deduced_param_attrs` attempts to infer attributes by
572- // visit the function body.
573+ // functions from vtable. And for a tls shim, passing the `fn_def_id` would refer to
574+ // the underlying static. Internally, `deduced_param_attrs` attempts to infer attributes
575+ // by visit the function body.
573576 determined_fn_def_id,
574577 ) ;
575578 debug ! ( "fn_abi_new_uncached = {:?}" , fn_abi) ;
0 commit comments