-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Fix indirect global-variable flow #14736
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
…nstead of the index (like we do for non-global uses as well).
… useful in the next commit.
01c5c58
to
39b9d2e
Compare
Here's my investigations so far:
to this strncpy that stores to a global: https://github.com/vim/vim/blob/a5a1ec1826c0e43d0282ba4d35c155a97bab3e27/src/option.c#L2088 and then flows to another use of the global here: https://github.com/vim/vim/blob/a5a1ec1826c0e43d0282ba4d35c155a97bab3e27/src/memline.c#L2568 The new ... And the new The new We write to a global variable here:
That global is then used almost immediately by a write to another global Which then taints the The flows all look genuine, so I'm happy with all of these new results 🎉 |
Oops. You're right. The bottom line in that commit should actually have been part of fd26ae1.
I think the commit message is accurate. The commit changes the implementation of For consistency this commit also implements a |
indirectionIndex = [0 .. defIndex] + 1 | ||
isDef(_, _, _, vai, indirection, indirectionIndex) |
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 change seems to offset the final argument of isDef
by 1, is that correct?
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.
Correct. So after this change any write to a global variable with indirection index indirectionIndex
generates a GlobalUse
SSA read at the end of the enclosing function with indirection index indirectionIndex
.
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.
LGTM. Note that I had some 1:1 discussion with @MathiasVP, which clarified most.
C++: Fix indirect global-variable flow
The logic for handling indirections of global variables was all wrong 😭. This PR hopefully fixes this logic 🤞.
The first commit adds a bunch of tests. I've then split the fix into a sequence of small commits. Finally, the last commit accepts the test changes.
There are a couple of new inconsistencies regarding missing
toString
on some esoteric syntax. I haven't investigated those yet, but I don't think they should block this PR.@jketema I'm requesting a review from you because you initially identified these missing steps. Let me know what I can do to help the review process here!