From patchwork Sat May 18 17:52:06 2013 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: 2589121 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 1F4BA3FD85 for ; Sat, 18 May 2013 17:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751912Ab3ERRwp (ORCPT ); Sat, 18 May 2013 13:52:45 -0400 Received: from mout.gmx.net ([212.227.17.22]:62433 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718Ab3ERRwo (ORCPT ); Sat, 18 May 2013 13:52:44 -0400 Received: from mailout-de.gmx.net ([10.1.76.10]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0LfDle-1UAxvf1BdY-00omUq for ; Sat, 18 May 2013 19:52:43 +0200 Received: (qmail invoked by alias); 18 May 2013 17:52:43 -0000 Received: from dslb-084-060-248-207.pools.arcor-ip.net (EHLO debian.debian) [84.60.248.207] by mail.gmx.net (mp010) with SMTP; 18 May 2013 19:52:43 +0200 X-Authenticated: #41721828 X-Provags-ID: V01U2FsdGVkX1/+DYVNBm3+/VdzXQwUkN2dJk4WUHYWDYJ0c7r7zD Myk4HbupnTzLwu 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 , Xi Wang Subject: [PATCH 3/4] sparse, llvm: base load/store address type on insn_symbol_type() Date: Sat, 18 May 2013 19:52:06 +0200 Message-Id: <1368899527-2350-3-git-send-email-j.neuschaefer@gmx.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368899527-2350-1-git-send-email-j.neuschaefer@gmx.net> References: <1368899527-2350-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 LLVM needs to be correctly told about the type of the object being accessed. This patch also fixes code generation for struct accesses. Cc: Pekka Enberg Cc: Christopher Li Cc: Jeff Garzik Cc: Linus Torvalds Cc: Xi Wang Signed-off-by: Jonathan Neuschäfer --- sparse-llvm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sparse-llvm.c b/sparse-llvm.c index 8573eda..a8ebeab 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -600,7 +600,7 @@ static void output_op_ret(struct function *fn, struct instruction *insn) static LLVMValueRef calc_memop_addr(struct function *fn, struct instruction *insn) { - LLVMTypeRef int_type; + LLVMTypeRef int_type, addr_type; LLVMValueRef src_p, src_i, ofs_i, addr_i, addr; /* int type large enough to hold a pointer */ @@ -613,9 +613,10 @@ static LLVMValueRef calc_memop_addr(struct function *fn, struct instruction *ins ofs_i = LLVMConstInt(int_type, insn->offset, 0); addr_i = LLVMBuildAdd(fn->builder, src_i, ofs_i, "addr_i"); + addr_type = LLVMPointerType(insn_symbol_type(fn->module, insn), 0); + /* convert address back to pointer */ - addr = LLVMBuildIntToPtr(fn->builder, addr_i, - LLVMTypeOf(src_p), "addr"); + addr = LLVMBuildIntToPtr(fn->builder, addr_i, addr_type, "addr"); return addr; }