* [PATCH] sparse, llvm: Fix 'void *' pointer code generation
@ 2011-10-24 11:43 Pekka Enberg
2011-10-24 11:52 ` Linus Torvalds
0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2011-10-24 11:43 UTC (permalink / raw)
To: linux-sparse; +Cc: Pekka Enberg, Christopher Li, Jeff Garzik, Linus Torvalds
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 | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sparse-llvm.c b/sparse-llvm.c
index a85dfea..ec46a04 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -80,7 +80,7 @@ static LLVMTypeRef sym_basetype_type(struct symbol *sym)
} else {
switch (sym->bit_size) {
case -1:
- ret = LLVMVoidType();
+ ret = LLVMIntType(bits_in_pointer);
break;
case 8:
ret = LLVMInt8Type();
--
1.7.6.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
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
0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2011-10-24 11:52 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-sparse, Christopher Li, Jeff Garzik
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().
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?
Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
2011-10-24 11:52 ` Linus Torvalds
@ 2011-10-24 11:56 ` Pekka Enberg
2011-10-24 12:14 ` Jonathan Neuschäfer
0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2011-10-24 11:56 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Pekka Enberg, linux-sparse, Christopher Li, Jeff Garzik
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
2011-10-24 11:56 ` Pekka Enberg
@ 2011-10-24 12:14 ` Jonathan Neuschäfer
2011-10-24 12:33 ` Pekka Enberg
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Neuschäfer @ 2011-10-24 12:14 UTC (permalink / raw)
To: Pekka Enberg
Cc: Linus Torvalds, Pekka Enberg, linux-sparse, Christopher Li,
Jeff Garzik
On Mon, Oct 24, 2011 at 02:56:41PM +0300, Pekka Enberg wrote:
> Fix the issue by switching to LLVMIntType(bits_per_pointer) in
> sym_basetype_type().
You didn't update the commit message.
--
Jonathan Neuschäfer
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
2011-10-24 12:14 ` Jonathan Neuschäfer
@ 2011-10-24 12:33 ` Pekka Enberg
2011-10-24 15:13 ` Jeff Garzik
0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2011-10-24 12:33 UTC (permalink / raw)
To: Jonathan Neuschäfer
Cc: Linus Torvalds, Pekka Enberg, linux-sparse, Christopher Li,
Jeff Garzik
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1939 bytes --]
> On Mon, Oct 24, 2011 at 02:56:41PM +0300, Pekka Enberg wrote:
>> Fix the issue by switching to LLVMIntType(bits_per_pointer) in
>> sym_basetype_type().
On Mon, 24 Oct 2011, Jonathan Neuschäfer wrote:
> You didn't update the commit message.
Thanks for pointing that out. Jeff, does this look OK?
Pekka
From e6981551345b7284f6995556398b3564d02afc42 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 treating 'void *' as 'char *' as suggested by Linus:
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?
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
2011-10-24 12:33 ` Pekka Enberg
@ 2011-10-24 15:13 ` Jeff Garzik
2011-10-24 15:18 ` Pekka Enberg
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Garzik @ 2011-10-24 15:13 UTC (permalink / raw)
To: Pekka Enberg
Cc: Jonathan Neuschäfer, Linus Torvalds, Pekka Enberg,
linux-sparse, Christopher Li, Jeff Garzik
On 10/24/2011 08:33 AM, Pekka Enberg wrote:
>> On Mon, Oct 24, 2011 at 02:56:41PM +0300, Pekka Enberg wrote:
>>> Fix the issue by switching to LLVMIntType(bits_per_pointer) in
>>> sym_basetype_type().
>
> On Mon, 24 Oct 2011, Jonathan Neuschäfer wrote:
>> You didn't update the commit message.
>
> Thanks for pointing that out. Jeff, does this look OK?
I don't know what bit_size==-1 means off the top of my head, so I assume
yes ;-)
Jeff
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] sparse, llvm: Fix 'void *' pointer code generation
2011-10-24 15:13 ` Jeff Garzik
@ 2011-10-24 15:18 ` Pekka Enberg
0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2011-10-24 15:18 UTC (permalink / raw)
To: Jeff Garzik
Cc: Jonathan Neuschäfer, Linus Torvalds, linux-sparse,
Christopher Li, Jeff Garzik
On Mon, Oct 24, 2011 at 6:13 PM, Jeff Garzik <jeff@garzik.org> wrote:
>> Thanks for pointing that out. Jeff, does this look OK?
>
> I don't know what bit_size==-1 means off the top of my head, so I assume yes
So
void *p;
looks as follows with test-inspect:
0: SYM_NODE: p
ctype.base_type: SYM_PTR: <noident>
ctype.base_type: SYM_BASETYPE: void
[ btw, is there a text mode version of test-inspect? ]
where the SYM_BASETYPE of 'void' has -1 set as bit_size by the frontend.
Pekka
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-10-24 15:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).