From: Pekka Enberg <penberg@kernel.org>
To: Xi Wang <xi.wang@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>,
linux-sparse@vger.kernel.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Christopher Li <sparse@chrisli.org>,
Jeff Garzik <jgarzik@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RFC/PATCH] sparse, llvm: Fix string globals access
Date: Sat, 9 Jun 2012 14:00:38 +0300 [thread overview]
Message-ID: <CAOJsxLFX-ZiDCQ84uKka4MYa_uUhLMPeR=XWAHMevTRFsfZBJA@mail.gmail.com> (raw)
In-Reply-To: <35CC6868-F462-4116-A143-81959DA38D5C@gmail.com>
On Sat, Jun 9, 2012 at 2:55 AM, Xi Wang <xi.wang@gmail.com> wrote:
> On Jun 8, 2012, at 4:39 PM, Pekka Enberg wrote:
>>
>> Xi, so I guess your current work on linearize.c might fix the SIGSEGV
>> I'm seeing?
>
> I guess the problem is that sparse-llvm generates an incorrect type
> `load i64*' in llvm from the sparse instruction load.64.
>
> load.64 %r2 <- 0[foo]
> call.32 %r1 <- puts, %r2
> ret.32 $0
>
> With the new ->ctype in pseudo sparse-llvm should be able to generate
> the correct type. I am playing with an LLVM backend with typed pseudos;
> it generates the following code, which seems okay.
>
> @0 = internal global [7 x i8] c"Foo !\0A\00", align 1
> @foo = internal global i8* getelementptr inbounds ([7 x i8]* @0, i64 0, i64 0), align 8
>
> define i32 @main(i32 %argc, i8** %argv) {
> entry:
> %0 = load i8** @foo
> %1 = call i32 @puts(i8* %0)
> ret i32 0
> }
Right. Looking at your "splay" backend
static value_t emit_gep(builder_t builder, struct pseudo *src,
unsigned int offset, struct pseudo *dst)
{
type_t charp = LLVMPointerType(LLVMInt8Type(), 0);
value_t base = LLVMBuildPointerCast(builder, emit_pseudo(src), charp, "");
value_t idx = LLVMConstInt(LLVMIntType(bits_in_pointer), offset, 0);
value_t gep = LLVMBuildGEP(builder, base, &idx, 1, "");
type_t type = LLVMPointerType(emit_type(dst->ctype), 0);
return LLVMBuildPointerCast(builder, gep, type, "");
}
after which OP_LOAD translation becomes as simple as
case OP_LOAD:
return LLVMBuildLoad(builder, emit_gep(builder, insn->src,
insn->offset, insn->target), "");
Jeff, I guess we should do this for output_load() and output_store()
in sparse-llvm.c as well?
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-06-09 11:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 12:58 [RFC/PATCH] sparse, llvm: Fix string globals access Pekka Enberg
2012-06-08 18:13 ` Jeff Garzik
2012-06-08 20:39 ` Pekka Enberg
2012-06-08 23:55 ` Xi Wang
2012-06-09 11:00 ` Pekka Enberg [this message]
2012-06-09 11:46 ` Xi Wang
2012-06-09 12:08 ` Jeff Garzik
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='CAOJsxLFX-ZiDCQ84uKka4MYa_uUhLMPeR=XWAHMevTRFsfZBJA@mail.gmail.com' \
--to=penberg@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=jeff@garzik.org \
--cc=jgarzik@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
--cc=torvalds@linux-foundation.org \
--cc=xi.wang@gmail.com \
/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).