From patchwork Tue Oct 9 23:34:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 1571831 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0FE9C40135 for ; Tue, 9 Oct 2012 23:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647Ab2JIXfM (ORCPT ); Tue, 9 Oct 2012 19:35:12 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:59067 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751387Ab2JIXfL (ORCPT ); Tue, 9 Oct 2012 19:35:11 -0400 Received: (qmail invoked by alias); 09 Oct 2012 23:35:09 -0000 Received: from dslb-084-060-229-125.pools.arcor-ip.net (EHLO debian.debian) [84.60.229.125] by mail.gmx.net (mp028) with SMTP; 10 Oct 2012 01:35:09 +0200 X-Authenticated: #41721828 X-Provags-ID: V01U2FsdGVkX1+vkr84MPKv9lRDrJiiAFLI+1+2s6UwwK40RwwI+1 eeSoukeapJZLSL From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= To: linux-sparse@vger.kernel.org Cc: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Pekka Enberg , Christopher Li , Jeff Garzik , Linus Torvalds Subject: [PATCH 2/2] sparse, llvm: Fix type of loaded values Date: Wed, 10 Oct 2012 01:34:36 +0200 Message-Id: <1349825676-1713-2-git-send-email-j.neuschaefer@gmx.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1349825676-1713-1-git-send-email-j.neuschaefer@gmx.net> References: <1349825676-1713-1-git-send-email-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Y-GMX-Trusted: 0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org 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 Cc: Christopher Li Cc: Jeff Garzik Cc: Linus Torvalds Signed-off-by: Jonathan Neuschäfer Acked-by: Jeff Garzik --- 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 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 + */