sparse, llvm: Fix 'void' return type code generation
commit33844e787a0ed80d04b2917042fec50ccf4c91dd
authorPekka Enberg <penberg@kernel.org>
Sun, 19 Aug 2012 09:25:11 +0000 (19 12:25 +0300)
committerPekka Enberg <penberg@kernel.org>
Sun, 19 Aug 2012 09:25:11 +0000 (19 12:25 +0300)
tree7ba44d11c0558027cdc3d519ade41048ac7a0755
parente49d1f0f310b8b6d9ef610e1e7108879bf24cdca
sparse, llvm: Fix 'void' return type code generation

Jonathan Neuschäfer reports:

  A simple function like this will compile to the following llvm
  bitcode:

        /* C */
        void func(void) {
                return;
        }

        /* LLVM */
        define i8 @func() {
        L0:
          ret void
        }

  The return type of the function and the type in the return instruction
  don't match.

  I found this inconsistency by running LLVM's bitcode validation on the
  bitcode produced by sparse-llvm.

Move 'void *' special-casing from sym_basetype_type() to sym_ptr_type()
to fix the issue.

Reported by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
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
validation/backend/void-return-type.c [new file with mode: 0644]