[pkg-d-commits] [ldc] 02/149: Remove the 16MB limit on static array sizes.

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:52 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 11c09ce2236a02790d6ec50f7db96ddfa4d2e0de
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Wed Dec 7 20:34:14 2016 +0100

    Remove the 16MB limit on static array sizes.
    
    The limit is a workaround for an optlink bug, thus unimportant for LDC, see
    https://issues.dlang.org/show_bug.cgi?id=14859
    https://forum.dlang.org/post/lxzyzcatydfkxkoxfccw@forum.dlang.org
---
 ddmd/mtype.d                      | 14 +++++++++++++-
 tests/codegen/static_array_huge.d | 12 ++++++++++++
 tests/d2/dmd-testsuite            |  2 +-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ddmd/mtype.d b/ddmd/mtype.d
index 2836f03..af5a452 100644
--- a/ddmd/mtype.d
+++ b/ddmd/mtype.d
@@ -4612,7 +4612,7 @@ public:
             if (d1 != d2)
             {
             Loverflow:
-                error(loc, "%s size %llu * %llu exceeds 16MiB size limit for static array", toChars(), cast(ulong)tbn.size(loc), cast(ulong)d1);
+                error(loc, "%s size %llu * %llu exceeds the size limit for static arrays (overflow)", toChars(), cast(ulong)tbn.size(loc), cast(ulong)d1);
                 goto Lerror;
             }
             Type tbx = tbn.baseElemOf();
@@ -4628,8 +4628,20 @@ public:
                  * run on them for the size, since they may be forward referenced.
                  */
                 bool overflow = false;
+version(IN_LLVM)
+{
+                /+ The size limit that DMD imposes here is only there to work around an optlink bug, which doesn't apply to LDC.
+                 + https://issues.dlang.org/show_bug.cgi?id=14859
+                 +/
+                mulu(tbn.size(loc), d2, overflow);
+                if (overflow)
+                    goto Loverflow;
+}
+else
+{
                 if (mulu(tbn.size(loc), d2, overflow) >= 0x1000000 || overflow) // put a 'reasonable' limit on it
                     goto Loverflow;
+}
             }
         }
         switch (tbn.ty)
diff --git a/tests/codegen/static_array_huge.d b/tests/codegen/static_array_huge.d
new file mode 100644
index 0000000..3b28fba
--- /dev/null
+++ b/tests/codegen/static_array_huge.d
@@ -0,0 +1,12 @@
+// Tests that static arrays can be large (> 16MB)
+
+// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
+
+// CHECK: Stuff = type { [209715200 x i8] }
+struct Stuff
+{
+    byte[1024*1024*200] a;
+}
+
+// CHECK: hugeArrayG209715200g ={{.*}} [209715200 x i8]
+byte[1024*1024*200] hugeArray;
diff --git a/tests/d2/dmd-testsuite b/tests/d2/dmd-testsuite
index a6d0fc7..32e19e4 160000
--- a/tests/d2/dmd-testsuite
+++ b/tests/d2/dmd-testsuite
@@ -1 +1 @@
-Subproject commit a6d0fc716643ceee52a7a63d70d7c860e12e5f6d
+Subproject commit 32e19e463c9afa157f287d5da5d3d04b2aef2414

-- 
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