@@ -4671,7 +4671,7 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg
4671
4671
bool isunion = layout->flags .arrayelem_isunion ;
4672
4672
bool isghost = layout->size == 0 ;
4673
4673
if ((!isboxed && isunion) || isghost) {
4674
- newdata = ctx.builder .CreateAdd (data, offset);
4674
+ newdata = ctx.builder .CreateAdd (data, offset, " " , true , true );
4675
4675
setName (ctx.emission_context , newdata, " memoryref_data+offset" );
4676
4676
if (bc) {
4677
4677
BasicBlock *failBB, *endBB;
@@ -4710,10 +4710,9 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg
4710
4710
setName (ctx.emission_context , ovflw, " memoryref_ovflw" );
4711
4711
}
4712
4712
#endif
4713
- boffset = ctx.builder .CreateMul (offset, elsz);
4714
- setName (ctx.emission_context , boffset, " memoryref_byteoffset" );
4715
- newdata = ctx.builder .CreateGEP (getInt8Ty (ctx.builder .getContext ()), data, boffset);
4716
- setName (ctx.emission_context , newdata, " memoryref_data_byteoffset" );
4713
+ Type *elty = isboxed ? ctx.types ().T_prjlvalue : julia_type_to_llvm (ctx, jl_tparam1 (ref.typ ));
4714
+ newdata = ctx.builder .CreateGEP (elty, data, offset);
4715
+ setName (ctx.emission_context , newdata, " memoryref_data_offset" );
4717
4716
(void )boffset; // LLVM is very bad at handling GEP with types different from the load
4718
4717
if (bc) {
4719
4718
BasicBlock *failBB, *endBB;
0 commit comments