[pkg-d-commits] [ldc] 01/03: Add Fix-storage-of-captured-lazy-parameters.patch

Matthias Klumpp mak at moszumanska.debian.org
Sat Sep 30 13:55:21 UTC 2017


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

mak pushed a commit to branch master
in repository ldc.

commit 47cd7764b1e5c5fdfd2fb45fead82fc274522c39
Author: Matthias Klumpp <mak at debian.org>
Date:   Sat Sep 30 15:36:34 2017 +0200

    Add Fix-storage-of-captured-lazy-parameters.patch
---
 ...7_Fix-storage-of-captured-lazy-parameters.patch | 64 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 65 insertions(+)

diff --git a/debian/patches/07_Fix-storage-of-captured-lazy-parameters.patch b/debian/patches/07_Fix-storage-of-captured-lazy-parameters.patch
new file mode 100644
index 0000000..fd7f23b
--- /dev/null
+++ b/debian/patches/07_Fix-storage-of-captured-lazy-parameters.patch
@@ -0,0 +1,64 @@
+From 0b4623ebee7eac149a82f3e5d42cc4ffb3087ec2 Mon Sep 17 00:00:00 2001
+From: Martin <noone at nowhere.com>
+Date: Wed, 13 Sep 2017 18:13:40 +0200
+Subject: [PATCH] Fix storage of captured lazy parameters (depending on ABI)
+
+Fixes issue #2302.
+---
+ gen/nested.cpp                     | 15 +++++++++++----
+ tests/codegen/nested_lazy_gh2302.d | 18 ++++++++++++++++++
+ 2 files changed, 29 insertions(+), 4 deletions(-)
+ create mode 100644 tests/codegen/nested_lazy_gh2302.d
+
+diff --git a/gen/nested.cpp b/gen/nested.cpp
+index 92c79d7c5..f3725502a 100644
+--- a/gen/nested.cpp
++++ b/gen/nested.cpp
+@@ -383,12 +383,19 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
+     irLocal.nestedDepth = depth;
+ 
+     LLType *t = nullptr;
+-    if (vd->isRef() || vd->isOut())
++    if (vd->isRef() || vd->isOut()) {
+       t = DtoType(vd->type->pointerTo());
+-    else if (vd->isParameter() && (vd->storage_class & STClazy))
+-      t = getIrParameter(vd)->value->getType()->getContainedType(0);
+-    else
++    } else if (vd->isParameter() && (vd->storage_class & STClazy)) {
++      // The LL type is a delegate (LL struct).
++      // Depending on the used TargetABI, the LL parameter is either a struct or
++      // a pointer to a struct (`byval` attribute, ExplicitByvalRewrite).
++      t = getIrParameter(vd)->value->getType();
++      if (t->isPointerTy())
++        t = t->getPointerElementType();
++      assert(t->isStructTy());
++    } else {
+       t = DtoMemType(vd->type);
++    }
+ 
+     builder.addType(t, getTypeAllocSize(t));
+ 
+diff --git a/tests/codegen/nested_lazy_gh2302.d b/tests/codegen/nested_lazy_gh2302.d
+new file mode 100644
+index 000000000..1457ea6f0
+--- /dev/null
++++ b/tests/codegen/nested_lazy_gh2302.d
+@@ -0,0 +1,18 @@
++// RUN: %ldc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
++// RUN: %ldc -run %s
++
++void foo()
++{
++    auto impl(T)(lazy T field)
++    {
++        // Make sure `field` is a closure variable with delegate type (LL struct).
++        // CHECK: %nest.impl = type { { i8*, i32 (i8*)* } }
++        auto ff() { return field; }
++        auto a = field;
++        return ff() + a;
++    }
++    auto r = impl(123);
++    assert(r == 246);
++}
++
++void main() { foo(); }
diff --git a/debian/patches/series b/debian/patches/series
index a56b08f..4fd2696 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@
 04_static-PIC.patch
 05_pass-d-compiler-flags.patch
 06_bootstrap-pic-default.patch
+07_Fix-storage-of-captured-lazy-parameters.patch

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