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

Fix codegen-issues with multi-edge phi #27609

Merged
merged 2 commits into from
Jun 16, 2018
Merged

Fix codegen-issues with multi-edge phi #27609

merged 2 commits into from
Jun 16, 2018

Conversation

Keno
Copy link
Member

@Keno Keno commented Jun 16, 2018

See commit messages. Fixes #27594, #27597.

Keno added 2 commits June 15, 2018 23:15
It is possible, after optimziations for the two branches of a conditional
to go to the same basic block. We have an IR invariant that requires the
incoming value to be the same for both incoming edges in this case. LLVM
has the same invariant. However, translating from a julia-incoming-value
to an LLVM one may require additional code generation, and without further
GVN, LLVM does not know that the two values are identical and thus believes
its invariants are violated. The fix is relatively straightforward. Since
we don't have user-inserted switch terminators, we can simply emit a
conditional branch with equal successors as unconditional branches and
skip codegening one of the phi paths. This avoids the issue and also
generates less code in this case.

Fixes #27594
The problem here was that we had an incomplete phi from a multi-branch,
but the logic that fills up the phi with `undef`s for incomplete phis,
only added one entry to the phi node. Rather than the two that LLVM was
expecting. Since the previous commit prevents us from turning conditional
branches into multi-edge phis, this problem does not occur anymore.
With this test, this fixes #27597
@ararslan ararslan added compiler:codegen Generation of LLVM IR and native code bugfix This change fixes an existing bug labels Jun 16, 2018
@Keno Keno merged commit 5e3259e into master Jun 16, 2018
@StefanKarpinski StefanKarpinski deleted the kf/multiedge-phi branch June 17, 2018 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants