Skip to content

Commit

Permalink
Merge pull request JuliaLang#32090 from JuliaLang/kf/clangsaclean
Browse files Browse the repository at this point in the history
Try to get GC analysis clean again
  • Loading branch information
Keno committed May 20, 2019
2 parents 25c33e4 + 297e353 commit 6e04733
Show file tree
Hide file tree
Showing 30 changed files with 318 additions and 210 deletions.
9 changes: 7 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ RUNTIME_C_SRCS := \
dlload sys init task array dump staticdata toplevel jl_uv datatype \
simplevector runtime_intrinsics precompile \
threading partr stackwalk gc gc-debug gc-pages gc-stacks method \
jlapi signal-handling safepoint jloptions timing subtype rtutils \
jlapi signal-handling safepoint jloptions timing subtype \
crc32c
RUNTIME_SRCS := APInt-C runtime_ccall processor $(RUNTIME_C_SRCS)
RUNTIME_SRCS := APInt-C runtime_ccall processor rtutils $(RUNTIME_C_SRCS)
SRCS := $(RUNTIME_SRCS)

ifeq ($(USEMSVC), 1)
Expand Down Expand Up @@ -324,6 +324,11 @@ clean-support:
cleanall: clean clean-flisp clean-support

analyzegc:
ifeq ($(USE_BINARYBUILDER_LLVM),0)
ifneq ($(BUILD_LLVM_CLANG),1)
$(error Clang must be available to use the clang analyzer. Either build it (BUILD_LLVM_CLANG) or use BinaryBuilder)
endif
endif
$(MAKE) -C clangsa
$(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)

Expand Down
4 changes: 2 additions & 2 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ typedef struct _jl_ast_context_t {
static jl_ast_context_t jl_ast_main_ctx;

#ifdef __clang_analyzer__
jl_ast_context_t *jl_ast_ctx(fl_context_t *fl) JL_GLOBALLY_ROOTED;
jl_ast_context_t *jl_ast_ctx(fl_context_t *fl) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
#else
#define jl_ast_ctx(fl_ctx) container_of(fl_ctx, jl_ast_context_t, fl)
#endif
Expand Down Expand Up @@ -203,7 +203,7 @@ static const builtinspec_t julia_flisp_ast_ext[] = {
{ NULL, NULL }
};

static void jl_init_ast_ctx(jl_ast_context_t *ast_ctx)
static void jl_init_ast_ctx(jl_ast_context_t *ast_ctx) JL_NOTSAFEPOINT
{
fl_context_t *fl_ctx = &ast_ctx->fl;
fl_init(fl_ctx, 4*1024*1024);
Expand Down
17 changes: 8 additions & 9 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int NOINLINE compare_fields(jl_value_t *a, jl_value_t *b, jl_datatype_t *
}
}
else {
jl_datatype_t *ft = (jl_datatype_t*)jl_field_type(dt, f);
jl_datatype_t *ft = (jl_datatype_t*)jl_field_type_concrete(dt, f);
if (jl_is_uniontype(ft)) {
uint8_t asel = ((uint8_t*)ao)[jl_field_size(dt, f) - 1];
uint8_t bsel = ((uint8_t*)bo)[jl_field_size(dt, f) - 1];
Expand Down Expand Up @@ -321,7 +321,7 @@ JL_DLLEXPORT uintptr_t jl_object_id_(jl_value_t *tv, jl_value_t *v) JL_NOTSAFEPO
u = (f == NULL) ? 0 : jl_object_id(f);
}
else {
jl_datatype_t *fieldtype = (jl_datatype_t*)jl_field_type(dt, f);
jl_datatype_t *fieldtype = (jl_datatype_t*)jl_field_type_concrete(dt, f);
if (jl_is_uniontype(fieldtype)) {
uint8_t sel = ((uint8_t*)vo)[jl_field_size(dt, f) - 1];
fieldtype = (jl_datatype_t*)jl_nth_union_component((jl_value_t*)fieldtype, sel);
Expand Down Expand Up @@ -472,7 +472,7 @@ void STATIC_INLINE _grow_to(jl_value_t **root, jl_value_t ***oldargs, jl_svec_t
*n_alloc = newalloc;
}

static jl_function_t *jl_iterate_func;
static jl_function_t *jl_iterate_func JL_GLOBALLY_ROOTED;

JL_CALLABLE(jl_f__apply)
{
Expand Down Expand Up @@ -597,10 +597,9 @@ JL_CALLABLE(jl_f__apply)
}
else {
assert(extra > 0);
jl_value_t *args[3];
args[0] = jl_iterate_func;
args[1] = ai;
jl_value_t *next = jl_apply(args, 2);
jl_value_t *args[2];
args[0] = ai;
jl_value_t *next = jl_apply_generic(jl_iterate_func, args, 1);
while (next != jl_nothing) {
roots[stackalloc] = next;
jl_value_t *value = jl_fieldref(next, 0);
Expand All @@ -612,8 +611,8 @@ JL_CALLABLE(jl_f__apply)
if (arg_heap)
jl_gc_wb(arg_heap, value);
roots[stackalloc + 1] = NULL;
args[2] = state;
next = jl_apply(args, 3);
args[1] = state;
next = jl_apply_generic(jl_iterate_func, args, 2);
}
roots[stackalloc] = NULL;
extra -= 1;
Expand Down
Loading

0 comments on commit 6e04733

Please sign in to comment.