@@ -330,12 +330,12 @@ static Constant *julia_pgv(jl_codectx_t &ctx, const char *cname, void *addr)
330
330
// emit a GlobalVariable for a jl_value_t named "cname"
331
331
// store the name given so we can reuse it (facilitating merging later)
332
332
// so first see if there already is a GlobalVariable for this address
333
- GlobalVariable* &gv = ctx.global_targets [addr];
333
+ GlobalVariable* &gv = ctx.emission_context . global_targets [addr];
334
334
Module *M = jl_Module;
335
335
StringRef localname;
336
336
std::string gvname;
337
337
if (!gv) {
338
- uint64_t id = ctx.emission_context .imaging ? jl_atomic_fetch_add (&globalUniqueGeneratedNames, 1 ) : ctx.global_targets .size ();
338
+ uint64_t id = ctx.emission_context .imaging ? jl_atomic_fetch_add (&globalUniqueGeneratedNames, 1 ) : ctx.emission_context . global_targets .size ();
339
339
raw_string_ostream (gvname) << cname << id;
340
340
localname = StringRef (gvname);
341
341
}
@@ -391,16 +391,6 @@ static Constant *literal_pointer_val_slot(jl_codectx_t &ctx, jl_value_t *p)
391
391
{
392
392
// emit a pointer to a jl_value_t* which will allow it to be valid across reloading code
393
393
// also, try to give it a nice name for gdb, for easy identification
394
- if (!ctx.emission_context .imaging ) {
395
- // TODO: this is an optimization, but is it useful or premature
396
- // (it'll block any attempt to cache these, but can be simply deleted)
397
- Module *M = jl_Module;
398
- GlobalVariable *gv = new GlobalVariable (
399
- *M, ctx.types ().T_pjlvalue , true , GlobalVariable::PrivateLinkage,
400
- literal_static_pointer_val (p, ctx.types ().T_pjlvalue ));
401
- gv->setUnnamedAddr (GlobalValue::UnnamedAddr::Global);
402
- return gv;
403
- }
404
394
if (JuliaVariable *gv = julia_const_gv (p)) {
405
395
// if this is a known special object, use the existing GlobalValue
406
396
return prepare_global_in (jl_Module, gv);
@@ -513,8 +503,6 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p)
513
503
{
514
504
if (p == NULL )
515
505
return Constant::getNullValue (ctx.types ().T_pjlvalue );
516
- if (!ctx.emission_context .imaging )
517
- return literal_static_pointer_val (p, ctx.types ().T_pjlvalue );
518
506
Value *pgv = literal_pointer_val_slot (ctx, p);
519
507
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_const );
520
508
auto load = ai.decorateInst (maybe_mark_load_dereferenceable (
@@ -530,8 +518,6 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_binding_t *p)
530
518
// emit a pointer to any jl_value_t which will be valid across reloading code
531
519
if (p == NULL )
532
520
return Constant::getNullValue (ctx.types ().T_pjlvalue );
533
- if (!ctx.emission_context .imaging )
534
- return literal_static_pointer_val (p, ctx.types ().T_pjlvalue );
535
521
// bindings are prefixed with jl_bnd#
536
522
jl_globalref_t *gr = p->globalref ;
537
523
Value *pgv = gr ? julia_pgv (ctx, " jl_bnd#" , gr->name , gr->mod , p) : julia_pgv (ctx, " jl_bnd#" , p);
@@ -575,17 +561,12 @@ static Value *julia_binding_gv(jl_codectx_t &ctx, jl_binding_t *b)
575
561
{
576
562
// emit a literal_pointer_val to a jl_binding_t
577
563
// binding->value are prefixed with *
578
- if (ctx.emission_context .imaging ) {
579
- jl_globalref_t *gr = b->globalref ;
580
- Value *pgv = gr ? julia_pgv (ctx, " *" , gr->name , gr->mod , b) : julia_pgv (ctx, " *jl_bnd#" , b);
581
- jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_const );
582
- auto load = ai.decorateInst (ctx.builder .CreateAlignedLoad (ctx.types ().T_pjlvalue , pgv, Align (sizeof (void *))));
583
- setName (ctx.emission_context , load, pgv->getName ());
584
- return load;
585
- }
586
- else {
587
- return literal_static_pointer_val (b, ctx.types ().T_pjlvalue );
588
- }
564
+ jl_globalref_t *gr = b->globalref ;
565
+ Value *pgv = gr ? julia_pgv (ctx, " *" , gr->name , gr->mod , b) : julia_pgv (ctx, " *jl_bnd#" , b);
566
+ jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_const );
567
+ auto load = ai.decorateInst (ctx.builder .CreateAlignedLoad (ctx.types ().T_pjlvalue , pgv, Align (sizeof (void *))));
568
+ setName (ctx.emission_context , load, pgv->getName ());
569
+ return load;
589
570
}
590
571
591
572
// --- mapping between julia and llvm types ---
@@ -1130,8 +1111,8 @@ static Value *emit_typeof(jl_codectx_t &ctx, const jl_cgval_t &p, bool maybenull
1130
1111
p.typ ,
1131
1112
counter);
1132
1113
auto emit_unboxty = [&] () -> Value* {
1133
- jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_const );
1134
1114
if (ctx.emission_context .imaging ) {
1115
+ jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_const );
1135
1116
Value *datatype = ai.decorateInst (ctx.builder .CreateAlignedLoad (expr_type, datatype_or_p, Align (sizeof (void *))));
1136
1117
setName (ctx.emission_context , datatype, " typetag" );
1137
1118
return justtag ? datatype : track_pjlvalue (ctx, datatype);
0 commit comments