diff mbox

[2/2] sparse, llvm: Fix type of loaded values

Message ID 1349825676-1713-2-git-send-email-j.neuschaefer@gmx.net (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

J. Neuschäfer Oct. 9, 2012, 11:34 p.m. UTC
Instead of making the computed address a pointer to an int type
large enough to hold a pointer, make it a pointer to the memory
object being loaded.  This fixes another LLVM warning.

Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 sparse-llvm.c                  |    2 +-
 validation/backend/load-type.c |   12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 validation/backend/load-type.c

Comments

Jeff Garzik Oct. 10, 2012, 12:13 a.m. UTC | #1
On 10/09/2012 07:34 PM, Jonathan Neuschäfer wrote:
> Instead of making the computed address a pointer to an int type
> large enough to hold a pointer, make it a pointer to the memory
> object being loaded.  This fixes another LLVM warning.
>
> Cc: Pekka Enberg <penberg@kernel.org>
> Cc: Christopher Li <sparse@chrisli.org>
> Cc: Jeff Garzik <jgarzik@redhat.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> ---
>   sparse-llvm.c                  |    2 +-
>   validation/backend/load-type.c |   12 ++++++++++++
>   2 files changed, 13 insertions(+), 1 deletion(-)
>   create mode 100644 validation/backend/load-type.c

Acked-by: Jeff Garzik <jgarzik@redhat.com>



--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pekka Enberg Oct. 10, 2012, 6:34 a.m. UTC | #2
On Wed, Oct 10, 2012 at 3:13 AM, Jeff Garzik <jgarzik@pobox.com> wrote:
> On 10/09/2012 07:34 PM, Jonathan Neuschäfer wrote:
>>
>> Instead of making the computed address a pointer to an int type
>> large enough to hold a pointer, make it a pointer to the memory
>> object being loaded.  This fixes another LLVM warning.
>>
>> Cc: Pekka Enberg <penberg@kernel.org>
>> Cc: Christopher Li <sparse@chrisli.org>
>> Cc: Jeff Garzik <jgarzik@redhat.com>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
>> ---
>>   sparse-llvm.c                  |    2 +-
>>   validation/backend/load-type.c |   12 ++++++++++++
>>   2 files changed, 13 insertions(+), 1 deletion(-)
>>   create mode 100644 validation/backend/load-type.c
>
> Acked-by: Jeff Garzik <jgarzik@redhat.com>

Applied, thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 2048a1b..7f45dc0 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -615,7 +615,7 @@  static void output_op_load(struct function *fn, struct instruction *insn)
 
 	/* convert address back to pointer */
 	addr = LLVMBuildIntToPtr(fn->builder, addr_i,
-				 LLVMPointerType(int_type, 0), "addr");
+				 LLVMTypeOf(src_p), "addr");
 
 	/* perform load */
 	target = LLVMBuildLoad(fn->builder, addr, "load_target");
diff --git a/validation/backend/load-type.c b/validation/backend/load-type.c
new file mode 100644
index 0000000..80416ca
--- /dev/null
+++ b/validation/backend/load-type.c
@@ -0,0 +1,12 @@ 
+extern struct _IO_FILE *stdin;
+
+static void sub(struct _IO_FILE *in) {}
+
+static void test(void) {
+        sub(stdin);
+}
+
+/*
+ * check-name: Type of loaded objects
+ * check-command: ./sparsec -c $file -o tmp.o
+ */