-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][dataflow] Propagate locations from result objects to initializers. #87320
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
Merged
martinboehme
merged 3 commits into
llvm:main
from
martinboehme:piper_export_cl_608290664
Apr 10, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
96ca082
[clang][dataflow] Propagate locations from result objects to initiali…
martinboehme d27da81
fixup! [clang][dataflow] Propagate locations from result objects to i…
martinboehme 4ae9d7e
fixup! fixup! [clang][dataflow] Propagate locations from result objec…
martinboehme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
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.
What would be the model for something like:
where
f
returns a value. Do we have the same storage location for the prvalue in all iterations? In that case, the location is in fact a "summary" for the different iterations. I think this is fine, as we want convergence. I am just wondering if we need to make this explicit in the future, so checks would know if a location were a summary, or an exact location.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.
Would it make sense for this to be owned by the
DataflowAnalysisContext
?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.
Let me clarify what you're asking.
I think what you mean is that
f()
is declared like this, correct?In this case, there is indeed no glvalue of type
S
-- just the prvalue for the callf()
. Normally, of course, prvalues don't have storage locations, but in this case, because there isn't an actual result object, we treat theCallExpr
as if it was aMaterializeTemporaryExpr
(see comment inResultObjectVisitor::VisitExpr()
).(Just making sure up to here that we agree on the setting -- do you agree with all of the above?)
First of all, yes, we use the same storage location on all iterations of the loop -- witness the call to
DACtx.getStableStorageLocation(*E)
.I'm not sure I would agree with this. Let's assume this was a case where we actually have a
MaterializeTemporaryExpr
(imagine we're accessing some member ofS
, i.e. assume the expression in the loop is actuallyf().some_member_fn()
). Then the compiler's codegen would very likely place the temporary in the same storage location on every iteration of the loop. (Sure, nothing in the standard mandates this AFAIK, but it's almost certainly what the compiler is going to do.) So the stable storage location that we use for the expression isn't a "summary" storage location, but it reflects the fact that the generated code, too, would use the same storage location.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.
Unfortunately, no.
The
DataflowAnalysisContext
is shared by the whole analysis -- which may span several functions if we're doing a context-sensitive analysis.In contrast, the result object map is specific to a given function, just like some of the other fields that are in
Environment
(CallStack
,ReturnVal
,ReturnLoc
andThisPointeeLoc
). See the comment above saying that we should create a call-context object (which would be a per-function data structure) and move all of these fields to it.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.
Ah, ok. +1, I like this approach.