From c83e5679b3cef0beca335f8e010af491335b4c82 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Aug 2023 15:45:48 +0200 Subject: [PATCH] Don't generate __restrict__ attribute for ByValue arguments --- src/abi.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 8f5cd30fe3c7..874ac0b087e8 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -123,7 +123,6 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { #[cfg(feature = "master")] let apply_attrs = |ty: Type<'gcc>, attrs: &ArgAttributes| { if attrs.regular.contains(rustc_target::abi::call::ArgAttribute::NoAlias) - && ty.get_pointee().is_some() { ty.make_restrict() } else { @@ -151,9 +150,10 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { let ty = cast.gcc_type(cx); apply_attrs(ty, &cast.attrs) } - PassMode::Indirect { attrs, extra_attrs: None, on_stack: true } => { + PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: true } => { + // This is a "byval" argument, so we don't apply the `restrict` attribute on it. on_stack_param_indices.insert(argument_tys.len()); - apply_attrs(arg.memory_ty(cx), &attrs) + arg.memory_ty(cx) }, PassMode::Direct(attrs) => apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs), PassMode::Indirect { attrs, extra_attrs: None, on_stack: false } => {