Skip to content

Commit 3b915fb

Browse files
committed
modify codegen
make `Expr(:ivdepscope, :begin/end)` lowered to `jl_ivdepscope_func`
1 parent 1e38f0e commit 3b915fb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/codegen.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,14 @@ static const auto jl_loopinfo_marker_func = new JuliaFunction{
669669
AttributeSet(),
670670
None); },
671671
};
672+
static const auto jl_ivdepscope_func = new JuliaFunction{
673+
"julia.ivdepscope",
674+
[](LLVMContext &C) { return FunctionType::get(T_void, false); },
675+
[](LLVMContext &C) { return AttributeList::get(C,
676+
Attributes(C, {Attribute::ReadOnly, Attribute::NoRecurse, Attribute::InaccessibleMemOnly}),
677+
AttributeSet(),
678+
None); },
679+
};
672680
static const auto jl_write_barrier_func = new JuliaFunction{
673681
"julia.write_barrier",
674682
[](LLVMContext &C) { return FunctionType::get(T_void,
@@ -4694,6 +4702,20 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaval)
46944702
I->setMetadata("julia.loopinfo", MD);
46954703
return jl_cgval_t();
46964704
}
4705+
else if (head == jl_ivdepscope_sym) {
4706+
// parse Expr(:ivdepscope, :begin/end)
4707+
SmallVector<Metadata *, 8> MDs;
4708+
for (int i = 0, ie = nargs; i < ie; ++i) {
4709+
Metadata *MD = to_md_tree(args[i]);
4710+
if (MD)
4711+
MDs.push_back(MD);
4712+
}
4713+
4714+
MDNode* MD = MDNode::get(jl_LLVMContext, MDs);
4715+
CallInst *I = ctx.builder.CreateCall(prepare_call(jl_ivdepscope_func));
4716+
I->setMetadata("julia.ivdepscope", MD);
4717+
return jl_cgval_t();
4718+
}
46974719
else if (head == jl_leave_sym || head == jl_coverageeffect_sym
46984720
|| head == jl_pop_exception_sym || head == jl_enter_sym || head == jl_inbounds_sym
46994721
|| head == jl_aliasscope_sym || head == jl_popaliasscope_sym || head == jl_inline_sym || head == jl_noinline_sym) {
@@ -7897,6 +7919,7 @@ static void init_jit_functions(void)
78977919
add_named_global(jl_alloc_obj_func, (void*)NULL);
78987920
add_named_global(jl_newbits_func, (void*)jl_new_bits);
78997921
add_named_global(jl_loopinfo_marker_func, (void*)NULL);
7922+
add_named_global(jl_ivdepscope_func, &jl_ivdepscope_error);
79007923
add_named_global(jl_typeof_func, (void*)NULL);
79017924
add_named_global(jl_write_barrier_func, (void*)NULL);
79027925
add_named_global(jldlsym_func, &jl_load_and_lookup);

0 commit comments

Comments
 (0)