Skip to content

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Sep 14, 2025

@llvmbot
Copy link
Member

llvmbot commented Sep 14, 2025

@llvm/pr-subscribers-backend-x86

Author: Brad Smith (brad0)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/158454.diff

2 Files Affected:

  • (modified) llvm/lib/Target/X86/X86Subtarget.cpp (+3-2)
  • (modified) llvm/test/CodeGen/X86/stack-align2.ll (+5)
diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index fd5f34b60efb8..3ab765b35be44 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -284,12 +284,13 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
     reportFatalUsageError("64-bit code requested on a subtarget that doesn't "
                           "support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD, and for all
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD, Hurd and for all
   // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
   // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
     stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() || Is64Bit)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+           isOSHurd() || Is64Bit)
     stackAlignment = Align(16);
 
   // Consume the vector width attribute or apply any target specific limit.
diff --git a/llvm/test/CodeGen/X86/stack-align2.ll b/llvm/test/CodeGen/X86/stack-align2.ll
index 095a9090ed08f..de1f9f4bcad46 100644
--- a/llvm/test/CodeGen/X86/stack-align2.ll
+++ b/llvm/test/CodeGen/X86/stack-align2.ll
@@ -1,10 +1,12 @@
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux | FileCheck %s -check-prefix=LINUX-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-I386
+; RUN: llc < %s -mcpu=generic -mtriple=i386-gnu | FileCheck %s -check-prefix=HURD-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-netbsd | FileCheck %s -check-prefix=NETBSD-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i686-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-pc-solaris2.11 | FileCheck %s -check-prefix=SOLARIS-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s -check-prefix=LINUX-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-X86_64
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-gnu | FileCheck %s -check-prefix=HURD-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-netbsd | FileCheck %s -check-prefix=NETBSD-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-solaris2.11 | FileCheck %s -check-prefix=SOLARIS-X86_64
@@ -17,6 +19,7 @@ entry:
 ; LINUX-I386:     subl	$12, %esp
 ; KFREEBSD-I386:  subl	$12, %esp
 ; DARWIN-I386:    subl	$12, %esp
+; HURD-I386:      subl  $12, %esp
 ; NETBSD-I386-NOT:  subl	{{.*}}, %esp
 ; SOLARIS-I386-NOT: subl	{{.*}}, %esp
 
@@ -30,6 +33,8 @@ entry:
 ; SOLARIS-X86_64-NOT: subq	{{.*}}, %rsp
 ; KFREEBSD-X86_64:     pushq %{{.*}}
 ; KFREEBSD-X86_64-NOT: subq	{{.*}}, %rsp
+; HURD-X86_64:       pushq %{{.*}}
+; HURD-X86_64-NOT:   subq       {{.*}}, %rsp
 }
 
 declare void @test2()

@brad0 brad0 force-pushed the hurd_x86_alignment branch from ddfc676 to 3950ec9 Compare September 14, 2025 04:35
@brad0
Copy link
Contributor Author

brad0 commented Sep 22, 2025

cc @sthibaul

@sthibaul
Copy link
Contributor

Yes, please! We are now seeing various SSE2 baselines, just like on Linux.

@brad0 brad0 merged commit 8323ff0 into llvm:main Sep 22, 2025
9 of 10 checks passed
@brad0 brad0 deleted the hurd_x86_alignment branch September 22, 2025 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants