From: Pekka Enberg <penberg@cs.helsinki.fi>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pekka Enberg <penberg@kernel.org>,
linux-sparse@vger.kernel.org, Christopher Li <sparse@chrisli.org>,
Jeff Garzik <jgarzik@redhat.com>
Subject: Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
Date: Mon, 24 Oct 2011 14:56:41 +0300 (EEST) [thread overview]
Message-ID: <alpine.LFD.2.02.1110241455580.13879@tux.localdomain> (raw)
In-Reply-To: <CA+55aFx1=9C_QDE2CfqLp1zg_t=x+VjKUPZgj2karJsS1FAZaA@mail.gmail.com>
On Mon, Oct 24, 2011 at 1:43 PM, Pekka Enberg <penberg@kernel.org> wrote:
>> Fix the issue by switching to LLVMIntType(bits_per_pointer) in
>> sym_basetype_type().
On Mon, 24 Oct 2011, Linus Torvalds wrote:
> Why bits_per_pointer? Isn't this the "base type" of void *? A more
> logical choice would seem to be to make it equivalent to "char *", and
> just make it fall through to the "case 8" case?
Indeed. Updated patch below.
Pekka
From f90242c21b21d91cfed57aa050b4726b6060dfdd Mon Sep 17 00:00:00 2001
From: Pekka Enberg <penberg@kernel.org>
Date: Mon, 24 Oct 2011 14:11:13 +0300
Subject: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
Sparse front-end generates SYM_PTR with SYM_BASETYPE with bit_size set to -1
for "void *" pointers. We currently map that to LLVMVoidType() but that no
longer works with LLVM Subversion trunk:
$ ./sparse-llvm validation/backend/struct.c
sparse-llvm: Type.cpp:676: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted
Fix the issue by switching to LLVMIntType(bits_per_pointer) in
sym_basetype_type().
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
sparse-llvm.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/sparse-llvm.c b/sparse-llvm.c
index a85dfea..fc0c2e9 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -79,9 +79,7 @@ static LLVMTypeRef sym_basetype_type(struct symbol *sym)
}
} else {
switch (sym->bit_size) {
- case -1:
- ret = LLVMVoidType();
- break;
+ case -1: /* 'void *' is treated like 'char *' */
case 8:
ret = LLVMInt8Type();
break;
--
1.7.6.4
next prev parent reply other threads:[~2011-10-24 11:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 11:43 [PATCH] sparse, llvm: Fix 'void *' pointer code generation Pekka Enberg
2011-10-24 11:52 ` Linus Torvalds
2011-10-24 11:56 ` Pekka Enberg [this message]
2011-10-24 12:14 ` Jonathan Neuschäfer
2011-10-24 12:33 ` Pekka Enberg
2011-10-24 15:13 ` Jeff Garzik
2011-10-24 15:18 ` Pekka Enberg
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=alpine.LFD.2.02.1110241455580.13879@tux.localdomain \
--to=penberg@cs.helsinki.fi \
--cc=jgarzik@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=penberg@kernel.org \
--cc=sparse@chrisli.org \
--cc=torvalds@linux-foundation.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).