-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix phi node value renumbering issue #28099
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
Conversation
base/compiler/ssair/ir.jl
Outdated
@@ -679,7 +679,7 @@ function process_phinode_values(old_values::Vector{Any}, late_fixup::Vector{Int} | |||
used_ssas[val.id] += 1 | |||
end | |||
elseif isa(val, OldSSAValue) | |||
if val.id > processed_idx | |||
if val.id >= processed_idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test passes without this one. I do think the change is correct, but if someone can come up with a piece of code that comes here with val.id==processed_idx
to build a test case, that would be appreciated.
freebsd failure is #28101. |
Thanks. I'm very happy that other people are starting to be able to make changes to this code. I particularly appreciate the test case in this PR. However, I think the real bug here is different. Adding the current statement to the rename table is supposed to happen before renaming of the phinode arguments, so it seemed to me the original code is correct. Instead I think what's happening is that the processed_idx is wrong for newly inserted nodes (passing the old idx of the reference statement instead). I think something like this may work:
|
7cb655b
to
52be376
Compare
Yep, that patch seems to be working. Updated PR accordingly. (I don't fully understand what's happening, so @Keno if you can come up with a more descriptive commit message...) |
Actually, that's still incorrect. I think |
When inserting new nodes during compaction, we need to rename all arguments. For performance, we keep track of which nodes we have already processed, renaming them immediately, and only scheduling those we have not for later re-processing. However, the was an off-by-one error in this logic such that a phi node refering to the statement it is being attached to would not get scheduled for later fixup.
The fact that we had three similar, but not equivalent patches that all fixed the issue and did not break any other tests makes me a bit uneasy. Ideally, we would have tests that had failed for the wrong fixes here. I'm clueless how to construct such tests, though. |
If a φ node got placed at a position one of its values referenced, that reference wasn't updated.
Fixes #28077.