Skip to content

Commit 39b8b2b

Browse files
committed
Remove StructRet arg attr
It is applied exactly when the return value has an indirect pass mode. Except for InReg on x86 fastcall, arg attrs are now only used for optimization purposes and thus are fine to ignore.
1 parent 42b0b80 commit 39b8b2b

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ArgAttributeExt for ArgAttribute {
3636
where
3737
F: FnMut(llvm::Attribute),
3838
{
39-
for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, StructRet, InReg)
39+
for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, InReg)
4040
}
4141
}
4242

@@ -429,7 +429,8 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
429429
}
430430
PassMode::Indirect { ref attrs, extra_attrs: _, on_stack } => {
431431
assert!(!on_stack);
432-
apply(attrs);
432+
let i = apply(attrs);
433+
llvm::Attribute::StructRet.apply_llfn(llvm::AttributePlace::Argument(i), llfn);
433434
}
434435
_ => {}
435436
}
@@ -484,7 +485,9 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
484485
}
485486
PassMode::Indirect { ref attrs, extra_attrs: _, on_stack } => {
486487
assert!(!on_stack);
487-
apply(attrs);
488+
let i = apply(attrs);
489+
llvm::Attribute::StructRet
490+
.apply_callsite(llvm::AttributePlace::Argument(i), callsite);
488491
}
489492
_ => {}
490493
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,10 +2801,6 @@ where
28012801
for arg in &mut self.args {
28022802
fixup(arg, false);
28032803
}
2804-
if let PassMode::Indirect { ref mut attrs, extra_attrs: _, on_stack: _ } = self.ret.mode
2805-
{
2806-
attrs.set(ArgAttribute::StructRet);
2807-
}
28082804
return;
28092805
}
28102806

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ mod attr_impl {
5959
const NoCapture = 1 << 2;
6060
const NonNull = 1 << 3;
6161
const ReadOnly = 1 << 4;
62-
const StructRet = 1 << 6;
6362
const InReg = 1 << 8;
6463
}
6564
}
@@ -619,10 +618,6 @@ impl<'a, Ty> FnAbi<'a, Ty> {
619618
a => return Err(format!("unrecognized arch \"{}\" in target specification", a)),
620619
}
621620

622-
if let PassMode::Indirect { ref mut attrs, extra_attrs: _, on_stack: _ } = self.ret.mode {
623-
attrs.set(ArgAttribute::StructRet);
624-
}
625-
626621
Ok(())
627622
}
628623
}

0 commit comments

Comments
 (0)