aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2011-10-24 14:11:13 +0300
committerPekka Enberg <penberg@kernel.org>2011-10-24 14:59:37 +0300
commite6981551345b7284f6995556398b3564d02afc42 (patch)
tree01f509a51ff6d48cf4ddcb284b82c73a2fd0d464
parent30f5aa58c15d8a2761e703424e8400943916a065 (diff)
downloadsparse-e6981551345b7284f6995556398b3564d02afc42.tar.gz
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>
-rw-r--r--sparse-llvm.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index a85dfea5..fc0c2e93 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;