WIP: Poison constants#379
Open
chambart wants to merge 6 commits intoocaml-flambda:flambda2.0-stablefrom
Open
Conversation
Author
|
This is a first draft. This is similar to LLVM poison value. They have two kind of undefined variables Undef and Poison. |
Author
|
By the way after testing I think I will change the definition of the constant. I thought it would be simpler this way, but now I think it will be simpler to have a case Poison in the Const_data rather than a field |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a first attempt of adding poison constants to flambda to represent arguments present in a branch and not in an other. This can arise from unboxing. For instance an example where this matter is: (it has to be compiled with
-flambda-expert-max-inlining-depth 2)The
ffunction is analysed twice: once for definition, and a second time when inlining.The first time the variant is correctly unboxed and all is well. And the branches of the switch ends in:
But the second time, the branches join the apply_result/214 and 0 and apply_result/215 and 42.
For the first round this was not a problem because the typing environment was 'hand built' by
unbox_continuation_param which didn't do that join. But the second round can't do that. Hence the
result can't be optimized when the
gfunction is inlinedIn that case the 0 is replaced by a Poison constant.
A Poison constant is a new kind of constants of type Poison that is somewhat
equivalent to bottom, but not really. It is ok to have a variable of type poison in the environment,
but using its value turns into bottom. This is done by
expand_head.That way the join of the poison and
12here is12which allows to propagate things further.It is not the case right now, but poison constants can also be used to track undefined variables during
Un_cps that would allow some parameter sharing.