Pekka Enberg | 1 Feb 10:55
Favicon
Gravatar

[RFC/PATCH 1/2] sparse, llvm: Make function declaration accessible to backend

From: Linus Torvalds <torvalds <at> linux-foundation.org>

On Tue, Aug 30, 2011 at 10:43 AM, Jeff Garzik <jeff <at> garzik.org> wrote:
> * if someone knows how to access a function declaration, I can solve the
> varargs problem

Hmm. Right now we do not have access to the function declaration at
linearize time. We've checked that the arguments match, and we've cast
the arguments to the right types (evaluate.c), so the thinking was
that you just use the arguments as-is.

But if llvm needs the declaration of a function, we'd need to squirrel it away.

Cc: Benjamin Herrenschmidt <benh <at> kernel.crashing.org>
Cc: Christopher Li <sparse <at> chrisli.org>
Cc: Jeff Garzik <jgarzik <at> redhat.com>
Cc: Linus Torvalds <torvalds <at> linux-foundation.org>
[ penberg <at> kernel.org: Fix validation/context.c breakage. ]
Signed-off-by: Pekka Enberg <penberg <at> kernel.org>
---
 linearize.c |    8 ++++++++
 linearize.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/linearize.c b/linearize.c
index 1899978..7d57474 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1195,6 +1195,7 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
 	struct instruction *insn = alloc_typed_instruction(OP_CALL, expr->ctype);
(Continue reading)

Jan Pokorný | 23 Jan 00:31
Picon
Favicon
Gravatar

[PATCH] evaluate: reject post-ops on void*

Following example haven't been linearized correctly:

	static void *inc_ptr(void *a) {
		return ++a;
	}

test-linearize:

	<entry-point>
	add.32      %r2 <- %arg1, $-1
	ret.32      %r2

Apparently, something went wrong with -1 value to be added to the original
pointer.  When void* substituted for int*, the result is as expected
(considering 32b int):

	<entry-point>
	add.32      %r2 <- %arg1, $4
	ret.32      %r2

The proposed patch turns post-ops on void* operand into an error
(taking the same route as with function operand).

When running check with C=2 on my old linux-3.0.6 configuration,
this detected a few occurencies:

	drivers/scsi/scsi_proc.c:405:31: error: bad argument type for ++/--
	drivers/scsi/scsi_proc.c:413:23: error: bad argument type for ++/--
	net/bluetooth/hci_core.c:1545:29: error: bad argument type for ++/--
	net/bluetooth/l2cap_core.c:1825:37: error: bad argument type for ++/--
(Continue reading)

Christopher Li | 19 Jan 03:00

sparse-llvm has been merged

 Pekka's sparse-llvm has been merged at sparse chrisl branch.

http://git.kernel.org/?p=devel/sparse/chrisl/sparse.git;a=summary

The new llvm back end require llvm 3.0.

Chris

Merge branch 'sparse-llvm' of git://github.com/penberg/sparse-llvm.git

    'master' branch of git://github.com/penberg/sparse-llvm.git

        Revert "sparse: Bump up sizeof(_Bool) to 8 bits"
        sparse, llvm: Add test case for <stdbool.h> type
        sparse, llvm: Use LLVMInt1Type() in sym_basetype_type()
        sparse, llvm: Don't fail the build if LLVM is too old
        Merge pull request #6 from jgarzik/hacks
        sparse, llvm: add loop testcase
        sparse, llvm: Fix loops, by properly handling OP_PHI forward references
        sparse, llvm: FP comparison op code generation
        sparse, llvm: Simplify comparison op code generation
        sparse, llvm: More comparison ops code generation
        sparse, llvm: OP_SET_B and OP_SET_A code generation
        sparse, llvm: Pointer cast code generation
        sparse, llvm: Make llc output to stdout in sparsec
        sparse, llvm: Fix 'extern' symbol code generation
        sparse, llvm: Fix symbol initializer code generation
        sparse, llvm: Function pointer code generation
        sparse, llvm: Make 'sparsec' error handling more robust
        sparse, llvm: Add support for union types
(Continue reading)

Ethan Jackson | 17 Jan 23:47
Favicon

[PATCH] sparse: Add 'leaf' to ignored attributes.

This patch adds the 'leaf' GCC attribute to the list of ignored
attributes.  Glibc uses this attribute causing the following
warnings in userspace projects:

  /usr/include/stdlib.h:514:26: error: attribute '__leaf__': unknown attribute

Signed-off-by: Ethan Jackson <ethan <at> nicira.com>
---
 ident-list.h |    2 ++
 parse.c      |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/ident-list.h b/ident-list.h
index b12d172..35ac6bd 100644
--- a/ident-list.h
+++ b/ident-list.h
@@ -88,6 +88,8 @@ IDENT(dllimport); IDENT(__dllimport__);
 IDENT(dllexport); IDENT(__dllexport__);
 IDENT(restrict); IDENT(__restrict);
 IDENT(artificial); IDENT(__artificial__);
+IDENT(leaf); IDENT(__leaf__);
+

 /* Preprocessor idents.  Direct use of __IDENT avoids mentioning the keyword
  * itself by name, preventing these tokens from expanding when compiling
diff --git a/parse.c b/parse.c
index bd42180..f8ade3e 100644
--- a/parse.c
+++ b/parse.c
@@ -519,6 +519,8 @@ const char *ignored_attributes[] = {
(Continue reading)

Pekka Enberg | 21 Dec 10:25
Favicon
Gravatar

[PATCH 1/3] sparse, llvm: Use LLVMInt1Type() in sym_basetype_type()

In preparation for reverting commit 2ded1e7 ("sparse: Bump up sizeof(_Bool) to
8 bits"), teach sym_basetype_type() about LLVMInt1Type().

Cc: Christopher Li <sparse <at> chrisli.org>
Cc: Jeff Garzik <jgarzik <at> redhat.com>
Cc: Linus Torvalds <torvalds <at> linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg <at> kernel.org>
---
 sparse-llvm.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 38f40fc..a291a0d 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -175,6 +175,9 @@ static LLVMTypeRef sym_basetype_type(struct symbol *sym)
 		}
 	} else {
 		switch (sym->bit_size) {
+		case 1:
+			ret = LLVMInt1Type();
+			break;
 		case -1:	/* 'void *' is treated like 'char *' */
 		case 8:
 			ret = LLVMInt8Type();
--

-- 
1.7.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
(Continue reading)

Christopher Li | 25 Nov 22:13

Sparse 0.4.4 is released

This is a long due release. The sparse 0.4.4 can be downloaded from:

http://www.kernel.org/pub/software/devel/sparse/dist/

The new sparse has a lot of bugs fixes. It will report less noise
while checking the new kernel tree. It compiles better with the
new gcc as well.

The sparse project is in the process of moving to the MIT license.
Dan is coordinating the efforts. Most sparse developers sign off
the MIT license already. If you haven't done so, please contact
Dan off the list regarding the new license.

Here is the short summery of the changes in this release.

Have a nice long week end.

Chris

Ben Pfaff (1):
      evaluate: Allow sizeof(_Bool) to succeed.

Christopher Li (13):
      inspect: adding function arugument list
      Allow overwrite CFLAGS from command line
      Ignore attribute vector_size
      Remove set but not used variable
      inspect: Add switch statement and more
      validation: inline switch statement
      Fix inlining switch statement.
(Continue reading)

Pekka Enberg | 25 Nov 08:46
Favicon
Gravatar

[GIT PULL] Sparse LLVM backend

Hi Chris,

Please consider pulling latest LLVM backend code from:

   git://github.com/penberg/sparse-llvm.git for-chris

The backend is still work in progress but it already supports the following C
language features:

   - Arithmetic operations

   - Comparison operations

   - Logical operations

   - Bitwise operations

   - Loops

   - Casts

   - Structs and unions

The backend has been tested on i386 and x86-64. Some features have also been
tested on PPC against LLVM 2.6.

Please note that sparse uses 32-bit data type sizes by default so the generated
code on 64-bit is not correct. We'd need something like the following patch to
fix it:

(Continue reading)

Pekka Enberg | 25 Nov 08:06
Favicon
Gravatar

[PATCH] sparse, llvm: Don't fail the build if LLVM is too old

Disable sparse-llvm compilation if LLVM version is too old.

Cc: Linus Torvalds <torvalds <at> linux-foundation.org>
Cc: Christopher Li <sparse <at> chrisli.org>
Cc: Jeff Garzik <jgarzik <at> redhat.com>
Signed-off-by: Pekka Enberg <penberg <at> kernel.org>
---
 Makefile |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e508cae..2b5976d 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,8 @@ HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
 		echo 'yes'; rm -f .gcc-test.d .gcc-test.o .gcc-test.c)
 HAVE_GTK2:=$(shell pkg-config --exists gtk+-2.0 2>/dev/null && echo 'yes')
 HAVE_LLVM:=$(shell llvm-config --version >/dev/null 2>&1 && echo 'yes')
+HAVE_LLVM_VERSION:=$(shell llvm-config --version | grep "^[3-9].*" >/dev/null 2>&1 && echo yes)
+LLVM_VERSION=$(shell llvm-config --version)

 GCC_BASE = $(shell $(CC) --print-file-name=)
 BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\"
@@ -65,7 +67,13 @@ else
 $(warning Your system does not have libgtk2, disabling test-inspect)
 endif

-ifeq ($(HAVE_LLVM),yes)
+ifneq ($(HAVE_LLVM),yes)
+$(warning Your system does not have llvm, disabling sparse-llvm)
(Continue reading)

Pekka Enberg | 22 Nov 20:53
Favicon
Gravatar

[PATCH] sparse, llvm: FP comparison op code generation

This patch implements code generation for floating point versions of OP_BINCMP.

Cc: Linus Torvalds <torvalds <at> linux-foundation.org>
Cc: Christopher Li <sparse <at> chrisli.org>
Cc: Jeff Garzik <jgarzik <at> redhat.com>
Signed-off-by: Pekka Enberg <penberg <at> kernel.org>
---
 sparse-llvm.c                |   29 +++++++++++++++++++++++++++--
 validation/backend/cmp-ops.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 4ef02a1..0674ef3 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -391,6 +391,25 @@ static LLVMTypeRef pseudo_type(struct function *fn, struct instruction *insn, ps
 	return result;
 }

+static LLVMRealPredicate translate_fop(int opcode)
+{
+	static const LLVMRealPredicate trans_tbl[] = {
+		[OP_SET_EQ]	= LLVMRealOEQ,
+		[OP_SET_NE]	= LLVMRealUNE,
+		[OP_SET_LE]	= LLVMRealOLE,
+		[OP_SET_GE]	= LLVMRealOGE,
+		[OP_SET_LT]	= LLVMRealOLT,
+		[OP_SET_GT]	= LLVMRealOGT,
+		/* Are these used with FP? */
+		[OP_SET_B]	= LLVMRealOLT,
(Continue reading)

Linus Torvalds | 22 Nov 19:26
Gravatar

Re: [PATCH] sparse, llvm: Simplify comparison op code generation

On Tue, Nov 22, 2011 at 10:18 AM, Pekka Enberg <penberg <at> kernel.org> wrote:
>
> I think that might be a generic sparse floating point issue but I
> didn't look too closely.

No, it looks like sparse is doing fine, but because you don't generate
the FP versions of the comparison ops, LLVM is unhappy with getting an
integer comparison for a floating point value.

Enhancing the translate_op() function to generate the proper FP
comparisons for LLVM would probably make it "JustWork(tm)".

But I don't really claim to know LLVM.

                    Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Pekka Enberg | 22 Nov 18:58
Favicon
Gravatar

[PATCH] sparse, llvm: Simplify comparison op code generation

Linus writes:

  On Tue, Nov 22, 2011 at 9:40 AM, Pekka Enberg <penberg <at> kernel.org> wrote:
  > This patch implements LLVM code generation for OP_SET_LE, OP_SET_GE, OP_SET_BE,
  > and OP_SET_AE.

  Ugh.

  Can't you just do it with a single statement like

     target = LLVMBuildICmp(fn->builder, translate_op(op), lhs, rhs,
target_name);

  instead of having that case-statement where every case does the same thing?

  The translate_op() thing should be trivial too, just something like

    static int translate_op(int sparse_op)
    {
        static const int trans_tbl[] = {
            .[OP_SET_LE] = LLVMIntSLE,
        ...
         };
         return trans_tbl[sparse_op];
    }

  or whatever. No?

Suggested-by: Linus Torvalds <torvalds <at> linux-foundation.org>
Cc: Christopher Li <sparse <at> chrisli.org>
(Continue reading)


Gmane