Skip to contentSkip to conversation

sparse, llvm: Use LLVMInt1Type() in sym_basetype_type()

PATCH In review Pekka Enberg 3 participants 7 messages Dec 21, 2011 – Dec 22, 2011 Sparse checker

lore
Share & tools
lore
#0 lore raw

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 <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 sparse-llvm.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
sparse-llvm.c +3 -0
index 38f40fc..a291a0d 100644
@@ -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();
Signature · 1 line
1.7.6.4
#1 lore raw

PATCH 2/3 sparse, llvm: Add test case for <stdbool.h> type

As it turns out, our validation test harness doesn't catch <stdbool.h> related breakage so add a minimal test case that does.

Cc Christopher Li <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 validation/backend/bool-test.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 validation/backend/bool-test.c
validation/backend/bool-test.c new file +11 -0
new file mode 100644
index 0000000..51ae356
@@ -0,0 +1,11 @@
+#include <stdbool.h>
+
+static bool return_false(void)
+{
+	return false;
+}
+
+/*
+ * check-name: Boolean type code generation
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
Signature · 1 line
1.7.6.4
#6 lore raw

PATCH 3/3 Revert "sparse: Bump up sizeof(_Bool) to 8 bits"

In reply to Pekka Enberg

This reverts commit 2ded1e7406914eda77abde035416140849d76f68. It's no longer needed as LLVM backend supports 1-bit integers.

Cc Christopher Li <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 target.c                 |    2 +-
 validation/sizeof-bool.c |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
target.c +1 -1
index 6a535bc..17b228a 100644
@@ -14,7 +14,7 @@ int max_alignment = 16;
 /*
  * Integer data types
  */
-int bits_in_bool = 8;
+int bits_in_bool = 1;
 int bits_in_char = 8;
 int bits_in_short = 16;
 int bits_in_int = 32;
validation/sizeof-bool.c +5 -1
index 71ae1bc..6c68748 100644
@@ -4,5 +4,9 @@ static int a(void)
 }
 /*
  * check-name: sizeof(_Bool) is valid
- * check-description: sizeof(_Bool) is valid
+ * check-description: sizeof(_Bool) was rejected because _Bool is not an even
+ * number of bytes
+ * check-error-start
+sizeof-bool.c:3:16: warning: expression using sizeof bool
+ * check-error-end
  */
Signature · 1 line
1.7.6.4
#2 lore raw

Re: [PATCH 2/3] sparse, llvm: Add test case for <stdbool.h> type

In reply to Pekka Enberg
Quoted 2 lines · Pekka Enberg

As it turns out, our validation test harness doesn't catch <stdbool.h> related breakage so add a minimal test case that does.

[...]

validation/backend/bool-test.c line 6

Quoted 9 lines
validation/backend/bool-test.c new file +6 -0
@@ -0,0 +1,11 @@
+#include <stdbool.h>
+
+static bool return_false(void)
+{
+	return false;
+}

Do we want tests that depend on system header files?

- Josh Triplett

#3 lore raw

Re: [PATCH 2/3] sparse, llvm: Add test case for <stdbool.h> type

Quoted 12 lines · Pekka Enberg
Quoted 2 lines

As it turns out, our validation test harness doesn't catch <stdbool.h> related breakage so add a minimal test case that does.

[...]

Quoted 9 lines
validation/backend/bool-test.c new file +6 -0
@@ -0,0 +1,11 @@
+#include <stdbool.h>
+
+static bool return_false(void)
+{
+     return false;
+}
Quoted 1 line · Josh Triplett

Do we want tests that depend on system header files?

I changed it to use _Bool instead. Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw

Re: [PATCH 2/3] sparse, llvm: Add test case for <stdbool.h> type

Quoted 4 lines · Pekka Enberg
Quoted 1 line · Josh Triplett

Do we want tests that depend on system header files?

I changed it to use _Bool instead. Thanks!

This series looks great to me.

Thanks

Chris

#5 lore raw

Re: [PATCH 2/3] sparse, llvm: Add test case for <stdbool.h> type

Quoted 1 line · Josh Triplett
Quoted 1 line
Quoted 1 line

Do we want tests that depend on system header files?

Quoted 1 line · Pekka Enberg
Quoted 1 line

I changed it to use _Bool instead. Thanks!

Quoted 1 line · Christopher Li

This series looks great to me.

The patches are in master branch of:

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