@@ -3,6 +3,7 @@ use std::iter;
3
3
use rustc_abi:: Primitive :: Pointer ;
4
4
use rustc_abi:: { BackendRepr , ExternAbi , PointerKind , Scalar , Size } ;
5
5
use rustc_hir as hir;
6
+ use rustc_hir:: attrs:: InlineAttr ;
6
7
use rustc_hir:: lang_items:: LangItem ;
7
8
use rustc_middle:: bug;
8
9
use rustc_middle:: query:: Providers ;
@@ -275,6 +276,7 @@ fn arg_attrs_for_rust_scalar<'tcx>(
275
276
offset : Size ,
276
277
is_return : bool ,
277
278
drop_target_pointee : Option < Ty < ' tcx > > ,
279
+ is_inline : bool ,
278
280
) -> ArgAttributes {
279
281
let mut attrs = ArgAttributes :: new ( ) ;
280
282
@@ -348,9 +350,10 @@ fn arg_attrs_for_rust_scalar<'tcx>(
348
350
PointerKind :: MutableRef { unpin } => unpin && noalias_mut_ref,
349
351
PointerKind :: Box { unpin, global } => unpin && global && noalias_for_box,
350
352
} ;
353
+
351
354
// We can never add `noalias` in return position; that LLVM attribute has some very surprising semantics
352
355
// (see <https://github.com/rust-lang/unsafe-code-guidelines/issues/385#issuecomment-1368055745>).
353
- if no_alias && !is_return {
356
+ if no_alias && !is_inline && ! is_return {
354
357
attrs. set ( ArgAttribute :: NoAlias ) ;
355
358
}
356
359
@@ -509,6 +512,11 @@ fn fn_abi_new_uncached<'tcx>(
509
512
extra_args
510
513
} ;
511
514
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 :: Hint || inline_attrs == InlineAttr :: Always
518
+ } ) ;
519
+
512
520
let is_drop_in_place = determined_fn_def_id. is_some_and ( |def_id| {
513
521
tcx. is_lang_item ( def_id, LangItem :: DropInPlace )
514
522
|| tcx. is_lang_item ( def_id, LangItem :: AsyncDropInPlace )
@@ -535,7 +543,15 @@ fn fn_abi_new_uncached<'tcx>(
535
543
} ;
536
544
537
545
let mut arg = ArgAbi :: new ( cx, layout, |layout, scalar, offset| {
538
- arg_attrs_for_rust_scalar ( * cx, scalar, * layout, offset, is_return, drop_target_pointee)
546
+ arg_attrs_for_rust_scalar (
547
+ * cx,
548
+ scalar,
549
+ * layout,
550
+ offset,
551
+ is_return,
552
+ drop_target_pointee,
553
+ is_inline,
554
+ )
539
555
} ) ;
540
556
541
557
if arg. layout . is_zst ( ) {
0 commit comments