@@ -2487,27 +2487,6 @@ static jl_cgval_t emit_unionload(jl_codectx_t &ctx, Value *addr, Value *ptindex,
2487
2487
return mark_julia_slot (fsz > 0 ? addr : nullptr , jfty, tindex, tbaa);
2488
2488
}
2489
2489
2490
- static const char *get_fieldname (jl_datatype_t *jt, unsigned idx)
2491
- {
2492
- if (jl_is_namedtuple_type (jt)) {
2493
- auto names = jl_tparam0 (jt);
2494
- assert (jl_is_tuple (names));
2495
- if (idx < jl_nfields (names)) {
2496
- auto name = jl_fieldref (names, idx);
2497
- assert (jl_is_symbol (name));
2498
- return jl_symbol_name ((jl_sym_t *)name);
2499
- }
2500
- } else {
2501
- auto flds = jl_field_names (jt);
2502
- if (idx < jl_svec_len (flds)) {
2503
- auto name = jl_svec_ref (flds, idx);
2504
- assert (jl_is_symbol (name));
2505
- return jl_symbol_name ((jl_sym_t *)name);
2506
- }
2507
- }
2508
- return " <unknown field>" ;
2509
- }
2510
-
2511
2490
// If `nullcheck` is not NULL and a pointer NULL check is necessary
2512
2491
// store the pointer to be checked in `*nullcheck` instead of checking it
2513
2492
static jl_cgval_t emit_getfield_knownidx (jl_codectx_t &ctx, const jl_cgval_t &strct,
@@ -2571,13 +2550,13 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2571
2550
else
2572
2551
addr = ctx.builder .CreateConstInBoundsGEP2_32 (lt, staddr, 0 , idx);
2573
2552
if (addr != staddr) {
2574
- setName (ctx.emission_context , addr, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx) + " _ptr" ). str (); } );
2553
+ setNameWithField (ctx.emission_context , addr, get_objname, jt, idx, Twine ( " _ptr" ));
2575
2554
}
2576
2555
}
2577
2556
if (jl_field_isptr (jt, idx)) {
2578
- setName (ctx.emission_context , addr, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx) + " _ptr" ). str (); } );
2557
+ setNameWithField (ctx.emission_context , addr, get_objname, jt, idx, Twine ( " _ptr" ));
2579
2558
LoadInst *Load = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , maybe_bitcast (ctx, addr, ctx.types ().T_pprjlvalue ), Align (sizeof (void *)));
2580
- setName (ctx.emission_context , Load, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2559
+ setNameWithField (ctx.emission_context , Load, get_objname, jt, idx, Twine () );
2581
2560
Load->setOrdering (order <= jl_memory_order_notatomic ? AtomicOrdering::Unordered : get_llvm_atomic_order (order));
2582
2561
maybe_mark_load_dereferenceable (Load, maybe_null, jl_field_type (jt, idx));
2583
2562
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, tbaa);
@@ -2601,7 +2580,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2601
2580
}
2602
2581
auto val = emit_unionload (ctx, addr, ptindex, jfty, fsz, al, tbaa, !jl_field_isconst (jt, idx), union_max, ctx.tbaa ().tbaa_unionselbyte );
2603
2582
if (val.V && val.V != addr) {
2604
- setName (ctx.emission_context , val.V , [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2583
+ setNameWithField (ctx.emission_context , val.V , get_objname, jt, idx, Twine () );
2605
2584
}
2606
2585
return val;
2607
2586
}
@@ -2618,7 +2597,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2618
2597
needlock ? AtomicOrdering::NotAtomic : get_llvm_atomic_order (order),
2619
2598
maybe_null, align, nullcheck);
2620
2599
if (ret.V ) {
2621
- setName (ctx.emission_context , ret.V , [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2600
+ setNameWithField (ctx.emission_context , ret.V , get_objname, jt, idx, Twine () );
2622
2601
}
2623
2602
if (needlock)
2624
2603
emit_lockstate_value (ctx, strct, false );
@@ -2637,7 +2616,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2637
2616
}
2638
2617
else if (isa<VectorType>(T)) {
2639
2618
fldv = ctx.builder .CreateExtractElement (obj, ConstantInt::get (getInt32Ty (ctx.builder .getContext ()), idx));
2640
- setName (ctx.emission_context , fldv, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2619
+ setNameWithField (ctx.emission_context , fldv, get_objname, jt, idx, Twine () );
2641
2620
}
2642
2621
else if (!jl_field_isptr (jt, idx) && jl_is_uniontype (jfty)) {
2643
2622
int fsz = jl_field_size (jt, idx) - 1 ;
@@ -2667,11 +2646,11 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2667
2646
ctx.builder .CreateAlignedStore (fldv, fldp, Align (1 ));
2668
2647
}
2669
2648
}
2670
- setName (ctx.emission_context , lv, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2649
+ setNameWithField (ctx.emission_context , lv, get_objname, jt, idx, Twine () );
2671
2650
}
2672
2651
Value *tindex0 = ctx.builder .CreateExtractValue (obj, makeArrayRef (ptindex));
2673
2652
Value *tindex = ctx.builder .CreateNUWAdd (ConstantInt::get (getInt8Ty (ctx.builder .getContext ()), 1 ), tindex0);
2674
- setName (ctx.emission_context , tindex, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx) + " .tindex" ). str (); } );
2653
+ setNameWithField (ctx.emission_context , tindex, get_objname, jt, idx, Twine ( " .tindex" ));
2675
2654
return mark_julia_slot (lv, jfty, tindex, ctx.tbaa ().tbaa_stack );
2676
2655
}
2677
2656
else {
@@ -2683,7 +2662,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
2683
2662
else
2684
2663
llvm_unreachable (" encountered incompatible type for a struct" );
2685
2664
fldv = ctx.builder .CreateExtractValue (obj, makeArrayRef (st_idx));
2686
- setName (ctx.emission_context , fldv, [&]() { return ( get_objname () + " . " + get_fieldname ( jt, idx)). str (); } );
2665
+ setNameWithField (ctx.emission_context , fldv, get_objname, jt, idx, Twine () );
2687
2666
}
2688
2667
if (maybe_null) {
2689
2668
Value *first_ptr = jl_field_isptr (jt, idx) ? fldv : extract_first_ptr (ctx, fldv);
@@ -3792,7 +3771,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
3792
3771
getInt8Ty (ctx.builder .getContext ()),
3793
3772
emit_bitcast (ctx, addr, getInt8PtrTy (ctx.builder .getContext ())),
3794
3773
ConstantInt::get (ctx.types ().T_size , byte_offset)); // TODO: use emit_struct_gep
3795
- setName (ctx.emission_context , addr, [&](){ return ( get_objname () + " . " + get_fieldname ( sty, idx0) + " _ptr" ). str (); } );
3774
+ setNameWithField (ctx.emission_context , addr, get_objname, sty, idx0, Twine ( " _ptr" ));
3796
3775
}
3797
3776
jl_value_t *jfty = jl_field_type (sty, idx0);
3798
3777
if (!jl_field_isptr (sty, idx0) && jl_is_uniontype (jfty)) {
@@ -3807,7 +3786,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
3807
3786
Value *ptindex = ctx.builder .CreateInBoundsGEP (getInt8Ty (ctx.builder .getContext ()),
3808
3787
emit_bitcast (ctx, addr, getInt8PtrTy (ctx.builder .getContext ())),
3809
3788
ConstantInt::get (ctx.types ().T_size , fsz));
3810
- setName (ctx.emission_context , ptindex, [&](){ return ( get_objname () + " . " + get_fieldname ( sty, idx0) + " .tindex_ptr" ). str (); } );
3789
+ setNameWithField (ctx.emission_context , ptindex, get_objname, sty, idx0, Twine ( " .tindex_ptr" ));
3811
3790
if (needlock)
3812
3791
emit_lockstate_value (ctx, strct, true );
3813
3792
BasicBlock *ModifyBB = NULL ;
@@ -3869,15 +3848,15 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
3869
3848
jl_datatype_t *rettyp = jl_apply_cmpswap_type (jfty);
3870
3849
oldval = emit_new_struct (ctx, (jl_value_t *)rettyp, 2 , argv);
3871
3850
if (oldval.V ) {
3872
- setName (ctx.emission_context , oldval.V , [&](){ return ( get_objname () + " . " + get_fieldname ( sty, idx0)). str (); } );
3851
+ setNameWithField (ctx.emission_context , oldval.V , get_objname, sty, idx0, Twine () );
3873
3852
}
3874
3853
}
3875
3854
else if (ismodifyfield) {
3876
3855
jl_cgval_t argv[2 ] = {oldval, rhs};
3877
3856
jl_datatype_t *rettyp = jl_apply_modify_type (jfty);
3878
3857
oldval = emit_new_struct (ctx, (jl_value_t *)rettyp, 2 , argv);
3879
3858
if (oldval.V ) {
3880
- setName (ctx.emission_context , oldval.V , [&](){ return ( get_objname () + " . " + get_fieldname ( sty, idx0)). str (); } );
3859
+ setNameWithField (ctx.emission_context , oldval.V , get_objname, sty, idx0, Twine () );
3881
3860
}
3882
3861
}
3883
3862
return oldval;
0 commit comments