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

Do we still need Ty::Unimplemented? #1536

Open
ltratt opened this issue Jan 7, 2025 · 2 comments
Open

Do we still need Ty::Unimplemented? #1536

ltratt opened this issue Jan 7, 2025 · 2 comments
Assignees

Comments

@ltratt
Copy link
Contributor

ltratt commented Jan 7, 2025

It feels like an odd enum variant for us to have to deal with: shouldn't it cause trace_builder to bork before it gets passed to the backend? But perhaps there's something here I haven't thought about!

@vext01
Copy link
Contributor

vext01 commented Jan 29, 2025

Looking at our IR serialiser, unimplemented types are emitted into the AOT IR when one of the following types are encountered:

The only reason we can't handle these types is that we haven't implemented a lowering. That said, some of these I expect are unlikely to ever be encountered in non-pathological programs, simply because they are just so rare/obscure (e.g. bfloat).

Why don't we just crash the serialiser when we encounter a type we can't handle? By deferring the crash to runtime it means we can JIT more programs if the AOT module contains a type we can't handle somewhere. As long as that type doesn't arise in traced code, we can still JIT that path.

Why don't we emit an unimplemented instruction instead, if an operand of an instruction is a type we can't handle? It makes the serialiser more complex, as we would have to insert code to check types of operands in lots of places.

Now to answer your question:

shouldn't it cause trace_builder to bork before it gets passed to the backend?

We could certainly do that. It would make the JIT IR more concise. In such a scenario we could abort tracing with an appropriate YK_LOG message and carry on. The AOT IR would still need the notion of an "unimplemented type".

Hope this helps.

@ltratt
Copy link
Contributor Author

ltratt commented Jan 29, 2025

shouldn't it cause trace_builder to bork before it gets passed to the backend?

We could certainly do that.

I think that would be best, as it would mean that nothing downstream of trace_builder needs to worry about this. [I do buy the "if we bork on Unimplemented in ykllvm, we might struggle to compile anything" argument".]

So I'm going to change this issue title, and it can be (hopefully!) an easy enough task to address this in trace_builder.

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

No branches or pull requests

2 participants