Skip to content

Make __consuming meaningful for code generation. #19613

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
Oct 1, 2018

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Sep 28, 2018

Previously, the __consuming decl modifier failed to get propagated to the value ownership of the
method's self parameter, causing it to effectively be a no-op. Fix this, and address some of the
downstream issues this exposes:

  • coerceCallArguments in the type checker failing to handle the single __owned parameter case
  • Various places in SILGen and optimizer passes that made inappropriate assertions that self
    was always passed guaranteed

rdar://problem/44769874

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@swift-ci Please benchmark

!AI->getSubstCalleeType()->getExtInfo().hasGuaranteedSelfParam())
if (Release && AI /*
&& (!AI->getSubstCalleeType()->hasSelfParam()
|| !AI->getSubstCalleeType()->getSelfParameter().isGuaranteed())*/)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gottesmm Do you know what this hasGuaranteedSelfParam check was trying to accomplish? Removing doesn't appear to have any effect on the test suite, and this was the only remaining use of a broken SILFunctionType::hasGuaranteedSelfParam() method.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would just rip it out.

@jckarter
Copy link
Contributor Author

cc @airspeedswift

Previously, the `__consuming` decl modifier failed to get propagated to the value ownership of the
method's `self` parameter, causing it to effectively be a no-op. Fix this, and address some of the
downstream issues this exposes:

- `coerceCallArguments` in the type checker failing to handle the single `__owned` parameter case
- Various places in SILGen and optimizer passes that made inappropriate assertions that `self`
  was always passed guaranteed
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@swift-ci Please benchmark

1 similar comment
@jckarter
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - bc49480dc293a54735894981898cf9d9cadbfaa7

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - bc49480dc293a54735894981898cf9d9cadbfaa7

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
IterateData 1565 1785 +14.1% 0.88x (?)
Improvement
LuhnAlgoLazy 454 295 -35.0% 1.54x
LuhnAlgoEager 438 294 -32.9% 1.49x
StringMatch 12235 11260 -8.0% 1.09x (?)
CharIteration_utf16_unicodeScalars 26670 24730 -7.3% 1.08x
RemoveWhereMoveInts 15 14 -6.7% 1.07x

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
IterateData.o 1388 1452 +4.6% 0.96x
Queue.o 12051 12451 +3.3% 0.97x
AnyHashableWithAClass.o 3604 3684 +2.2% 0.98x
RC4.o 5166 5230 +1.2% 0.99x
Improvement
LuhnAlgoEager.o 20131 18344 -8.9% 1.10x
LuhnAlgoLazy.o 20127 18341 -8.9% 1.10x
ArrayAppend.o 41843 39198 -6.3% 1.07x
StringWalk.o 48082 45242 -5.9% 1.06x
DictOfArraysToArrayOfDicts.o 35142 33894 -3.6% 1.04x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
COWArrayGuaranteedParameterOverhead 10134 11478 +13.3% 0.88x
DropLastAnyCollection 59 66 +11.9% 0.89x
IterateData 1640 1813 +10.5% 0.90x (?)
Improvement
SuffixAnyCollection 66 59 -10.6% 1.12x
StringMatch 12130 11141 -8.2% 1.09x (?)
FloatingPointPrinting_Float_description_uniform 5646 5271 -6.6% 1.07x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
UTF8Decode.o 12983 13415 +3.3% 0.97x
IterateData.o 1564 1596 +2.0% 0.98x
RC4.o 4056 4120 +1.6% 0.98x
AnyHashableWithAClass.o 3884 3932 +1.2% 0.99x
LuhnAlgoLazy.o 15766 15942 +1.1% 0.99x
LuhnAlgoEager.o 15770 15946 +1.1% 0.99x
Improvement
StringWalk.o 40642 37290 -8.2% 1.09x
StringMatch.o 8097 7985 -1.4% 1.01x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
CountAlgoString 4984 7263 +45.7% 0.69x
FatCompactMap 293511 352503 +20.1% 0.83x
WordCountUniqueUTF16 9973 11566 +16.0% 0.86x
ArrayOfPOD 758 860 +13.5% 0.88x (?)

Code size: Swift libraries

TEST OLD NEW DELTA RATIO
Improvement
libswiftStdlibUnittest.dylib 409600 405504 -1.0% 1.01x
How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false alarms. Unexpected regressions which are marked with '(?)' are probably noise. If you see regressions which you cannot explain you can try to run the benchmarks again. If regressions still show up, please consult with the performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@@ -5753,6 +5753,17 @@ Expr *ExprRewriter::coerceCallArguments(
// If we came from a scalar, create a scalar-to-tuple conversion.
TupleShuffleExpr::TypeImpact typeImpact;
if (argTuple == nullptr) {
// Deal with a difference in only scalar ownership.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yuck. Hopefully this all goes away one day.

!AI->getSubstCalleeType()->getExtInfo().hasGuaranteedSelfParam())
if (Release && AI /*
&& (!AI->getSubstCalleeType()->hasSelfParam()
|| !AI->getSubstCalleeType()->getSelfParameter().isGuaranteed())*/)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just rip it out.

@jckarter
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jckarter
Copy link
Contributor Author

Compat suite failure in 'Fluent' looks unrelated.

@jckarter jckarter merged commit 5414747 into swiftlang:master Oct 1, 2018
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