Skip to content

Commit 893fecc

Browse files
authored
Fix debug level check and add types to allocations in the IR (#51338)
1 parent a811406 commit 893fecc

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/cgutils.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,8 +3545,11 @@ static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &vinfo, bool is_promotab
35453545
originalAlloca->eraseFromParent();
35463546
ctx.builder.restoreIP(IP);
35473547
} else {
3548+
auto arg_typename = [&] JL_NOTSAFEPOINT {
3549+
return jl_symbol_name(((jl_datatype_t*)(jt))->name->name);
3550+
};
35483551
box = emit_allocobj(ctx, (jl_datatype_t*)jt);
3549-
setName(ctx.emission_context, box, "box");
3552+
setName(ctx.emission_context, box, "box" + StringRef("::") + arg_typename());
35503553
init_bits_cgval(ctx, box, vinfo, jl_is_mutable(jt) ? ctx.tbaa().tbaa_mutab : ctx.tbaa().tbaa_immut);
35513554
}
35523555
}
@@ -3879,6 +3882,9 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
38793882
assert(jl_is_datatype(ty));
38803883
assert(jl_is_concrete_type(ty));
38813884
jl_datatype_t *sty = (jl_datatype_t*)ty;
3885+
auto arg_typename = [&] JL_NOTSAFEPOINT {
3886+
return jl_symbol_name((sty)->name->name);
3887+
};
38823888
size_t nf = jl_datatype_nfields(sty);
38833889
if (nf > 0 || sty->name->mutabl) {
38843890
if (deserves_stack(ty)) {
@@ -3910,7 +3916,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
39103916
}
39113917
else {
39123918
strct = emit_static_alloca(ctx, lt);
3913-
setName(ctx.emission_context, strct, "newstruct");
3919+
setName(ctx.emission_context, strct, "new" + StringRef("::") + arg_typename());
39143920
if (tracked.count)
39153921
undef_derived_strct(ctx, strct, sty, ctx.tbaa().tbaa_stack);
39163922
}
@@ -4080,7 +4086,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
40804086
}
40814087
}
40824088
Value *strct = emit_allocobj(ctx, sty);
4083-
setName(ctx.emission_context, strct, "newstruct");
4089+
setName(ctx.emission_context, strct, "new" + StringRef("::") + arg_typename());
40844090
jl_cgval_t strctinfo = mark_julia_type(ctx, strct, true, ty);
40854091
strct = decay_derived(ctx, strct);
40864092
undef_derived_strct(ctx, strct, sty, strctinfo.tbaa);

src/codegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7431,7 +7431,7 @@ static jl_llvm_functions_t
74317431
f = cast<Function>(returninfo.decl.getCallee());
74327432
has_sret = (returninfo.cc == jl_returninfo_t::SRet || returninfo.cc == jl_returninfo_t::Union);
74337433
jl_init_function(f, ctx.emission_context.TargetTriple);
7434-
if (ctx.emission_context.debug_level > 0) {
7434+
if (ctx.emission_context.debug_level >= 2) {
74357435
auto arg_typename = [&](size_t i) JL_NOTSAFEPOINT {
74367436
auto tp = jl_tparam(lam->specTypes, i);
74377437
return jl_is_datatype(tp) ? jl_symbol_name(((jl_datatype_t*)tp)->name->name) : "<unknown type>";

test/llvmpasses/names.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ function f7(a)
7272
return a[2]
7373
end
7474

75-
# COM: check write barrier names
75+
# COM: check write barrier names and struct names
7676
mutable struct Barrier
7777
b
7878
end
7979

80+
struct Named
81+
x::Int
82+
end
8083
# CHECK-LABEL: define {{(swiftcc )?}}double @julia_f1
8184
# CHECK-SAME: double %"a::Float64"
8285
# CHECK-SAME: double %"b::Float64"
@@ -186,3 +189,11 @@ emit(f7,Tuple{Int,Int})
186189
# CHECK: %child_bit
187190
# CHECK: %child_not_marked
188191
emit(Barrier, Int64)
192+
193+
# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_Barrier
194+
# CHECK-SAME: %"b::Named"
195+
# CHECK: %"new::Barrier"
196+
# CHECK: %"box::Named"
197+
# CHECK: %parent_bits
198+
# CHECK: %parent_old_marked
199+
emit(Barrier, Named)

0 commit comments

Comments
 (0)