Skip to content

Commit 6e04733

Browse files
authored
Merge pull request JuliaLang#32090 from JuliaLang/kf/clangsaclean
Try to get GC analysis clean again
2 parents 25c33e4 + 297e353 commit 6e04733

30 files changed

+318
-210
lines changed

src/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ RUNTIME_C_SRCS := \
4444
dlload sys init task array dump staticdata toplevel jl_uv datatype \
4545
simplevector runtime_intrinsics precompile \
4646
threading partr stackwalk gc gc-debug gc-pages gc-stacks method \
47-
jlapi signal-handling safepoint jloptions timing subtype rtutils \
47+
jlapi signal-handling safepoint jloptions timing subtype \
4848
crc32c
49-
RUNTIME_SRCS := APInt-C runtime_ccall processor $(RUNTIME_C_SRCS)
49+
RUNTIME_SRCS := APInt-C runtime_ccall processor rtutils $(RUNTIME_C_SRCS)
5050
SRCS := $(RUNTIME_SRCS)
5151

5252
ifeq ($(USEMSVC), 1)
@@ -324,6 +324,11 @@ clean-support:
324324
cleanall: clean clean-flisp clean-support
325325

326326
analyzegc:
327+
ifeq ($(USE_BINARYBUILDER_LLVM),0)
328+
ifneq ($(BUILD_LLVM_CLANG),1)
329+
$(error Clang must be available to use the clang analyzer. Either build it (BUILD_LLVM_CLANG) or use BinaryBuilder)
330+
endif
331+
endif
327332
$(MAKE) -C clangsa
328333
$(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CPPFLAGS) $(CFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core,julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c $(RUNTIME_C_SRCS:%=$(SRCDIR)/%.c)
329334

src/ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ typedef struct _jl_ast_context_t {
109109
static jl_ast_context_t jl_ast_main_ctx;
110110

111111
#ifdef __clang_analyzer__
112-
jl_ast_context_t *jl_ast_ctx(fl_context_t *fl) JL_GLOBALLY_ROOTED;
112+
jl_ast_context_t *jl_ast_ctx(fl_context_t *fl) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
113113
#else
114114
#define jl_ast_ctx(fl_ctx) container_of(fl_ctx, jl_ast_context_t, fl)
115115
#endif
@@ -203,7 +203,7 @@ static const builtinspec_t julia_flisp_ast_ext[] = {
203203
{ NULL, NULL }
204204
};
205205

206-
static void jl_init_ast_ctx(jl_ast_context_t *ast_ctx)
206+
static void jl_init_ast_ctx(jl_ast_context_t *ast_ctx) JL_NOTSAFEPOINT
207207
{
208208
fl_context_t *fl_ctx = &ast_ctx->fl;
209209
fl_init(fl_ctx, 4*1024*1024);

src/builtins.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int NOINLINE compare_fields(jl_value_t *a, jl_value_t *b, jl_datatype_t *
9494
}
9595
}
9696
else {
97-
jl_datatype_t *ft = (jl_datatype_t*)jl_field_type(dt, f);
97+
jl_datatype_t *ft = (jl_datatype_t*)jl_field_type_concrete(dt, f);
9898
if (jl_is_uniontype(ft)) {
9999
uint8_t asel = ((uint8_t*)ao)[jl_field_size(dt, f) - 1];
100100
uint8_t bsel = ((uint8_t*)bo)[jl_field_size(dt, f) - 1];
@@ -321,7 +321,7 @@ JL_DLLEXPORT uintptr_t jl_object_id_(jl_value_t *tv, jl_value_t *v) JL_NOTSAFEPO
321321
u = (f == NULL) ? 0 : jl_object_id(f);
322322
}
323323
else {
324-
jl_datatype_t *fieldtype = (jl_datatype_t*)jl_field_type(dt, f);
324+
jl_datatype_t *fieldtype = (jl_datatype_t*)jl_field_type_concrete(dt, f);
325325
if (jl_is_uniontype(fieldtype)) {
326326
uint8_t sel = ((uint8_t*)vo)[jl_field_size(dt, f) - 1];
327327
fieldtype = (jl_datatype_t*)jl_nth_union_component((jl_value_t*)fieldtype, sel);
@@ -472,7 +472,7 @@ void STATIC_INLINE _grow_to(jl_value_t **root, jl_value_t ***oldargs, jl_svec_t
472472
*n_alloc = newalloc;
473473
}
474474

475-
static jl_function_t *jl_iterate_func;
475+
static jl_function_t *jl_iterate_func JL_GLOBALLY_ROOTED;
476476

477477
JL_CALLABLE(jl_f__apply)
478478
{
@@ -597,10 +597,9 @@ JL_CALLABLE(jl_f__apply)
597597
}
598598
else {
599599
assert(extra > 0);
600-
jl_value_t *args[3];
601-
args[0] = jl_iterate_func;
602-
args[1] = ai;
603-
jl_value_t *next = jl_apply(args, 2);
600+
jl_value_t *args[2];
601+
args[0] = ai;
602+
jl_value_t *next = jl_apply_generic(jl_iterate_func, args, 1);
604603
while (next != jl_nothing) {
605604
roots[stackalloc] = next;
606605
jl_value_t *value = jl_fieldref(next, 0);
@@ -612,8 +611,8 @@ JL_CALLABLE(jl_f__apply)
612611
if (arg_heap)
613612
jl_gc_wb(arg_heap, value);
614613
roots[stackalloc + 1] = NULL;
615-
args[2] = state;
616-
next = jl_apply(args, 3);
614+
args[1] = state;
615+
next = jl_apply_generic(jl_iterate_func, args, 2);
617616
}
618617
roots[stackalloc] = NULL;
619618
extra -= 1;

0 commit comments

Comments
 (0)