Re: [RFC/PATCH] sparse, llvm: Fix string globals access

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

 



On Jun 9, 2012, at 7:00 AM, Pekka Enberg wrote:
> 
> Right. Looking at your "splay" backend
> 
> static value_t emit_gep(builder_t builder, struct pseudo *src,
> unsigned int offset, struct pseudo *dst)
> {
> 	type_t charp = LLVMPointerType(LLVMInt8Type(), 0);
> 	value_t base = LLVMBuildPointerCast(builder, emit_pseudo(src), charp, "");
> 	value_t idx = LLVMConstInt(LLVMIntType(bits_in_pointer), offset, 0);
> 	value_t gep = LLVMBuildGEP(builder, base, &idx, 1, "");
> 	type_t type = LLVMPointerType(emit_type(dst->ctype), 0);
> 
> 	return LLVMBuildPointerCast(builder, gep, type, "");
> }
> 
> after which OP_LOAD translation becomes as simple as
> 
> 	case OP_LOAD:
> 		return LLVMBuildLoad(builder, emit_gep(builder, insn->src,
> insn->offset, insn->target), "");
> 
> Jeff, I guess we should do this for output_load() and output_store()
> in sparse-llvm.c as well?

Maybe we can do this for "pointer + integer" as well, using getelementptr
with offset computed by sparse (converting the pointer to char* first).
Unlike inttoptr/ptrtotint, this shouldn't disable LLVM's alias analysis.
I will give it a try later.

- xi
--
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