about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-22 19:29:38 +0100
committerGitHub <noreply@github.com>2025-01-22 19:29:38 +0100
commitdf0104086036faac8a8f080572e0b057f507bd52 (patch)
tree46b561a6a70c155d7e1adbc8ebfb002494cf6fa8
parentcd1f36b020c77f600132972c853fd9d3dda1dacd (diff)
parent7bfcddf479d044b06fdb90855232e06d69d251bb (diff)
downloadrust-df0104086036faac8a8f080572e0b057f507bd52.tar.gz
rust-df0104086036faac8a8f080572e0b057f507bd52.zip
Rollup merge of #134396 - mustartt:byval-pointer-natural-alignment, r=wesleywiser
AIX: use align 8 for byval parameter

On AIX, byval pointer arguments are aligned to 8 bytes based on the 64bit register size. For example, the C callee https://godbolt.org/z/5f4vnG6bh will expect the following argument.

```
ptr nocapture noundef readonly byval(%struct.TwoU64s) align 8 %0
```

This case is captured by `run-make/extern-fn-explicit-align`
-rw-r--r--compiler/rustc_target/src/callconv/powerpc64.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/callconv/powerpc64.rs b/compiler/rustc_target/src/callconv/powerpc64.rs
index 3a71592cbe0..92c1f6e7148 100644
--- a/compiler/rustc_target/src/callconv/powerpc64.rs
+++ b/compiler/rustc_target/src/callconv/powerpc64.rs
@@ -58,8 +58,10 @@ where
 
     // The AIX ABI expect byval for aggregates
     // See https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/Targets/PPC.cpp.
+    // The incoming parameter is represented as a pointer in the IR,
+    // the alignment is associated with the size of the register. (align 8 for 64bit)
     if !is_ret && abi == AIX {
-        arg.pass_by_stack_offset(None);
+        arg.pass_by_stack_offset(Some(Align::from_bytes(8).unwrap()));
         return;
     }