-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inference: backward constraint propagation from call signatures
This PR implements another (limited) backward analysis pass in abstract interpretation; it exploits signatures of matching methods and refines types of slots. Here are couple of examples where these changes will improve the accuracy: > generic function example ```julia addi(a::Integer, b::Integer) = a + b Base.return_types((Any,Any,)) do a, b c = addi(a, b) return a, b, c # now the compiler understands `a::Integer`, `b::Integer` end ``` > `typeassert` example ```julia Base.return_types((Any,)) do a typeassert(a, Int) return a # now the compiler understands `a::Int` end ``` This PR consists of two main parts: 1.) obtain refinement information and back-propagate it, and 2.) apply state updates As for 1., unlike conditional constraints, refinement information isn't encoded within lattice element, but rather they are stored in the newly defined field `InferenceState.state_updates`, which is refreshed on each program counter increment. For now refinement information is obtained from call signatures of generic functions and `typeassert`. Finally, in order to apply multiple state updates, this PR extends `StateUpdate` and `stupdate` so that they can hold and apply multiple state updates.
- Loading branch information
Showing
4 changed files
with
247 additions
and
28 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
Oops, something went wrong.