-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Make InitializeParameter
and Uninitialized
return memory results
#72
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
#67 is merged. To make GitHub forget the overlapping commits, you may have to close and re-open. Or maybe rebase. |
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.
I haven't worked with InitializeParameter
and Uninitialized
before, so please help me understand them. Why do they work in a different way than UnmodeledDefinition
? To me it seems like they are describing the same sort of thing: an SSA definition originates from a location that is external to the function we are analysing. For InitializeParameter
and Uninitialized
we know something extra about where the value came from, and this might be useful to other analyses, but why does that mean the memory edges need to be wired differently?
I think this change actually makes |
To add the additional background you asked for: |
…ults The IR avoids having non-trivially-copyable and non-trivially-assignable types in register results, because objects of those types need to exist at a particular memory location. The `InitializeParameter` and `Uninitialized` instructions were violating this restriction because they returned register results, which were then stored into the destination location via a `Store`. This change makes those two instructions take the destination address as an operand, and return a memory result representing the (un-)initialized memory, removing the need for a separate `Store` instruction.
56db3c3
to
f2053c4
Compare
Thanks for the clarification. I think my confusion is over whether I should conceptually think of these instructions as storing an unknown value into the variable or as terminators of the loose source ends in the SSA graph. I agree that this change brings them closer to the latter. Looking at the test output in its new and helpful format (:heart: #65), a function with a parameter
to this:
That's an improvement, but I don't understand why
|
In order to do alias analysis and build SSA, we need to know what memory location (or locations) may be defined by the result of each instruction. There are currently four kinds of memory access that alias analysis knows about (from "MemoryAccessKind.qll": Merging the If we wanted to only mention I'd like to reconsider the whole "all memory accesses are indirect" decision after we've written one or two real queries on the IR. My original theory was that making everything indirect would mean fewer cases to handle in anything that used the IR. If it turns out that our real usage of the IR doesn't need to make that distinction, and only the guts of alias analysis and SSA construction care, then I'd probably be OK with introducing direct loads and stores of variables and fields to make the IR a bit smaller. |
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.
Thanks for the explanation. It sounds right that we should wait and see how these memory access kinds work out in practice.
…ion-repeats Don't abort external class extraction after first duplicate
feat(queries): Improve Output Clobbering query
The IR avoids having non-trivially-copyable and non-trivially-assignable types in register results, because objects of those types need to exist at a particular memory location. The
InitializeParameter
andUninitialized
instructions were violating this restriction because they returned register results, which were then stored into the destination location via aStore
.This change makes those two instructions take the destination address as an operand, and return a memory result representing the (un-)initialized memory, removing the need for a separate
Store
instruction.Note: This PR is rebased on top of the commits for pending PR #67. Only commit 56db3c3 needs to be reviewed. Once #67 is merged, the other commits should disappear from this PR. I'll remove the WIP label once that happens.