forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inference annotations that can be read by an external tool
This builds on top of JuliaLang#35831, letting inference emit a custom message whenever it gives up on infering something. These messages are intended to be displayed by external tools, either to debug what inference is doing (e.g. for Cthulhu) or, if an external compiler needs to disallow certain kinds of missing information (e.g. no dynamic dispatch on GPUs), can be used to improve diagnostics. This is mostly a proof of concept, I think these messages/hooks need to be a bit richer for a full solution, though I think this can be already useful if we hook up something like Cthulhu. As a proof of concept, I hacked up a 10 line function that reads these messagse. It works something like the following: ``` function bar() sin = eval(:sin) sin(1) end foo() = bar() ``` ``` julia> Compiler3.analyze_static(Tuple{typeof(foo)}) In function: bar() ERROR: The called function was unknown 1| function bar() 2| sin = eval(:sin) => sin(1) 4| end [1] In foo() ``` The reason this needs to sit on top of JuliaLang#35831 is that it needs to run with a completely fresh cache, which JuliaLang#35831 provides the primitives for. Otherwise, while you could still get the annotations out, that would only work the first time something is inferred anywhere in the system. With a fresh cache, everything is analyzed again, and any messages like these that are opted in to can be collected.
- Loading branch information
1 parent
029a218
commit 61bac8b
Showing
3 changed files
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters