git: d1470ac7f365 - main - Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Thu, 19 Nov 2026 08:20:54 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/src/commit/?id=d1470ac7f365a1846b8cc565b76592c7a79a22e3

commit d1470ac7f365a1846b8cc565b76592c7a79a22e3
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-11-17 16:28:06 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-19 08:20:49 +0000

    Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):
    
      [PowerPC] Use the 16-byte stack and vector alignment on FreeBSD (#232336)
    
      FreeBSD uses the ELFv2 ABI on both byte orders, so it has the same
      16-byte stack alignment as Linux. The explicit vector alignment is a
      backend workaround that does not depend on the OS. There is no
      reason for the layouts to differ.
    
    llvm 21 still keeps the data layout in two places, so the check is
    changed in both the PowerPC backend and clang. They have to match, or
    clang errors out with a data layout mismatch.
    
    Reviewed by:    dim
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D61678
---
 contrib/llvm-project/clang/lib/Basic/Targets/PPC.h                | 2 +-
 contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
index 5c47e0dca666..6da3adb61fb5 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
@@ -478,7 +478,7 @@ public:
       LongDoubleFormat = &llvm::APFloat::IEEEdouble();
     }
 
-    if (Triple.isOSAIX() || Triple.isOSLinux())
+    if (Triple.isOSAIX() || Triple.isOSLinux() || Triple.isOSFreeBSD())
       DataLayout += "-S128-v256:256:256-v512:512:512";
     resetDataLayout(DataLayout);
 
diff --git a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index b5c6ac111dff..484fbbebf060 100644
--- a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -195,7 +195,9 @@ static std::string getDataLayoutString(const Triple &T) {
   // Specify the vector alignment explicitly. For v256i1 and v512i1, the
   // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
   // which is 256 and 512 bytes - way over aligned.
-  if (is64Bit && (T.isOSAIX() || T.isOSLinux()))
+  // FreeBSD uses the ELFv2 ABI and has the same 16-byte stack alignment as
+  // Linux.
+  if (is64Bit && (T.isOSAIX() || T.isOSLinux() || T.isOSFreeBSD()))
     Ret += "-S128-v256:256:256-v512:512:512";
 
   return Ret;