Skip to content

Commit

Permalink
Fix codegen compilation warnings. (JuliaLang#36847)
Browse files Browse the repository at this point in the history
* uninitialized field warning
* LLVM 10 deprecation warning for CreateMemCpy
  • Loading branch information
yuyichao committed Aug 1, 2020
1 parent f2319b5 commit 84ef118
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,15 +1697,15 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)

ctx.builder.CreateMemCpy(
ctx.builder.CreateIntToPtr(destp, T_pint8),
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
MaybeAlign(1),
#else
1,
#endif
ctx.builder.CreateIntToPtr(
emit_unbox(ctx, T_size, src, (jl_value_t*)jl_voidpointer_type),
T_pint8),
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
MaybeAlign(0),
#else
0,
Expand Down
4 changes: 2 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, MDNode *tbaa_dst, Va
// for the load part (x.tbaa) and the store part (tbaa_stack).
// since the tbaa lattice has to be a tree we have unfortunately
// x.tbaa ∪ tbaa_stack = tbaa_root if x.tbaa != tbaa_stack
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
ctx.builder.CreateMemCpy(dst, MaybeAlign(align), src, MaybeAlign(0), sz, is_volatile, MDNode::getMostGenericTBAA(tbaa_dst, tbaa_src));
#else
ctx.builder.CreateMemCpy(dst, align, src, 0, sz, is_volatile, MDNode::getMostGenericTBAA(tbaa_dst, tbaa_src));
Expand All @@ -1491,7 +1491,7 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, MDNode *tbaa_dst, Va
emit_memcpy_llvm(ctx, dst, tbaa_dst, src, tbaa_src, const_sz->getZExtValue(), align, is_volatile);
return;
}
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
ctx.builder.CreateMemCpy(dst, MaybeAlign(align), src, MaybeAlign(0), sz, is_volatile, MDNode::getMostGenericTBAA(tbaa_dst, tbaa_src));
#else
ctx.builder.CreateMemCpy(dst, align, src, 0, sz, is_volatile, MDNode::getMostGenericTBAA(tbaa_dst, tbaa_src));
Expand Down
27 changes: 25 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ static const auto jlgetworld_global = new JuliaVariable{
static const auto jltls_states_func = new JuliaFunction{
"julia.ptls_states",
[](LLVMContext &C) { return FunctionType::get(PointerType::get(T_ppjlvalue, 0), false); },
nullptr,
};


Expand Down Expand Up @@ -476,21 +477,25 @@ static const auto jlcheckassign_func = new JuliaFunction{
"jl_checked_assignment",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_pjlvalue, PointerType::get(T_jlvalue, AddressSpace::CalleeRooted)}, false); },
nullptr,
};
static const auto jldeclareconst_func = new JuliaFunction{
"jl_declare_constant",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_pjlvalue}, false); },
nullptr,
};
static const auto jlgetbindingorerror_func = new JuliaFunction{
"jl_get_binding_or_error",
[](LLVMContext &C) { return FunctionType::get(T_pjlvalue,
{T_pjlvalue, T_pjlvalue}, false); },
nullptr,
};
static const auto jlboundp_func = new JuliaFunction{
"jl_boundp",
[](LLVMContext &C) { return FunctionType::get(T_int32,
{T_pjlvalue, T_pjlvalue}, false); },
nullptr,
};
static const auto jltopeval_func = new JuliaFunction{
"jl_toplevel_eval",
Expand Down Expand Up @@ -538,40 +543,48 @@ static const auto jlmethod_func = new JuliaFunction{
"jl_method_def",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_prjlvalue, T_prjlvalue, T_pjlvalue}, false); },
nullptr,
};
static const auto jlgenericfunction_func = new JuliaFunction{
"jl_generic_function_def",
[](LLVMContext &C) { return FunctionType::get(T_prjlvalue,
{T_pjlvalue, T_pjlvalue, T_pprjlvalue, T_pjlvalue, T_pjlvalue}, false); },
nullptr,
};
static const auto jlenter_func = new JuliaFunction{
"jl_enter_handler",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_pint8}, false); },
nullptr,
};
static const auto jl_current_exception_func = new JuliaFunction{
"jl_current_exception",
[](LLVMContext &C) { return FunctionType::get(T_prjlvalue, false); },
nullptr,
};
static const auto jlleave_func = new JuliaFunction{
"jl_pop_handler",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_int32}, false); },
nullptr,
};
static const auto jl_restore_excstack_func = new JuliaFunction{
"jl_restore_excstack",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_size}, false); },
nullptr,
};
static const auto jl_excstack_state_func = new JuliaFunction{
"jl_excstack_state",
[](LLVMContext &C) { return FunctionType::get(T_size, false); },
nullptr,
};
static const auto jlegal_func = new JuliaFunction{
"jl_egal",
[](LLVMContext &C) {
Type *T = PointerType::get(T_jlvalue, AddressSpace::CalleeRooted);
return FunctionType::get(T_int32, {T, T}, false); },
nullptr,
};
static const auto jl_alloc_obj_func = new JuliaFunction{
"julia.gc_alloc_obj",
Expand Down Expand Up @@ -621,12 +634,14 @@ static const auto jlisa_func = new JuliaFunction{
"jl_isa",
[](LLVMContext &C) { return FunctionType::get(T_int32,
{T_prjlvalue, T_prjlvalue}, false); },
nullptr,
};

static const auto jlsubtype_func = new JuliaFunction{
"jl_subtype",
[](LLVMContext &C) { return FunctionType::get(T_int32,
{T_prjlvalue, T_prjlvalue}, false); },
nullptr,
};
static const auto jlapplytype_func = new JuliaFunction{
"jl_instantiate_type_in_env",
Expand All @@ -641,6 +656,7 @@ static const auto jl_object_id__func = new JuliaFunction{
"jl_object_id_",
[](LLVMContext &C) { return FunctionType::get(T_size,
{T_prjlvalue, PointerType::get(T_int8, AddressSpace::Derived)}, false); },
nullptr,
};
static const auto setjmp_func = new JuliaFunction{
jl_setjmp_name,
Expand Down Expand Up @@ -669,11 +685,13 @@ static const auto jldlsym_func = new JuliaFunction{
"jl_load_and_lookup",
[](LLVMContext &C) { return FunctionType::get(T_pvoidfunc,
{T_pint8, T_pint8, PointerType::get(T_pint8, 0)}, false); },
nullptr,
};
static const auto jltypeassert_func = new JuliaFunction{
"jl_typeassert",
[](LLVMContext &C) { return FunctionType::get(T_void,
{T_prjlvalue, T_prjlvalue}, false); },
nullptr,
};
static const auto jlgetnthfieldchecked_func = new JuliaFunction{
"jl_get_nth_field_checked",
Expand Down Expand Up @@ -704,11 +722,13 @@ static const auto jlgetcfunctiontrampoline_func = new JuliaFunction{
static const auto diff_gc_total_bytes_func = new JuliaFunction{
"jl_gc_diff_total_bytes",
[](LLVMContext &C) { return FunctionType::get(T_int64, false); },
nullptr,
};
static const auto sync_gc_total_bytes_func = new JuliaFunction{
"jl_gc_sync_total_bytes",
[](LLVMContext &C) { return FunctionType::get(T_int64,
{T_int64}, false); },
nullptr,
};
static const auto jlarray_data_owner_func = new JuliaFunction{
"jl_array_data_owner",
Expand Down Expand Up @@ -745,14 +765,17 @@ BOX_FUNC(ssavalue, T_prjlvalue, T_size, nullptr);
static const auto gcroot_flush_func = new JuliaFunction{
"julia.gcroot_flush",
[](LLVMContext &C) { return FunctionType::get(T_void, false); },
nullptr,
};
static const auto gc_preserve_begin_func = new JuliaFunction{
"llvm.julia.gc_preserve_begin",
[](LLVMContext &C) { return FunctionType::get(Type::getTokenTy(C), true); },
nullptr,
};
static const auto gc_preserve_end_func = new JuliaFunction {
"llvm.julia.gc_preserve_end",
[](LLVMContext &C) { return FunctionType::get(T_void, {Type::getTokenTy(C)}, false); },
nullptr,
};
static const auto except_enter_func = new JuliaFunction{
"julia.except_enter",
Expand Down Expand Up @@ -3796,7 +3819,7 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
Value *isboxed = ctx.builder.CreateICmpNE(
ctx.builder.CreateAnd(Tindex_phi, ConstantInt::get(T_int8, 0x80)),
ConstantInt::get(T_int8, 0));
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
ctx.builder.CreateMemCpy(phi, MaybeAlign(min_align), dest, MaybeAlign(0), nbytes, false);
#else
ctx.builder.CreateMemCpy(phi, min_align, dest, 0, nbytes, false);
Expand Down Expand Up @@ -3840,7 +3863,7 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
// here it's moved into phi in the successor (from dest)
dest = emit_static_alloca(ctx, vtype);
Value *phi = emit_static_alloca(ctx, vtype);
#if JL_LLVM_VERSION >= 110000
#if JL_LLVM_VERSION >= 100000
ctx.builder.CreateMemCpy(phi, MaybeAlign(julia_alignment(phiType)),
dest, MaybeAlign(0),
jl_datatype_size(phiType), false);
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FunctionType *get_intr_args3(LLVMContext &C) { return FunctionType::get(T_prjlva
FunctionType *get_intr_args4(LLVMContext &C) { return FunctionType::get(T_prjlvalue, {T_prjlvalue, T_prjlvalue, T_prjlvalue, T_prjlvalue}, false); }

static JuliaFunction *runtime_func[num_intrinsics] = {
#define ADD_I(name, nargs) new JuliaFunction{"jl_"#name, get_intr_args##nargs},
#define ADD_I(name, nargs) new JuliaFunction{"jl_"#name, get_intr_args##nargs, nullptr},
#define ADD_HIDDEN ADD_I
#define ALIAS(alias, base) nullptr,
INTRINSICS
Expand Down

0 comments on commit 84ef118

Please sign in to comment.