summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 24b7b9f97f9..4b96aa13d00 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1010,6 +1010,7 @@ class X86_32ABIInfo : public SwiftABIInfo {
bool IsWin32StructABI;
bool IsSoftFloatABI;
bool IsMCUABI;
+ bool IsLinuxABI;
unsigned DefaultNumRegisterParameters;
static bool isRegisterSize(unsigned Size) {
@@ -1076,6 +1077,7 @@ public:
IsWin32StructABI(Win32StructABI),
IsSoftFloatABI(SoftFloatABI),
IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
+ IsLinuxABI(CGT.getTarget().getTriple().isOSLinux()),
DefaultNumRegisterParameters(NumRegisterParameters) {}
bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> scalars,
@@ -1492,8 +1494,15 @@ unsigned X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty,
if (Align <= MinABIStackAlignInBytes)
return 0; // Use default alignment.
- // On non-Darwin, the stack type alignment is always 4.
- if (!IsDarwinVectorABI) {
+ if (IsLinuxABI) {
+ // i386 System V ABI 2.1: Structures and unions assume the alignment of their
+ // most strictly aligned component.
+ //
+ // Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
+ // want to spend any effort dealing with the ramifications of ABI breaks.
+ return Align;
+ } else if (!IsDarwinVectorABI) {
+ // On non-Darwin and non-Linux, the stack type alignment is always 4.
// Set explicit alignment, since we may need to realign the top.
return MinABIStackAlignInBytes;
}
OpenPOWER on IntegriCloud