Skip to content

[AddressLowering] Some small fixes. #61945

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

Conversation

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Nov 4, 2022

See individual commit messages for details.

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler force-pushed the opaque-values/3/20221103 branch 2 times, most recently from 3852857 to 5c471da Compare November 5, 2022 02:59
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler force-pushed the opaque-values/3/20221103 branch from 5c471da to f87a4d5 Compare November 5, 2022 06:03
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler marked this pull request as ready for review November 5, 2022 17:00
Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

A couple comments...

The test's correctness doesn't depend on the exact sequence of
instructions.  Use IDs to allow for other instructions to appear.
When rewriting uses, it is possible for new uses of a value to be
created, as when a  debug_value instruction is created when a store
instruction is deleted.  Ensure that all uses are rewritten by adding
all uses to the worklist of uses after rewriting each use.
Resizing a SmallVector of SILValues fills it with invalid SILValues.
THe intent is to reserve space for forthcoming values.
The filterDeadArgs function takes a list of dead argument
indices--ordered from least to greatest--a list of original arguments,
and produces a list of arguments excluding the arguments at those dead
indices.

It does that by iterating from 0 to size(originalArguments) - 1, adding
the original argument at that index to the list of new arguments, so
long as the index that of a dead argument.  To avoid doing lookups into
a set, this relies on the dead arguments being ordered ascending.  There
is an interator into the dead argument list that is incremented only
when the current index is dead.

When that iterator is at the end, dereferencing it just gives the size
of the array of dead arguments.  So in the case where the first argument
is dead but no other arguments are, and there _are_ other arguments, the
first argument would be skipped, and the second argument's index would
be found to be equal to the dereferenced iterator (1).

Previously, there was no check that the iterator was not at the end.
The result was failing to add the second argument to the new list.  And
tripping an assertion failure.

Here, it is checked that the iterator is not at the end.
@nate-chandler nate-chandler force-pushed the opaque-values/3/20221103 branch from f87a4d5 to 81d37be Compare November 8, 2022 00:53
@nate-chandler
Copy link
Contributor Author

@swift-ci please test and merge

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macOS platform

@nate-chandler nate-chandler merged commit c4ebdeb into swiftlang:main Nov 8, 2022
@nate-chandler nate-chandler deleted the opaque-values/3/20221103 branch November 8, 2022 20:33
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.

3 participants