Skip to content

Commit 8323ff0

Browse files
authored
Default stack alignment of X86 Hurd to 16 bytes (#158454)
https://sourceware.org/bugzilla/show_bug.cgi?id=21120
1 parent 583256d commit 8323ff0

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

llvm/lib/Target/X86/X86Subtarget.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,13 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
284284
reportFatalUsageError("64-bit code requested on a subtarget that doesn't "
285285
"support it!");
286286

287-
// Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD, and for all
287+
// Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD, Hurd and for all
288288
// 64-bit targets. On Solaris (32-bit), stack alignment is 4 bytes
289289
// following the i386 psABI, while on Illumos it is always 16 bytes.
290290
if (StackAlignOverride)
291291
stackAlignment = *StackAlignOverride;
292-
else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() || Is64Bit)
292+
else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
293+
isTargetHurd() || Is64Bit)
293294
stackAlignment = Align(16);
294295

295296
// Consume the vector width attribute or apply any target specific limit.

llvm/lib/Target/X86/X86Subtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class X86Subtarget final : public X86GenSubtargetInfo {
291291

292292
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
293293
bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
294+
bool isTargetHurd() const { return TargetTriple.isOSHurd(); }
294295
bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
295296
bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
296297
bool isTargetMCU() const { return TargetTriple.isOSIAMCU(); }

llvm/test/CodeGen/X86/stack-align2.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
; RUN: llc < %s -mcpu=generic -mtriple=i386-linux | FileCheck %s -check-prefix=LINUX-I386
22
; RUN: llc < %s -mcpu=generic -mtriple=i386-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-I386
3+
; RUN: llc < %s -mcpu=generic -mtriple=i386-hurd | FileCheck %s -check-prefix=HURD-I386
34
; RUN: llc < %s -mcpu=generic -mtriple=i386-netbsd | FileCheck %s -check-prefix=NETBSD-I386
45
; RUN: llc < %s -mcpu=generic -mtriple=i686-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-I386
56
; RUN: llc < %s -mcpu=generic -mtriple=i386-pc-solaris2.11 | FileCheck %s -check-prefix=SOLARIS-I386
67
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s -check-prefix=LINUX-X86_64
78
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-X86_64
9+
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-hurd | FileCheck %s -check-prefix=HURD-X86_64
810
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-netbsd | FileCheck %s -check-prefix=NETBSD-X86_64
911
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-X86_64
1012
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-solaris2.11 | FileCheck %s -check-prefix=SOLARIS-X86_64
@@ -17,6 +19,7 @@ entry:
1719
; LINUX-I386: subl $12, %esp
1820
; KFREEBSD-I386: subl $12, %esp
1921
; DARWIN-I386: subl $12, %esp
22+
; HURD-I386: subl $12, %esp
2023
; NETBSD-I386-NOT: subl {{.*}}, %esp
2124
; SOLARIS-I386-NOT: subl {{.*}}, %esp
2225

@@ -30,6 +33,8 @@ entry:
3033
; SOLARIS-X86_64-NOT: subq {{.*}}, %rsp
3134
; KFREEBSD-X86_64: pushq %{{.*}}
3235
; KFREEBSD-X86_64-NOT: subq {{.*}}, %rsp
36+
; HURD-X86_64: pushq %{{.*}}
37+
; HURD-X86_64-NOT: subq {{.*}}, %rsp
3338
}
3439

3540
declare void @test2()

0 commit comments

Comments
 (0)