]> granicus.if.org Git - clang/commitdiff
For X86-64 linux and PPC64 linux align int128 to 16 bytes.
authorEric Christopher <echristo@gmail.com>
Fri, 10 Feb 2017 03:32:34 +0000 (03:32 +0000)
committerEric Christopher <echristo@gmail.com>
Fri, 10 Feb 2017 03:32:34 +0000 (03:32 +0000)
For other platforms we should find out what they need and likely
make the same change, however, a smaller additional change is easier
for platforms we know have it specified in the ABI.

clang support for r294702

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/CodeGen/target-data.c
test/CodeGen/thinlto-multi-module.ll
test/CodeGen/thinlto_backend.ll

index f03e7e192480ac02e71caf57493b9f7c9a5d52eb..a359ec2088cf420e639d4882797d38452d49482a 100644 (file)
@@ -1673,15 +1673,35 @@ public:
     IntMaxType = SignedLong;
     Int64Type = SignedLong;
 
-    if ((Triple.getArch() == llvm::Triple::ppc64le)) {
-      resetDataLayout("e-m:e-i64:64-n32:64");
+    std::string Layout;
+
+    // PPC64LE is little endian.
+    if (Triple.getArch() == llvm::Triple::ppc64le)
+      Layout = "e";
+    else
+      Layout = "E";
+
+    Layout += llvm::DataLayout::getManglingComponent(Triple);
+
+    Layout += "-i64:64";
+
+    // 128 bit integers are always aligned to 128 bits, but only 64-bit matters,
+    // because __int128 is only supoprted on 64-bit targets.
+    // FIXME: See if this is valid on other 64-bit ppc oses.
+    if (Triple.isOSLinux())
+      Layout += "-i128:128";
+
+    Layout += "-n32:64";
+
+    resetDataLayout(Layout);
+
+    // PPC64LE started a new ABI.
+    if (Triple.getArch() == llvm::Triple::ppc64le)
       ABI = "elfv2";
-    } else {
-      resetDataLayout("E-m:e-i64:64-n32:64");
+    else
       ABI = "elfv1";
-    }
 
-    switch (getTriple().getOS()) {
+    switch (Triple.getOS()) {
     case llvm::Triple::FreeBSD:
       LongDoubleWidth = LongDoubleAlign = 64;
       LongDoubleFormat = &llvm::APFloat::IEEEdouble();
@@ -4581,11 +4601,21 @@ public:
     Int64Type   = IsX32 ? SignedLongLong   : SignedLong;
     RegParmMax = 6;
 
+    // Use 128-bit alignment for 128-bit integers in linux.
+    // FIXME: Figure out if we should change this for other oses.
     // Pointers are 32-bit in x32.
-    resetDataLayout(IsX32
-                        ? "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128"
-                        : IsWinCOFF ? "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-                                    : "e-m:e-i64:64-f80:128-n8:16:32:64-S128");
+    if (IsX32) {
+      if (Triple.isOSLinux())
+        resetDataLayout(
+            "e-m:e-p:32:32-i64:64-i128:128-f80:128-n8:16:32:64-S128");
+      else
+       resetDataLayout("e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128");
+    } else if (IsWinCOFF)
+      resetDataLayout("e-m:w-i64:64-f80:128-n8:16:32:64-S128");
+    else if (Triple.isOSLinux())
+      resetDataLayout("e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128");
+    else
+      resetDataLayout("e-m:e-i64:64-f80:128-n8:16:32:64-S128");
 
     // Use fpret only for long double.
     RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble);
index 1e8ce6a2fd12f4fc2f37bf44ac75f31475b12581..8f8b9e1f8b6d19f964d402516fd402cf7dcb1c93 100644 (file)
 
 // RUN: %clang_cc1 -triple powerpc64-linux -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC64-LINUX
-// PPC64-LINUX: target datalayout = "E-m:e-i64:64-n32:64"
+// PPC64-LINUX: target datalayout = "E-m:e-i64:64-i128:128-n32:64"
 
 // RUN: %clang_cc1 -triple powerpc64le-linux -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC64LE-LINUX
-// PPC64LE-LINUX: target datalayout = "e-m:e-i64:64-n32:64"
+// PPC64LE-LINUX: target datalayout = "e-m:e-i64:64-i128:128-n32:64"
 
 // RUN: %clang_cc1 -triple powerpc-darwin -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC32-DARWIN
index 21d28cf44da2544dd92f4d3602244fdb0daa362e..127426ab3d03a35997f9d685519e5db4d60413fd 100644 (file)
@@ -11,7 +11,7 @@
 ; CHECK-OBJ: T f1
 ; CHECK-OBJ: U f2
 
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target datalayout = "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
 declare void @f2()
index ac0b3b76ef7d1c0d3bfbf70b3a2dfdd0a729018f..e2c7f105e827637e15c7c5b96125a72880d68459 100644 (file)
@@ -31,7 +31,7 @@
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR2
 ; CHECK-ERROR2: Error loading imported file '{{.*}}': Could not find module summary
 
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target datalayout = "e-m:e-i64:64-i128:128-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
 declare void @f2()