@@ -795,19 +795,21 @@ static Value *emit_nthptr_addr(jl_codectx_t &ctx, Value *v, Value *idx)
795
795
idx);
796
796
}
797
797
798
- static LoadInst *emit_nthptr_recast (jl_codectx_t &ctx, Value *v, Value *idx, MDNode *tbaa, Type *ptype )
798
+ static LoadInst *emit_nthptr_recast (jl_codectx_t &ctx, Value *v, Value *idx, MDNode *tbaa, Type *type )
799
799
{
800
- // p = (jl_value_t**)v; *(ptype )&p[n]
800
+ // p = (jl_value_t**)v; *(type* )&p[n]
801
801
Value *vptr = emit_nthptr_addr (ctx, v, idx);
802
- return cast<LoadInst>(tbaa_decorate (tbaa, ctx.builder .CreateLoad (emit_bitcast (ctx, vptr, ptype))));
802
+ return cast<LoadInst>(tbaa_decorate (tbaa, ctx.builder .CreateLoad (type,
803
+ emit_bitcast (ctx, vptr, PointerType::get (type, 0 )))));
803
804
}
804
805
805
- static LoadInst *emit_nthptr_recast (jl_codectx_t &ctx, Value *v, ssize_t n, MDNode *tbaa, Type *ptype )
806
+ static LoadInst *emit_nthptr_recast (jl_codectx_t &ctx, Value *v, ssize_t n, MDNode *tbaa, Type *type )
806
807
{
807
- // p = (jl_value_t**)v; *(ptype )&p[n]
808
+ // p = (jl_value_t**)v; *(type* )&p[n]
808
809
Value *vptr = emit_nthptr_addr (ctx, v, n);
809
- return cast<LoadInst>(tbaa_decorate (tbaa, ctx.builder .CreateLoad (emit_bitcast (ctx, vptr, ptype))));
810
- }
810
+ return cast<LoadInst>(tbaa_decorate (tbaa, ctx.builder .CreateLoad (type,
811
+ emit_bitcast (ctx, vptr, PointerType::get (type, 0 )))));
812
+ }
811
813
812
814
static Value *boxed (jl_codectx_t &ctx, const jl_cgval_t &v);
813
815
@@ -1506,7 +1508,7 @@ static jl_cgval_t typed_load(jl_codectx_t &ctx, Value *ptr, Value *idx_0based, j
1506
1508
alignment = sizeof (void *);
1507
1509
else if (!alignment)
1508
1510
alignment = julia_alignment (jltype);
1509
- LoadInst *load = ctx.builder .CreateAlignedLoad (data, Align (alignment), false );
1511
+ LoadInst *load = ctx.builder .CreateAlignedLoad (elty, data, Align (alignment), false );
1510
1512
load->setOrdering (Order);
1511
1513
if (aliasscope)
1512
1514
load->setMetadata (" alias.scope" , aliasscope);
@@ -1519,7 +1521,7 @@ static jl_cgval_t typed_load(jl_codectx_t &ctx, Value *ptr, Value *idx_0based, j
1519
1521
instr = ctx.builder .CreateTrunc (instr, realelty);
1520
1522
if (intcast) {
1521
1523
ctx.builder .CreateStore (instr, ctx.builder .CreateBitCast (intcast, instr->getType ()->getPointerTo ()));
1522
- instr = ctx.builder .CreateLoad (intcast);
1524
+ instr = ctx.builder .CreateLoad (intcast-> getAllocatedType (), intcast );
1523
1525
}
1524
1526
if (maybe_null_if_boxed) {
1525
1527
Value *first_ptr = isboxed ? instr : extract_first_ptr (ctx, instr);
@@ -1586,7 +1588,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
1586
1588
return emit_new_struct (ctx, (jl_value_t *)rettyp, 2 , argv);
1587
1589
}
1588
1590
}
1589
- Value *intcast = nullptr ;
1591
+ AllocaInst *intcast = nullptr ;
1590
1592
if (!isboxed && Order != AtomicOrdering::NotAtomic && !elty->isIntOrPtrTy ()) {
1591
1593
const DataLayout &DL = jl_data_layout;
1592
1594
unsigned nb = DL.getTypeSizeInBits (elty);
@@ -1736,7 +1738,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
1736
1738
if (intcast) {
1737
1739
ctx.builder .CreateStore (realCompare, ctx.builder .CreateBitCast (intcast, realCompare->getType ()->getPointerTo ()));
1738
1740
if (maybe_null_if_boxed)
1739
- realCompare = ctx.builder .CreateLoad (intcast);
1741
+ realCompare = ctx.builder .CreateLoad (intcast-> getAllocatedType (), intcast );
1740
1742
}
1741
1743
if (maybe_null_if_boxed) {
1742
1744
Value *first_ptr = isboxed ? Compare : extract_first_ptr (ctx, Compare);
@@ -1816,7 +1818,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
1816
1818
ctx.builder .CreateStore (realinstr, ctx.builder .CreateBitCast (intcast, realinstr->getType ()->getPointerTo ()));
1817
1819
oldval = mark_julia_slot (intcast, jltype, NULL , tbaa_stack);
1818
1820
if (maybe_null_if_boxed)
1819
- realinstr = ctx.builder .CreateLoad (intcast);
1821
+ realinstr = ctx.builder .CreateLoad (intcast-> getAllocatedType (), intcast );
1820
1822
}
1821
1823
else {
1822
1824
oldval = mark_julia_type (ctx, realinstr, isboxed, jltype);
@@ -1876,7 +1878,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
1876
1878
instr = ctx.builder .Insert (CastInst::Create (Instruction::Trunc, instr, realelty));
1877
1879
if (intcast) {
1878
1880
ctx.builder .CreateStore (instr, ctx.builder .CreateBitCast (intcast, instr->getType ()->getPointerTo ()));
1879
- instr = ctx.builder .CreateLoad (intcast);
1881
+ instr = ctx.builder .CreateLoad (intcast-> getAllocatedType (), intcast );
1880
1882
}
1881
1883
if (maybe_null_if_boxed) {
1882
1884
Value *first_ptr = isboxed ? instr : extract_first_ptr (ctx, instr);
@@ -1949,18 +1951,18 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, MDNode *tbaa_dst, Va
1949
1951
dstty = dstel->getPointerTo ();
1950
1952
}
1951
1953
1952
- bool direct = false ;
1954
+ llvm::Type *directel = nullptr ;
1953
1955
if (srcel->isSized () && srcel->isSingleValueType () && DL.getTypeStoreSize (srcel) == sz) {
1954
- direct = true ;
1956
+ directel = srcel ;
1955
1957
dst = emit_bitcast (ctx, dst, srcty);
1956
1958
}
1957
1959
else if (dstel->isSized () && dstel->isSingleValueType () &&
1958
1960
DL.getTypeStoreSize (dstel) == sz) {
1959
- direct = true ;
1961
+ directel = dstel ;
1960
1962
src = emit_bitcast (ctx, src, dstty);
1961
1963
}
1962
- if (direct ) {
1963
- auto val = tbaa_decorate (tbaa_src, ctx.builder .CreateAlignedLoad (src, Align (align), is_volatile));
1964
+ if (directel ) {
1965
+ auto val = tbaa_decorate (tbaa_src, ctx.builder .CreateAlignedLoad (directel, src, Align (align), is_volatile));
1964
1966
tbaa_decorate (tbaa_dst, ctx.builder .CreateAlignedStore (val, dst, Align (align), is_volatile));
1965
1967
return ;
1966
1968
}
@@ -2430,7 +2432,7 @@ static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, Value *
2430
2432
auto load = emit_nthptr_recast (ctx,
2431
2433
t,
2432
2434
ctx.builder .CreateAdd (dim, ConstantInt::get (dim->getType (), o)),
2433
- tbaa, T_psize );
2435
+ tbaa, T_size );
2434
2436
MDBuilder MDB (jl_LLVMContext);
2435
2437
auto rng = MDB.createRange (V_size0, ConstantInt::get (T_size, arraytype_maxsize (tinfo.typ )));
2436
2438
load->setMetadata (LLVMContext::MD_range, rng);
@@ -2466,7 +2468,7 @@ static Value *emit_arraylen_prim(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
2466
2468
Value *addr = ctx.builder .CreateStructGEP (jl_array_llvmt,
2467
2469
emit_bitcast (ctx, decay_derived (ctx, t), jl_parray_llvmt),
2468
2470
1 ); // index (not offset) of length field in jl_parray_llvmt
2469
- LoadInst *len = ctx.builder .CreateAlignedLoad (addr, Align (sizeof (size_t )));
2471
+ LoadInst *len = ctx.builder .CreateAlignedLoad (T_size, addr, Align (sizeof (size_t )));
2470
2472
len->setOrdering (AtomicOrdering::NotAtomic);
2471
2473
MDBuilder MDB (jl_LLVMContext);
2472
2474
auto rng = MDB.createRange (V_size0, ConstantInt::get (T_size, arraytype_maxsize (tinfo.typ )));
@@ -2519,7 +2521,8 @@ static Value *emit_arrayptr_internal(jl_codectx_t &ctx, const jl_cgval_t &tinfo,
2519
2521
PointerType::get (PPT->getElementType (), AS),
2520
2522
PT->getAddressSpace ()));
2521
2523
}
2522
- LoadInst *LI = ctx.builder .CreateAlignedLoad (addr, Align (sizeof (char *)));
2524
+ LoadInst *LI = ctx.builder .CreateAlignedLoad (
2525
+ cast<PointerType>(addr->getType ())->getElementType (), addr, Align (sizeof (char *)));
2523
2526
LI->setOrdering (AtomicOrdering::NotAtomic);
2524
2527
LI->setMetadata (LLVMContext::MD_nonnull, MDNode::get (jl_LLVMContext, None));
2525
2528
tbaa_decorate (tbaa, LI);
@@ -2828,9 +2831,9 @@ static Value *as_value(jl_codectx_t &ctx, Type *to, const jl_cgval_t &v)
2828
2831
static Value *load_i8box (jl_codectx_t &ctx, Value *v, jl_datatype_t *ty)
2829
2832
{
2830
2833
auto jvar = ty == jl_int8_type ? jlboxed_int8_cache : jlboxed_uint8_cache;
2831
- Constant *gv = prepare_global_in (jl_Module, jvar);
2834
+ GlobalVariable *gv = prepare_global_in (jl_Module, jvar);
2832
2835
Value *idx[] = {ConstantInt::get (T_int32, 0 ), ctx.builder .CreateZExt (v, T_int32)};
2833
- auto slot = ctx.builder .CreateInBoundsGEP (gv, idx);
2836
+ auto slot = ctx.builder .CreateInBoundsGEP (gv-> getType ()-> getElementType (), gv , idx);
2834
2837
return tbaa_decorate (tbaa_const, maybe_mark_load_dereferenceable (
2835
2838
ctx.builder .CreateAlignedLoad (T_pjlvalue, slot, Align (sizeof (void *))), false ,
2836
2839
(jl_value_t *)ty));
0 commit comments