Skip to content

[Constant Evaluator] Enable SILConstants::setIndexedElement function to work with aggregates containing unknown values #65003

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
merged 1 commit into from
Apr 8, 2023

Conversation

ravikandhadai
Copy link
Contributor

@ravikandhadai ravikandhadai commented Apr 7, 2023

Such aggregates can be generated when an instruction is skipped during constant evaluation and its results are used to create a struct.

rdar://107344820

to work with aggregates containing unknown values. Such aggregates
can be generated when an instruction is skipped during constant
evaluation and its results are used to create a struct.
@ravikandhadai
Copy link
Contributor Author

@swift-ci smoke test


%6 = struct_element_addr %5 : $*StructWithSkippedElements, #StructWithSkippedElements.unknownValue
%7 = struct_element_addr %6 : $*UnknownStruct, #UnknownStruct.value
store %1 to %7 : $*Int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand the new behavior better. Now that this known value has been set in the location of the unknown value, what is the expected behavior? The code below appears to be simply accessing the known value in the first field of StructWithSkippedElements, but what if we were to now try to access %5.unknownValue.value again now that we've tried to set it? Would we get an unknown because the set would not actually have occurred, or would it have occurred and we'd be left with 301? I'm guessing the first option (we'd get an unknown).

Copy link
Contributor Author

@ravikandhadai ravikandhadai Apr 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewseaman that's a great question. Yes, unknown. It is a conservative but safe option. It is certainly possible to teach the constant evaluator to again track the constant value being assigned to the property, but it will be bit more complex to correctly implement it, and also we don't need that capability for any application at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants