compile-i386: fix use-after-free in func_cleanup()

compile-i386 sometimes crashes due a use-after-free error.  Since
f->pseudo_list is freed first, which invalidates some atom->op* in
f->atom_list.  Further checks like `atom->op1->flags & STOR_WANTS_FREE'
will read garbage, which may lead to a double free.

This patch switches the cleanup order and frees f->atom_list first.
Those marked as STOR_WANTS_FREE won't appear in f->pseudo_list.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
check missing or duplicate goto labels

This patch sets ->stmt of a SYM_LABEL to the corresponding label
statement.  If ->stmt was already set, it is a duplicate label.

On the other hand, if ->stmt of a goto label is not set during
evaluation, the label was never declared.

Signed-off-by: Christopher Li <sparse@chrisli.org>
sparse, llvm: Add _Bool to cast validation test

This patch adds casting backend validation test cases for the _Bool data type.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: Simplify output_data() type logic

Use LLVMTypeOf() in output_data() to simplify type handling logic.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: Fix string initializer code generation

This fixes code generation for string initializer such as:

  static char *foo = "Foo !\n";

It's the same fix Ben proposed earlier with the small difference that we now
use LLVMTypeOf() instead of symbol_type() to resolve the type.

The generated LLVM IR looks as follows:

  [penberg@tux sparse]$ ./sparse-llvm foo.c |llvm-dis
  ; ModuleID = '<stdin>'

  @"<noident>" = private global [7 x i8] c"Foo !\0A\00"
  @foo = private global [7 x i8]* @"<noident>"

Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: Fix global string access code generation

This patch attempts to fix code generation for global string access:

  static char *foo = "Foo !\n";

  extern int puts(const char *s);

  int main(int argc, char *argv[])
  {
          puts(foo);

          return 0;
  }

The generated executable causes a SIGSEGV:

  [penberg@tux sparse]$ ./sparsec foo.c && ./a.out
  Segmentation fault

But as pointed out by Xi Wang, the problem is in "output_load()":

  I guess the problem is that sparse-llvm generates an incorrect type `load i64*'
  in llvm from the sparse instruction load.64.

         load.64     %r2 <- 0[foo]
         call.32     %r1 <- puts, %r2
         ret.32      $0

  With the new ->ctype in pseudo sparse-llvm should be able to generate the
  correct type.  I am playing with an LLVM backend with typed pseudos; it
  generates the following code, which seems okay.

  @0 = internal global [7 x i8] c"Foo !\0A\00", align 1
  @foo = internal global i8* getelementptr inbounds ([7 x i8]* @0, i64 0, i64 0), align 8

  define i32 @main(i32 %argc, i8** %argv) {
  entry:
   %0 = load i8** @foo
   %1 = call i32 @puts(i8* %0)
   ret i32 0
  }

So I'll leave the output_load() fix to a separate patch for now.

Cc: Xi Wang <xi.wang@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Merge branch 'for-chris' of git://github.com/penberg/sparse-llvm

Pull 'for-chris' tree from Pekka Enberg:

"Please pull the latest sparse-llvm tree from:
 git@github.com:penberg/sparse-llvm.git for-chris

 It has one new validation test case and fixes to handle strings properly
 in the LLVM backend."

Pekka Enberg (4):
      sparse, llvm: Add _Bool to cast validation test
      sparse, llvm: Simplify output_data() type logic
      sparse, llvm: Fix string initializer code generation
      sparse, llvm: Fix global string access code generation
sparse: Add '__vector_size__' to ignored attributes

We already had "vector_size" but we also need __vector_size__ to silence
some warnings in glibc:

/usr/include/bits/link.h:67:45: error: attribute '__vector_size__': unknown attribute

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
sparse: Add 'error' to ignored attributes

Add some more ignored attributes which are used in glibc header files.  It
silences the warnings such as the following:

/usr/include/bits/fcntl2.h:36:1: error: attribute '__error__': unknown attribute

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
FAQ: update the website address and call it Wiki

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>
ptrlist.c: fix a typo in a comment

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>