git: 4d0163d6063c - stable/14 - Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Tue, 24 Nov 2026 17:21:33 UTC
The branch stable/14 has been updated by pkubaj:

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

commit 4d0163d6063c67a0062c1ed9a29cb84da0b6eb41
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-11-17 16:28:06 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-24 16:11:13 +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
    
    (cherry picked from commit d1470ac7f365a1846b8cc565b76592c7a79a22e3)
---
 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 9f3a4cd2da71..2eee8688db47 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
@@ -473,7 +473,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;