Skip to content

Rdar 27397701 synthesized get set typechecking #5588

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

graydon
Copy link
Contributor

@graydon graydon commented Nov 2, 2016

Addresses redundant typechecking of getter/setter function bodies outside of the primary file.
This is responsible for unnecessary quadratic work when doing a multi-file compilation.
PR also includes more scale-testing machinery, and a regression test that uses it.

Resolves SR-2901.
Resolves rdar://27397701

@graydon
Copy link
Contributor Author

graydon commented Nov 2, 2016

@swift-ci please test


#include "llvm/ADT/Statistic.h"

#define SWIFT_FUNC_STAT \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need a do { ... } while (0) given how often braceless control flow is used, or are macro hacks like that not Swift/LLVM style?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, that definitely would be preferred.

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

In the future, can you split things like this up into multiple PRs? The statistics-gathering seems separate from the fixes.

@@ -763,17 +767,25 @@ void swift::addTrivialAccessorsToStorage(AbstractStorageDecl *storage,

// Synthesize and type-check the body of the getter.
synthesizeTrivialGetter(getter, storage, TC);
TC.typeCheckDecl(getter, true);
TC.typeCheckDecl(getter, false);
if (storage->getDeclContext()->isModuleScopeContext()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why this is the right check. What's different about members? Why can't I just validate accessors at module scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without that check, various resilience tests fail when emitting global getters (compiler crashes). I imagine this is due to unconditional emission of those getters, w/o being driven by any other references.

Seems to work when I tighten the condition to "only when in resilient mode", so I'll try that (and add a comment to that extent).

@swift-ci
Copy link
Contributor

swift-ci commented Nov 2, 2016

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 948fa2b5e7394eb9be4298e9d4b2d3411b35590b
Test requested by - @graydon

@DougGregor
Copy link
Member

Looks like we can't rely on numpy being around

This was referenced Nov 2, 2016
@graydon graydon force-pushed the rdar-27397701-synthesized-get-set-typechecking-redux branch from 948fa2b to 07d8594 Compare November 2, 2016 17:06
@graydon
Copy link
Contributor Author

graydon commented Nov 2, 2016

Split scale-test and stats helpers into separate PRs (#5607 and #5608 respectively) that this one depends on. Also fixed numpy and macro definition problems in them.

@graydon graydon force-pushed the rdar-27397701-synthesized-get-set-typechecking-redux branch from 07d8594 to e7336b6 Compare November 2, 2016 17:46
@graydon graydon force-pushed the rdar-27397701-synthesized-get-set-typechecking-redux branch from e7336b6 to 166eebe Compare November 2, 2016 18:50
@graydon
Copy link
Contributor Author

graydon commented Nov 2, 2016

Updated to unconditionally typecheck all accessors-with-bodies in decl visitor (that's applied to all SF-local decls) rather than trying to switch behaviour for resilient globals.

PR still depends on #5607 and #5608 to land first.

@DougGregor
Copy link
Member

This looks fantastic, thanks!

@graydon
Copy link
Contributor Author

graydon commented Nov 2, 2016

@swift-ci please smoke test and merge

@graydon
Copy link
Contributor Author

graydon commented Nov 2, 2016

@swift-ci please smoke test linux and merge

@graydon
Copy link
Contributor Author

graydon commented Nov 3, 2016

@swift-ci please smoke test linux

@graydon graydon merged commit 9351843 into swiftlang:master Nov 3, 2016
@graydon graydon deleted the rdar-27397701-synthesized-get-set-typechecking-redux branch January 18, 2017 22:35
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.

5 participants