sparse, llvm: Fix 'void *' pointer code generation
commite6981551345b7284f6995556398b3564d02afc42
authorPekka Enberg <penberg@kernel.org>
Mon, 24 Oct 2011 11:11:13 +0000 (24 14:11 +0300)
committerPekka Enberg <penberg@kernel.org>
Mon, 24 Oct 2011 11:59:37 +0000 (24 14:59 +0300)
tree01f509a51ff6d48cf4ddcb284b82c73a2fd0d464
parent30f5aa58c15d8a2761e703424e8400943916a065
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