Skip to content

[5.3] Pull in changes from PR 34323, 34327, 34445 and 34495 #34791

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 9 commits into from
Nov 18, 2020

Conversation

shahmishal
Copy link
Member

Pull in changes from:

  • [5.3] Fix a miscompile of global variables
  • [5.3][stdlib] Fix Array.append(contentsOf:) for arguments of type NSArray
  • [temp-rvalue-opt] Disable handling of load [take] in temp-rvalue-elim.
  • [5.3][Sema] Consider inherited platform unavailability to silence diagnostics

xymus and others added 9 commits October 14, 2020 16:14
[5.3][Sema] Consider inherited platform unavailability to silence diagnostics
This pass was attempting to handle cases where we use load [take] +
destroy_value instead of a destroy_addr since we have a loadable value. There
are a few issues around how this was done, so for 5.3, we are just going to turn
off the optimization.

rdar://70356725
[temp-rvalue-opt] Disable handling of load [take] in temp-rvalue-elim.
Due to a couple of unfortunate circumstances, appending an NSArray instance to an Array instance does not actually append any elements.

The cause is #29220, which accidentally optimized away the actual loop that appends the elements in this particular case. (And only this particular case, which is why this wasn’t detected by the test suite.)

When the argument to `Array.append(contentsOf:)` is of type NSArray, the `newElements is [Element]` expression is compiled into a runtime check that returns true, eliminating the subsequent loop over the remaining items of the iterator. Sadly, NSArray.underestimatedCount` currently returns 0, so the earlier _copyContents call is a noop, so no elements get added to `self` at all.

Turning the `is` test into a direct equality check between the metatype instances resolves the issue.

(cherry picked from commit 184367c)
[5.3][stdlib] Fix Array.append(contentsOf:) for arguments of type NSArray
)

GlobalOpt works mostly on trivial values (there are special cases for ObjectInst and ValueToBridgeObjectInst).
optimizeGlobalAccess is explicitly turned off for non-trivial values. optimizeInitializer calls SILGlobalVariable::isValidStaticInitializerInst which limits it to mostly trivial values except for special cases for ObjectInst and ValueToBridgeObjectInst.

This changes adds GlobalOpt tests for ossa and enables GlobalOpt on ossa

Co-authored-by: Meghana Gupta <[email protected]>
@shahmishal shahmishal requested a review from a team as a code owner November 17, 2020 21:58
@shahmishal
Copy link
Member Author

@swift-ci test

@eeckstein
Copy link
Contributor

Why did you include #32621? It's not a bug fix.

@shahmishal
Copy link
Member Author

@eeckstein It was merged in to 5.3-20201012 branch - #34495

@eeckstein
Copy link
Contributor

Ah sorry, it was actually a bug fix

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@shahmishal shahmishal merged commit d9ce289 into release/5.3 Nov 18, 2020
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants