Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mark_julia_const in codegen of typeof when type is known #15313

Merged
merged 1 commit into from
Mar 2, 2016

Conversation

JeffBezanson
Copy link
Member

This improves performance of #15146. In collect_to! there is a call to typeof in the inner loop, which was generating a store to the gc frame instead of a no-op. @vtjnash is this the right way to do this?

@carnaval
Copy link
Contributor

carnaval commented Mar 1, 2016

Should we instead have one of the post-inference pass replace every e::Type{X} with X where X has no typevar and e is effect free ?

@vtjnash
Copy link
Member

vtjnash commented Mar 1, 2016

no, expr_type should always have strictly worse type information than emit_typeof

@JeffBezanson
Copy link
Member Author

So should there instead be an overload of emit_typeof that returns a jl_cgval_t?

@vtjnash
Copy link
Member

vtjnash commented Mar 1, 2016

yeah, or just always return a jl_cgval_t, and use boxed(emit_typeof()) for the current usage

now `emit_typeof(jl_cgval_t&)` returns a jl_cgval_t, and
`emit_typeof_boxed` returns a Value*.

also optimize away `typeof` in `inlineable` along with other
type functions, and check argument for effect_free.
@JeffBezanson
Copy link
Member Author

Ok, I've done all of the above. Should be truly beaten to death now :)

@@ -1075,6 +1075,9 @@ static Value *emit_typeptr_addr(Value *p)
return emit_nthptr_addr(p, -offset);
}

static Value *boxed(const jl_cgval_t &v, jl_codectx_t *ctx, bool gcooted=true);
static Value *boxed(const jl_cgval_t &v, jl_codectx_t *ctx, jl_value_t* type) = delete; // C++11 (temporary to prevent rebase error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vtjnash what does "rebase error" mean here? from 3ac4574

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure there's no use of the original signature?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. C++ will silently convert from a jl_value_t* to bool during dispatch, potentially leading to unhappiness. this makes it a fast error, but won't compile on pre-C++11. if someone needs a pre-C++11 compiler and complains about this, we can either remove the = delete (turning misuse into a linker error), or the whole line (turning misuse into silent corruption).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need a pre-C++11 compiler when building against LLVM 3.3, so if this is behind enough ifdefs to not break that then I think we're fine. Hopefully compiler performance will be at parity soon enough that we could confidently remove the LLVM 3.3 code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need a pre-C++11 compiler when building against LLVM 3.3

We don't "need" pre-C++11 compiler, we just don't require a c++11 mode. All the compiler we support should support c++11 and we should just bump the compiler flags in Make.inc to enable it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang doesn't seem to care, but i don't know if gcc might

JeffBezanson added a commit that referenced this pull request Mar 2, 2016
use `mark_julia_const` in codegen of `typeof` when type is known
@JeffBezanson JeffBezanson merged commit a26b792 into master Mar 2, 2016
@tkelman tkelman deleted the jb/codegen_typeof branch March 2, 2016 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants