[PATCH 3/4] sparse, llvm: base load/store address type on insn_symbol_type()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <penberg@xxxxxxxxxx>
Cc: Christopher Li <sparse@xxxxxxxxxxx>
Cc: Jeff Garzik <jgarzik@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Xi Wang <xi.wang@xxxxxxxxx>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>
---
 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;
 }
-- 
1.7.10.4

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




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux