From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Dibyendu Majumdar <mobile@majumdar.org.uk>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/2] llvm: default init of arrays & structs
Date: Thu, 28 Dec 2017 23:30:26 +0100 [thread overview]
Message-ID: <20171228223026.39089-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20171228223026.39089-1-luc.vanoostenryck@gmail.com>
Linearization of arrays & structs default initialization is done
as if these objects would be an integer as large as the object.
This integer is then simply zero-initialized.
(This may be objectionable and will be done differently).
However, sparse-llvm is not ready to handle this situation where
a non-scalar is initialized with a scalar value.
Workaround this by using LLVMConstNull() when possible.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
sparse-llvm.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 4c64f1aaa..a1a48fd0f 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -354,6 +354,12 @@ static LLVMValueRef constant_value(unsigned long long val, LLVMTypeRef dtype)
case LLVMIntegerTypeKind:
result = LLVMConstInt(dtype, val, 1);
break;
+ case LLVMArrayTypeKind:
+ case LLVMStructTypeKind:
+ if (val != 0)
+ return NULL;
+ result = LLVMConstNull(dtype);
+ break;
default:
return NULL;
}
--
2.15.0
prev parent reply other threads:[~2017-12-28 22:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-28 22:30 [PATCH 0/2] llvm: improve default/zero initialization Luc Van Oostenryck
2017-12-28 22:30 ` [PATCH 1/2] llvm: simplify emit of null pointers Luc Van Oostenryck
2017-12-28 22:30 ` Luc Van Oostenryck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171228223026.39089-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=mobile@majumdar.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.