aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2013-05-18 19:52:06 +0200
committerPekka Enberg <penberg@kernel.org>2013-05-19 10:58:04 +0300
commit8c4e44129b08cc5e0c037f87d590d33c5294b764 (patch)
tree96d4217c6ef345a139c22a35f9c40440c6046020
parent1c1dd120b41b93dc63587929c48c2b7d215eb2dc (diff)
downloadsparse-8c4e44129b08cc5e0c037f87d590d33c5294b764.tar.gz
sparse, llvm: base load/store address type on insn_symbol_type()
LLVM needs to be correctly told about the type of the object being accessed. This patch also fixes code generation for struct accesses. Cc: Christopher Li <sparse@chrisli.org> Cc: Jeff Garzik <jgarzik@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Xi Wang <xi.wang@gmail.com> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--sparse-llvm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 8ac3a440..41e0ab7e 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -543,7 +543,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 */
@@ -556,9 +556,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;
}