Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

verifier: Diagnose incorrect uses of INVALID #493

Closed
sunfishcode opened this issue Sep 3, 2018 · 4 comments
Closed

verifier: Diagnose incorrect uses of INVALID #493

sunfishcode opened this issue Sep 3, 2018 · 4 comments
Labels
E-compiler-easy Beginner–Intermediate compiler issues.

Comments

@sunfishcode
Copy link
Member

Cranelift has a VOID type but it's only used in a few contexts, because in general Cranelift prefers to use an array or vector of types which can be empty. As an example, it's particularly confusing that one can create a function with a return type of VOID, which turns out to be impossible to actually use. We should add verifier checks for this and other possible misuses of VOID.

@bjorn3
Copy link
Contributor

bjorn3 commented Sep 3, 2018

Returning VOID is equal to diverging isn't it?

@sunfishcode
Copy link
Member Author

Cranelift's VOID isn't actually used to indicate any actual typing concept, it's just a placeholder for IR data structures that have a type field but don't always need it. To hopefully clear up some of the understandable confusion, I've now renamed VOID to INVALID and updated the comments accordingly.

This issue can remain open, as we should still implement more verifier checks to ensure that INVALID doesn't appear in the IR, such as in function signatures.

@sunfishcode sunfishcode changed the title Diagnose incorrect uses of VOID Diagnose incorrect uses of INVALID Sep 5, 2018
@sunfishcode sunfishcode changed the title Diagnose incorrect uses of INVALID verifier: Diagnose incorrect uses of INVALID Sep 7, 2018
@sunfishcode sunfishcode added the E-compiler-easy Beginner–Intermediate compiler issues. label Sep 20, 2018
@ash-tamraz
Copy link

Where should the verifier checks to ensure that INVALID doesn't appear in the IR be implemented? I mean in terms of the files. Is it all in cranelift-codegen/src/verifier? I'm interested in working on this, where would be a good place to start?

@sunfishcode
Copy link
Member Author

Yes, this can be done entirely in cranelift-codegen/src/verifier. I think the best way to do this is to add new checks at the top of Verifier::run similar to verify_global_values etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E-compiler-easy Beginner–Intermediate compiler issues.
Projects
None yet
Development

No branches or pull requests

3 participants