From: Jeff Garzik <jeff@garzik.org>
To: Pekka Enberg <penberg@kernel.org>
Cc: linux-sparse@vger.kernel.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Christopher Li <sparse@chrisli.org>,
Jeff Garzik <jgarzik@redhat.com>
Subject: Re: [PATCH 2/2] sparse, llvm: Fix string initializer code generation
Date: Fri, 08 Jun 2012 14:15:33 -0400 [thread overview]
Message-ID: <4FD24145.9050209@garzik.org> (raw)
In-Reply-To: <1339158877-32024-2-git-send-email-penberg@kernel.org>
On 06/08/2012 08:34 AM, Pekka Enberg wrote:
> This fixes code generation for string initializer such as:
>
> static char *foo = "Foo !\n";
>
> It's the same fix Ben proposed earlier with the small difference that we now
> use LLVMTypeOf() instead of symbol_type() to resolve the type.
>
> The generated LLVM IR looks as follows:
>
> [penberg@tux sparse]$ ./sparse-llvm foo.c |llvm-dis
> ; ModuleID = '<stdin>'
>
> @"<noident>" = private global [7 x i8] c"Foo !\0A\00"
> @foo = private global [7 x i8]* @"<noident>"
>
> Reported-by: Benjamin Herrenschmidt<benh@kernel.crashing.org>
> Cc: Benjamin Herrenschmidt<benh@kernel.crashing.org>
> Cc: Christopher Li<sparse@chrisli.org>
> Cc: Jeff Garzik<jgarzik@redhat.com>
> Signed-off-by: Pekka Enberg<penberg@kernel.org>
> ---
> sparse-llvm.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/sparse-llvm.c b/sparse-llvm.c
> index a39bc02..89c6a2e 100644
> --- a/sparse-llvm.c
> +++ b/sparse-llvm.c
> @@ -1181,6 +1181,12 @@ static LLVMValueRef output_data(LLVMModuleRef module, struct symbol *sym)
> initial_value = output_data(module, sym);
> break;
> }
> + case EXPR_STRING: {
> + const char *s = initializer->string->data;
> +
> + initial_value = LLVMConstString(strdup(s), strlen(s) + 1, true);
> + break;
> + }
> default:
ACK 1-2
prev parent reply other threads:[~2012-06-08 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 12:34 [PATCH 1/2] sparse, llvm: Simplify output_data() type logic Pekka Enberg
2012-06-08 12:34 ` [PATCH 2/2] sparse, llvm: Fix string initializer code generation Pekka Enberg
2012-06-08 18:15 ` Jeff Garzik [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=4FD24145.9050209@garzik.org \
--to=jeff@garzik.org \
--cc=benh@kernel.crashing.org \
--cc=jgarzik@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=penberg@kernel.org \
--cc=sparse@chrisli.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).