[pkg-d-commits] [ldc] 16/149: Fix ABI issue #1925 (#1938)

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.2.0
in repository ldc.

commit feb4ebd1adc78047cea8cfd79608ef4c986a5486
Author: kinke <kinke at users.noreply.github.com>
Date:   Thu Dec 22 18:04:01 2016 +0100

    Fix ABI issue #1925 (#1938)
---
 gen/abi-x86-64.cpp                   | 36 +++++++++++++++++++-----------------
 tests/codegen/array_literal_gh1924.d | 18 ++++++++++++++++++
 2 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp
index 04796c1..42f32a0 100644
--- a/gen/abi-x86-64.cpp
+++ b/gen/abi-x86-64.cpp
@@ -116,25 +116,27 @@ struct RegCount {
         int_regs += elementRegCount.int_regs;
         sse_regs += elementRegCount.sse_regs;
       }
-
-      assert(int_regs + sse_regs <= 2);
-    } else { // not a struct
-      if (ty->isIntegerTy() || ty->isPointerTy()) {
-        ++int_regs;
-      } else if (ty->isFloatingPointTy() || ty->isVectorTy()) {
-        // X87 reals are passed on the stack
-        if (!ty->isX86_FP80Ty()) {
-          ++sse_regs;
-        }
-      } else {
-        unsigned sizeInBits = gDataLayout->getTypeSizeInBits(ty);
-        IF_LOG Logger::cout()
-            << "SysV RegCount: assuming 1 GP register for type " << *ty << " ("
-            << sizeInBits << " bits)\n";
-        assert(sizeInBits > 0 && sizeInBits <= 64);
-        ++int_regs;
+    } else if (LLArrayType *arrayTy = isaArray(ty)) {
+      char N = static_cast<char>(arrayTy->getNumElements());
+      RegCount elementRegCount(arrayTy->getElementType());
+      int_regs = N * elementRegCount.int_regs;
+      sse_regs = N * elementRegCount.sse_regs;
+    } else if (ty->isIntegerTy() || ty->isPointerTy()) {
+      ++int_regs;
+    } else if (ty->isFloatingPointTy() || ty->isVectorTy()) {
+      // X87 reals are passed on the stack
+      if (!ty->isX86_FP80Ty()) {
+        ++sse_regs;
       }
+    } else {
+      unsigned sizeInBits = gDataLayout->getTypeSizeInBits(ty);
+      IF_LOG Logger::cout() << "SysV RegCount: assuming 1 GP register for type "
+                            << *ty << " (" << sizeInBits << " bits)\n";
+      assert(sizeInBits > 0 && sizeInBits <= 64);
+      ++int_regs;
     }
+
+    assert(int_regs + sse_regs <= 2);
   }
 
   enum SubtractionResult {
diff --git a/tests/codegen/array_literal_gh1924.d b/tests/codegen/array_literal_gh1924.d
index 88b8b85..b71f5b3 100644
--- a/tests/codegen/array_literal_gh1924.d
+++ b/tests/codegen/array_literal_gh1924.d
@@ -11,6 +11,17 @@ auto simple2d()
     return [[1.0]];
 }
 
+// GitHub issue #1925
+// CHECK-LABEL: define{{.*}} @{{.*}}make2d
+auto make2d()
+{
+    // CHECK: _d_newarrayU
+    // CHECK-NOT: _d_newarrayU
+    double[][1] a = [[1.0]];
+    // CHECK: ret
+    return a;
+}
+
 // CHECK-LABEL: define{{.*}} @{{.*}}make3d
 auto make3d()
 {
@@ -54,10 +65,17 @@ version (RUN)
             assert(a[0].ptr !is b[0].ptr);
         }
         {
+            auto a = make2d();
+            auto b = make2d();
+            assert(a.ptr !is b.ptr);
+            assert(a[0].ptr !is b[0].ptr);
+        }
+        {
             auto a = make3d();
             auto b = make3d();
             assert(a.ptr !is b.ptr);
             assert(a[0].ptr !is b[0].ptr);
+            assert(a[0][0].ptr !is b[0][0].ptr);
         }
         {
             enum e = [[1.0]];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list