@@ -3,7 +3,6 @@ use std::iter;
33use rustc_abi:: Primitive :: Pointer ;
44use rustc_abi:: { BackendRepr , ExternAbi , PointerKind , Scalar , Size } ;
55use rustc_hir as hir;
6- use rustc_hir:: attrs:: InlineAttr ;
76use rustc_hir:: lang_items:: LangItem ;
87use rustc_middle:: bug;
98use rustc_middle:: query:: Providers ;
@@ -276,7 +275,7 @@ fn arg_attrs_for_rust_scalar<'tcx>(
276275 offset : Size ,
277276 is_return : bool ,
278277 drop_target_pointee : Option < Ty < ' tcx > > ,
279- is_inline : bool ,
278+ involves_raw_ptr : bool ,
280279) -> ArgAttributes {
281280 let mut attrs = ArgAttributes :: new ( ) ;
282281
@@ -353,7 +352,7 @@ fn arg_attrs_for_rust_scalar<'tcx>(
353352
354353 // We can never add `noalias` in return position; that LLVM attribute has some very surprising semantics
355354 // (see <https://github.com/rust-lang/unsafe-code-guidelines/issues/385#issuecomment-1368055745>).
356- if no_alias && !is_inline && !is_return {
355+ if no_alias && !involves_raw_ptr && !is_return {
357356 attrs. set ( ArgAttribute :: NoAlias ) ;
358357 }
359358
@@ -512,10 +511,13 @@ fn fn_abi_new_uncached<'tcx>(
512511 extra_args
513512 } ;
514513
515- let is_inline = determined_fn_def_id. is_some_and ( |def_id| {
516- let inline_attrs = tcx. codegen_fn_attrs ( def_id) . inline ;
517- inline_attrs == InlineAttr :: Always
518- } ) ;
514+ let involves_raw_ptr = inputs
515+ . iter ( )
516+ . copied ( )
517+ . chain ( extra_args. iter ( ) . copied ( ) )
518+ . chain ( caller_location)
519+ . chain ( Some ( sig. output ( ) ) )
520+ . any ( |ty| matches ! ( ty. kind( ) , ty:: RawPtr ( _, _) ) ) ;
519521
520522 let is_drop_in_place = determined_fn_def_id. is_some_and ( |def_id| {
521523 tcx. is_lang_item ( def_id, LangItem :: DropInPlace )
@@ -550,7 +552,7 @@ fn fn_abi_new_uncached<'tcx>(
550552 offset,
551553 is_return,
552554 drop_target_pointee,
553- is_inline ,
555+ involves_raw_ptr ,
554556 )
555557 } ) ;
556558
0 commit comments