Skip to content

Commit

Permalink
Workaround LLVM bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jul 22, 2016
1 parent dffc068 commit 87b5b34
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,8 @@ static Value *emit_allocobj(jl_codectx_t *ctx, size_t static_size, Value *jt)
ArrayRef<Value*>(args, 2));
}
else {
Value *pool_ptr = builder.CreateConstGEP1_32(ptls_ptr, offset);
Value *args[] = {ptls_ptr, pool_ptr, ConstantInt::get(T_int32, osize),
Value *pool_offs = ConstantInt::get(T_int32, offset);
Value *args[] = {ptls_ptr, pool_offs, ConstantInt::get(T_int32, osize),
ConstantInt::get(T_int32, end_offset)};
v = builder.CreateCall(prepare_call(jlalloc_pool_func),
ArrayRef<Value*>(args, 4));
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5490,7 +5490,7 @@ static void init_julia_llvm_env(Module *m)

std::vector<Type*> alloc_pool_args(0);
alloc_pool_args.push_back(T_pint8);
alloc_pool_args.push_back(T_pint8);
alloc_pool_args.push_back(T_int32);
alloc_pool_args.push_back(T_int32);
alloc_pool_args.push_back(T_int32);
jlalloc_pool_func =
Expand Down
6 changes: 5 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,13 @@ static NOINLINE jl_taggedvalue_t *add_page(jl_gc_pool_t *p)
}

// Size includes the tag and the tag is not cleared!!
JL_DLLEXPORT jl_value_t *jl_gc_pool_alloc(jl_ptls_t ptls, jl_gc_pool_t *p,
JL_DLLEXPORT jl_value_t *jl_gc_pool_alloc(jl_ptls_t ptls, int pool_offset,
int osize, int end_offset)
{
// Use the pool offset instead of the pool address as the argument
// to workaround a llvm bug.
// Ref https://llvm.org/bugs/show_bug.cgi?id=27190
jl_gc_pool_t *p = (jl_gc_pool_t*)((char*)ptls + pool_offset);
assert(ptls->gc_state == 0);
#ifdef MEMDEBUG
return jl_gc_big_alloc(ptls, osize);
Expand Down
4 changes: 2 additions & 2 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern unsigned sig_stack_size;
JL_DLLEXPORT extern int jl_lineno;
JL_DLLEXPORT extern const char *jl_filename;

JL_DLLEXPORT jl_value_t *jl_gc_pool_alloc(jl_ptls_t ptls, jl_gc_pool_t *p,
JL_DLLEXPORT jl_value_t *jl_gc_pool_alloc(jl_ptls_t ptls, int pool_offset,
int osize, int end_offset);
JL_DLLEXPORT jl_value_t *jl_gc_big_alloc(jl_ptls_t ptls, size_t allocsz);
int jl_gc_classify_pools(size_t sz, int *osize, int *end_offset);
Expand Down Expand Up @@ -133,7 +133,7 @@ STATIC_INLINE jl_value_t *jl_gc_alloc_(jl_ptls_t ptls, size_t sz, void *ty)
osize = p->osize;
endoff = p->end_offset;
}
v = jl_gc_pool_alloc(ptls, p, osize, endoff);
v = jl_gc_pool_alloc(ptls, (char*)p - (char*)ptls, osize, endoff);
}
else {
v = jl_gc_big_alloc(ptls, allocsz);
Expand Down

0 comments on commit 87b5b34

Please sign in to comment.