[llvm] 5f2b276 - Default stack alignment of x86 NaCl to 16 bytes

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Tue May 18 15:17:40 PDT 2021


Author: Fabian Sommer
Date: 2021-05-18T15:16:59-07:00
New Revision: 5f2b27666797c6462641434fee7ee010c77d22c0

URL: https://github.com/llvm/llvm-project/commit/5f2b27666797c6462641434fee7ee010c77d22c0
DIFF: https://github.com/llvm/llvm-project/commit/5f2b27666797c6462641434fee7ee010c77d22c0.diff

LOG: Default stack alignment of x86 NaCl to 16 bytes

X86 NaCl generally requires the stack to be aligned to 16 bytes.
This change was already implemented in two downstream NaCl compilers
based on llvm.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D102610

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86Subtarget.cpp
    llvm/test/CodeGen/X86/stack-align2.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index c95213c3539d..4af0ac238f59 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -265,13 +265,13 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
     report_fatal_error("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, NaCl, 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() ||
-           In64BitMode)
+           isTargetNaCl() || In64BitMode)
     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 095a9090ed08..99f36d2ca8b7 100644
--- a/llvm/test/CodeGen/X86/stack-align2.ll
+++ b/llvm/test/CodeGen/X86/stack-align2.ll
@@ -3,11 +3,13 @@
 ; 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=i386-nacl | FileCheck %s -check-prefix=NACL-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-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
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-nacl | FileCheck %s -check-prefix=NACL-X86_64
 
 define i32 @test() nounwind {
 entry:
@@ -17,6 +19,7 @@ entry:
 ; LINUX-I386:     subl	$12, %esp
 ; KFREEBSD-I386:  subl	$12, %esp
 ; DARWIN-I386:    subl	$12, %esp
+; NACL-I386:      subl	$12, %esp
 ; NETBSD-I386-NOT:  subl	{{.*}}, %esp
 ; SOLARIS-I386-NOT: subl	{{.*}}, %esp
 
@@ -24,6 +27,8 @@ entry:
 ; LINUX-X86_64-NOT:  subq	{{.*}}, %rsp
 ; DARWIN-X86_64:     pushq %{{.*}}
 ; DARWIN-X86_64-NOT: subq	{{.*}}, %rsp
+; NACL-X86_64:       pushq %{{.*}}
+; NACL-X86_64-NOT:   subq	{{.*}}, %rsp
 ; NETBSD-X86_64:     pushq %{{.*}}
 ; NETBSD-X86_64-NOT: subq	{{.*}}, %rsp
 ; SOLARIS-X86_64:     pushq %{{.*}}


        


More information about the llvm-commits mailing list