Skip to content

Commit

Permalink
Merge pull request #21307 from JuliaLang/jn/incremental-correctness
Browse files Browse the repository at this point in the history
incremental precompile correctness issues
  • Loading branch information
vtjnash authored Apr 12, 2017
2 parents d91a719 + 8d16ddd commit bdd4d77
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 86 deletions.
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ function finalize_backedges(frame::InferenceState)
end

function code_for_method(method::Method, atypes::ANY, sparams::SimpleVector, world::UInt, preexisting::Bool=false)
if world < min_world(method) || world > max_world(method)
if world < min_world(method)
return nothing
end
if method.isstaged && !isleaftype(atypes)
Expand Down
2 changes: 1 addition & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end

function kwarg_decl(m::Method, kwtype::DataType)
sig = rewrap_unionall(Tuple{kwtype, Core.AnyVector, unwrap_unionall(m.sig).parameters...}, m.sig)
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, max_world(m))
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, typemax(UInt))
if kwli !== nothing
kwli = kwli::Method
src = uncompressed_ast(kwli, kwli.source)
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,6 @@ has_bottom_parameter(t::TypeVar) = has_bottom_parameter(t.ub)
has_bottom_parameter(::Any) = false

min_world(m::Method) = reinterpret(UInt, m.min_world)
max_world(m::Method) = reinterpret(UInt, m.max_world)
max_world(m::Method) = typemax(UInt)
min_world(m::Core.MethodInstance) = reinterpret(UInt, m.min_world)
max_world(m::Core.MethodInstance) = reinterpret(UInt, m.max_world)
3 changes: 0 additions & 3 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,6 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
if ex.world < min_world(method)
print(buf, " (method too new to be called from this world context.)")
end
if ex.world > max_world(method)
print(buf, " (method deleted before this world age.)")
end
# TODO: indicate if it's in the wrong world
push!(lines, (buf, right_matches))
end
Expand Down
12 changes: 4 additions & 8 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,26 +931,22 @@ static inline void maybe_mark_argument_dereferenceable(Argument *A, jl_value_t *
if (!size) {
return;
}
llvm::AttrBuilder Attrs;
Attrs.addDereferenceableAttr(size);
#if JL_LLVM_VERSION >= 50000
A->addAttr(llvm::AttributeList::get(jl_LLVMContext,
A->getArgNo() + 1, Attrs));
#else
A->addAttr(llvm::AttributeSet::get(jl_LLVMContext,
A->getArgNo() + 1, Attrs));
#if JL_LLVM_VERSION >= 30700
A->getParent()->addDereferenceableAttr(A->getArgNo() + 1, size);
#endif
}

static inline Instruction *maybe_mark_load_dereferenceable(Instruction *LI, bool can_be_null, size_t size) {
if (!size) {
return LI;
}
#if JL_LLVM_VERSION >= 30700
llvm::SmallVector<Metadata *, 1> OPs;
OPs.push_back(ConstantAsMetadata::get(ConstantInt::get(T_int64, size)));
LI->setMetadata(can_be_null ? "dereferenceable_or_null" :
"dereferenceable",
MDNode::get(jl_LLVMContext, OPs));
#endif
return LI;
}

Expand Down
2 changes: 2 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5033,7 +5033,9 @@ static jl_returninfo_t get_specsig_function(Module *M, const std::string &name,
continue;
if (ty->isAggregateType()) { // aggregate types are passed by pointer
attributes = attributes.addAttribute(jl_LLVMContext, fsig.size() + 1, Attribute::NoCapture);
#if JL_LLVM_VERSION >= 30500
attributes = attributes.addAttribute(jl_LLVMContext, fsig.size() + 1, Attribute::ReadOnly);
#endif
ty = PointerType::get(ty, 0);
}
fsig.push_back(ty);
Expand Down
Loading

0 comments on commit bdd4d77

Please sign in to comment.