@@ -908,13 +908,12 @@ static const auto jldeclareglobal_func = new JuliaFunction<>{
908
908
{T_pjlvalue, T_pjlvalue, T_prjlvalue, getInt32Ty (C)}, false ); },
909
909
nullptr ,
910
910
};
911
- static const auto jlgetbindingorerror_func = new JuliaFunction<>{
912
- XSTR (jl_get_binding_or_error ),
911
+ static const auto jldepcheck_func = new JuliaFunction<>{
912
+ XSTR (jl_binding_deprecation_check ),
913
913
[](LLVMContext &C) {
914
914
auto T_pjlvalue = JuliaType::get_pjlvalue_ty (C);
915
- return FunctionType::get (T_pjlvalue,
916
- {T_pjlvalue, T_pjlvalue}, false );
917
- },
915
+ return FunctionType::get (getVoidTy (C),
916
+ {T_pjlvalue}, false ); },
918
917
nullptr ,
919
918
};
920
919
static const auto jlcheckbpwritable_func = new JuliaFunction<>{
@@ -2894,20 +2893,6 @@ static void mallocVisitLine(jl_codectx_t &ctx, StringRef filename, int line, Val
2894
2893
2895
2894
// --- constant determination ---
2896
2895
2897
- static void show_source_loc (jl_codectx_t &ctx, JL_STREAM *out)
2898
- {
2899
- jl_printf (out, " in %s at %s" , ctx.name , ctx.file .str ().c_str ());
2900
- }
2901
-
2902
- static void cg_bdw (jl_codectx_t &ctx, jl_sym_t *var, jl_binding_t *b)
2903
- {
2904
- jl_binding_deprecation_warning (ctx.module , var, b);
2905
- if (b->deprecated == 1 && jl_options.depwarn ) {
2906
- show_source_loc (ctx, JL_STDERR);
2907
- jl_printf (JL_STDERR, " \n " );
2908
- }
2909
- }
2910
-
2911
2896
static jl_value_t *static_apply_type (jl_codectx_t &ctx, ArrayRef<jl_cgval_t > args, size_t nargs)
2912
2897
{
2913
2898
assert (nargs > 1 );
@@ -2932,6 +2917,12 @@ static jl_value_t *static_apply_type(jl_codectx_t &ctx, ArrayRef<jl_cgval_t> arg
2932
2917
return result;
2933
2918
}
2934
2919
2920
+ static void emit_depwarn_check (jl_codectx_t &ctx, jl_binding_t *b)
2921
+ {
2922
+ Value *bp = julia_binding_gv (ctx, b);
2923
+ ctx.builder .CreateCall (prepare_call (jldepcheck_func), { bp });
2924
+ }
2925
+
2935
2926
// try to statically evaluate, NULL if not possible. note that this may allocate, and as
2936
2927
// such the resulting value should not be embedded directly in the generated code.
2937
2928
static jl_value_t *static_eval (jl_codectx_t &ctx, jl_value_t *ex)
@@ -2940,9 +2931,13 @@ static jl_value_t *static_eval(jl_codectx_t &ctx, jl_value_t *ex)
2940
2931
jl_sym_t *sym = (jl_sym_t *)ex;
2941
2932
jl_binding_t *bnd = jl_get_module_binding (ctx.module , sym, 0 );
2942
2933
jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
2943
- jl_walk_binding_inplace_all (&bnd, &bpart, ctx.min_world , ctx.max_world );
2944
- if (bpart && jl_bkind_is_some_constant (jl_binding_kind (bpart)))
2934
+ int possibly_deprecated = 0 ;
2935
+ jl_walk_binding_inplace_all (&bnd, &bpart, &possibly_deprecated, ctx.min_world , ctx.max_world );
2936
+ if (bpart && jl_bkind_is_some_constant (jl_binding_kind (bpart))) {
2937
+ if (possibly_deprecated)
2938
+ emit_depwarn_check (ctx, bnd);
2945
2939
return bpart->restriction ;
2940
+ }
2946
2941
return NULL ;
2947
2942
}
2948
2943
if (jl_is_slotnumber (ex) || jl_is_argument (ex))
@@ -2965,13 +2960,14 @@ static jl_value_t *static_eval(jl_codectx_t &ctx, jl_value_t *ex)
2965
2960
s = jl_globalref_name (ex);
2966
2961
jl_binding_t *bnd = jl_get_module_binding (jl_globalref_mod (ex), s, 0 );
2967
2962
jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
2968
- jl_walk_binding_inplace_all (&bnd, &bpart, ctx.min_world , ctx.max_world );
2963
+ int possibly_deprecated = 0 ;
2964
+ jl_walk_binding_inplace_all (&bnd, &bpart, &possibly_deprecated, ctx.min_world , ctx.max_world );
2969
2965
jl_value_t *v = NULL ;
2970
2966
if (bpart && jl_bkind_is_some_constant (jl_binding_kind (bpart)))
2971
2967
v = bpart->restriction ;
2972
2968
if (v) {
2973
- if (bnd-> deprecated )
2974
- cg_bdw (ctx, s , bnd);
2969
+ if (possibly_deprecated )
2970
+ emit_depwarn_check (ctx, bnd);
2975
2971
return v;
2976
2972
}
2977
2973
return NULL ;
@@ -2992,13 +2988,14 @@ static jl_value_t *static_eval(jl_codectx_t &ctx, jl_value_t *ex)
2992
2988
if (s && jl_is_symbol (s)) {
2993
2989
jl_binding_t *bnd = jl_get_module_binding (m, s, 0 );
2994
2990
jl_binding_partition_t *bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
2995
- jl_walk_binding_inplace_all (&bnd, &bpart, ctx.min_world , ctx.max_world );
2991
+ int possibly_deprecated = 0 ;
2992
+ jl_walk_binding_inplace_all (&bnd, &bpart, &possibly_deprecated, ctx.min_world , ctx.max_world );
2996
2993
jl_value_t *v = NULL ;
2997
2994
if (bpart && jl_bkind_is_some_constant (jl_binding_kind (bpart)))
2998
2995
v = bpart->restriction ;
2999
2996
if (v) {
3000
- if (bnd-> deprecated )
3001
- cg_bdw (ctx, s , bnd);
2997
+ if (possibly_deprecated )
2998
+ emit_depwarn_check (ctx, bnd);
3002
2999
return v;
3003
3000
}
3004
3001
}
@@ -3244,48 +3241,47 @@ static jl_cgval_t emit_globalref(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *
3244
3241
if (!bpart) {
3245
3242
return emit_globalref_runtime (ctx, bnd, mod, name);
3246
3243
}
3247
- // bpart was updated in place - this will change with full partition
3248
- if (jl_bkind_is_some_guard (jl_binding_kind (bpart))) {
3249
- // Redo the lookup at runtime
3250
- return emit_globalref_runtime (ctx, bnd, mod, name);
3251
- } else {
3252
- while (true ) {
3253
- if (!bpart)
3254
- break ;
3255
- if (!jl_bkind_is_some_import (jl_binding_kind (bpart)))
3256
- break ;
3257
- if (bnd->deprecated ) {
3258
- cg_bdw (ctx, name, bnd);
3259
- }
3260
- bnd = (jl_binding_t *)bpart->restriction ;
3261
- bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
3262
- if (!bpart)
3263
- break ;
3264
- }
3265
- if (bpart) {
3266
- enum jl_partition_kind kind = jl_binding_kind (bpart);
3267
- if (jl_bkind_is_some_constant (kind) && kind != BINDING_KIND_BACKDATED_CONST) {
3268
- jl_value_t *constval = bpart->restriction ;
3269
- if (!constval) {
3270
- undef_var_error_ifnot (ctx, ConstantInt::get (getInt1Ty (ctx.builder .getContext ()), 0 ), name, (jl_value_t *)mod);
3271
- return jl_cgval_t ();
3272
- }
3273
- return mark_julia_const (ctx, constval);
3244
+ int possibly_deprecated = 0 ;
3245
+ int saw_explicit = 0 ;
3246
+ while (bpart) {
3247
+ if (!saw_explicit && (bpart->kind & BINDING_FLAG_DEPWARN))
3248
+ possibly_deprecated = 1 ;
3249
+ enum jl_partition_kind kind = jl_binding_kind (bpart);
3250
+ if (!jl_bkind_is_some_import (kind))
3251
+ break ;
3252
+ if (kind != BINDING_KIND_IMPLICIT)
3253
+ saw_explicit = 1 ;
3254
+ bnd = (jl_binding_t *)bpart->restriction ;
3255
+ bpart = jl_get_binding_partition_all (bnd, ctx.min_world , ctx.max_world );
3256
+ }
3257
+ Value *bp = NULL ;
3258
+ if (bpart) {
3259
+ enum jl_partition_kind kind = jl_binding_kind (bpart);
3260
+ if (jl_bkind_is_some_constant (kind) && kind != BINDING_KIND_BACKDATED_CONST) {
3261
+ if (possibly_deprecated) {
3262
+ bp = julia_binding_gv (ctx, bnd);
3263
+ ctx.builder .CreateCall (prepare_call (jldepcheck_func), { bp });
3264
+ }
3265
+ jl_value_t *constval = bpart->restriction ;
3266
+ if (!constval) {
3267
+ undef_var_error_ifnot (ctx, ConstantInt::get (getInt1Ty (ctx.builder .getContext ()), 0 ), name, (jl_value_t *)mod);
3268
+ return jl_cgval_t ();
3274
3269
}
3270
+ return mark_julia_const (ctx, constval);
3275
3271
}
3276
3272
}
3277
3273
if (!bpart || jl_binding_kind (bpart) != BINDING_KIND_GLOBAL) {
3278
3274
return emit_globalref_runtime (ctx, bnd, mod, name);
3279
3275
}
3280
- Value * bp = julia_binding_gv (ctx, bnd);
3281
- if (bnd-> deprecated ) {
3282
- cg_bdw ( ctx, name, bnd );
3276
+ bp = julia_binding_gv (ctx, bnd);
3277
+ if (possibly_deprecated ) {
3278
+ ctx. builder . CreateCall ( prepare_call (jldepcheck_func), { bp } );
3283
3279
}
3284
3280
jl_value_t *ty = bpart->restriction ;
3285
- bp = julia_binding_pvalue (ctx, bp);
3281
+ Value *bpval = julia_binding_pvalue (ctx, bp);
3286
3282
if (ty == nullptr )
3287
3283
ty = (jl_value_t *)jl_any_type;
3288
- return update_julia_type (ctx, emit_checked_var (ctx, bp , name, (jl_value_t *)mod, false , ctx.tbaa ().tbaa_binding ), ty);
3284
+ return update_julia_type (ctx, emit_checked_var (ctx, bpval , name, (jl_value_t *)mod, false , ctx.tbaa ().tbaa_binding ), ty);
3289
3285
}
3290
3286
3291
3287
static jl_cgval_t emit_globalop (jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *sym, jl_cgval_t rval, const jl_cgval_t &cmp,
@@ -3298,6 +3294,7 @@ static jl_cgval_t emit_globalop(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *s
3298
3294
Value *bp = julia_binding_gv (ctx, bnd);
3299
3295
if (bpart) {
3300
3296
if (jl_binding_kind (bpart) == BINDING_KIND_GLOBAL) {
3297
+ int possibly_deprecated = bpart->kind & BINDING_FLAG_DEPWARN;
3301
3298
jl_value_t *ty = bpart->restriction ;
3302
3299
if (ty != nullptr ) {
3303
3300
const std::string fname = issetglobal ? " setglobal!" : isreplaceglobal ? " replaceglobal!" : isswapglobal ? " swapglobal!" : ismodifyglobal ? " modifyglobal!" : " setglobalonce!" ;
@@ -3310,6 +3307,9 @@ static jl_cgval_t emit_globalop(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *s
3310
3307
}
3311
3308
bool isboxed = true ;
3312
3309
bool maybe_null = jl_atomic_load_relaxed (&bnd->value ) == NULL ;
3310
+ if (possibly_deprecated) {
3311
+ ctx.builder .CreateCall (prepare_call (jldepcheck_func), { bp });
3312
+ }
3313
3313
return typed_store (ctx,
3314
3314
julia_binding_pvalue (ctx, bp),
3315
3315
rval, cmp, ty,
@@ -9913,7 +9913,6 @@ static void init_jit_functions(void)
9913
9913
add_named_global (memcmp_func, &memcmp);
9914
9914
add_named_global (jltypeerror_func, &jl_type_error);
9915
9915
add_named_global (jlcheckassign_func, &jl_checked_assignment);
9916
- add_named_global (jlgetbindingorerror_func, &jl_get_binding_or_error);
9917
9916
add_named_global (jlcheckbpwritable_func, &jl_check_binding_currently_writable);
9918
9917
add_named_global (jlboundp_func, &jl_boundp);
9919
9918
for (auto it : builtin_func_map ())
0 commit comments