Skip to content

[IRGen][interop] do not add 'nocapture' to not bitwise takable types #68481

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
Sep 26, 2023

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Sep 13, 2023

The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687

@hyp hyp added c++ interop Feature: Interoperability with C++ IRGen LLVM IR generation labels Sep 13, 2023
@hyp
Copy link
Contributor Author

hyp commented Sep 13, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 13, 2023

@swift-ci please benchmark

@hyp
Copy link
Contributor Author

hyp commented Sep 13, 2023

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
StringWithCString2 0.0 0.002 +200.0% 0.33x
UTF8Decode_InitDecoding 134.917 165.0 +22.3% 0.82x (?)
UTF8Decode_InitFromCustom_contiguous 137.071 164.923 +20.3% 0.83x (?)
UTF8Decode_InitFromCustom_noncontiguous 174.818 202.889 +16.1% 0.86x (?)
Array.removeAll.keepingCapacity.Int 0.097 0.11 +13.3% 0.88x (?)
 
Improvement OLD NEW DELTA RATIO
SequenceAlgosRange 2178.75 1742.727 -20.0% 1.25x (?)
CxxStringConversion.cxx.to.swift 146.5 128.0 -12.6% 1.14x (?)
StringComparison_ascii 208.091 187.0 -10.1% 1.11x (?)
Calculator 157.75 144.063 -8.7% 1.10x (?)
Chars2 3523.81 3231.25 -8.3% 1.09x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
BinaryFloatingPointConversionFromBinaryInteger.o 28860 29292 +1.5% 0.99x
COWArrayGuaranteedParameterOverhead.o 1314 1330 +1.2% 0.99x
InsertCharacter.o 4643 4691 +1.0% 0.99x

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 133.636 161.444 +20.8% 0.83x (?)
UTF8Decode_InitFromCustom_contiguous 133.545 160.929 +20.5% 0.83x (?)
UTF8Decode_InitFromCustom_noncontiguous 258.75 285.833 +10.5% 0.91x (?)
Set.subtracting.Empty.Box 19.594 21.333 +8.9% 0.92x (?)
CxxStringConversion.cxx.to.swift 142.4 154.8 +8.7% 0.92x (?)
Set.filter.Int50.28k 317.286 342.25 +7.9% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
SequenceAlgosRange 2614.444 1742.727 -33.3% 1.50x
FlattenListLoop 1622.0 1381.0 -14.9% 1.17x (?)
Set.isSuperset.Seq.Empty.Int 50.08 44.647 -10.8% 1.12x (?)
Calculator 157.833 141.077 -10.6% 1.12x (?)
UTF8Decode_InitDecoding_ascii 183.8 169.2 -7.9% 1.09x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
BinaryFloatingPointConversionFromBinaryInteger.o 28406 28094 -1.1% 1.01x

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 141.333 168.0 +18.9% 0.84x (?)
UTF8Decode_InitFromCustom_contiguous 145.25 169.4 +16.6% 0.86x (?)
CharacterRecognizer.ascii 127.786 139.0 +8.8% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
CxxStringConversion.cxx.to.swift 161.0 129.4 -19.6% 1.24x (?)

Code size: -swiftlibs

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 mini
  Model Identifier: Macmini8,1
  Processor Name: 6-Core Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 32 GB

@hyp
Copy link
Contributor Author

hyp commented Sep 13, 2023

@swift-ci please benchmark

@hyp
Copy link
Contributor Author

hyp commented Sep 14, 2023

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
ArrayAppendToGeneric 300.0 621.667 +107.2% 0.48x (?)
ArrayAppendGenericStructs 1380.0 1786.667 +29.5% 0.77x (?)
UTF8Decode_InitFromCustom_contiguous 133.824 161.333 +20.6% 0.83x (?)
UTF8Decode_InitDecoding 137.7 160.9 +16.8% 0.86x (?)
UTF8Decode_InitFromCustom_noncontiguous 173.1 201.111 +16.2% 0.86x (?)
 
Improvement OLD NEW DELTA RATIO
SequenceAlgosRange 2178.75 1742.727 -20.0% 1.25x (?)
Array.removeAll.keepingCapacity.Object 6.707 5.823 -13.2% 1.15x (?)
StringComparison_ascii 208.636 187.0 -10.4% 1.12x (?)
Chars2 3590.476 3235.714 -9.9% 1.11x (?)
Calculator 158.333 144.462 -8.8% 1.10x (?)
CxxStringConversion.cxx.to.swift 143.0 130.5 -8.7% 1.10x (?)
Data.hash.Medium 27.423 25.067 -8.6% 1.09x (?)
OpenClose 56.625 52.286 -7.7% 1.08x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
BinaryFloatingPointConversionFromBinaryInteger.o 28860 29292 +1.5% 0.99x
COWArrayGuaranteedParameterOverhead.o 1314 1330 +1.2% 0.99x
InsertCharacter.o 4643 4691 +1.0% 0.99x

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 136.167 165.091 +21.2% 0.82x (?)
UTF8Decode_InitFromCustom_contiguous 138.923 165.909 +19.4% 0.84x (?)
UTF8Decode_InitFromCustom_noncontiguous 258.714 285.286 +10.3% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
SequenceAlgosRange 2615.0 1742.727 -33.4% 1.50x
UTF8Decode_InitFromCustom_contiguous_ascii 201.5 173.0 -14.1% 1.16x (?)
Calculator 155.933 141.462 -9.3% 1.10x (?)
Set.isSuperset.Seq.Empty.Int 49.0 44.64 -8.9% 1.10x (?)
Set.isDisjoint.Seq.Int.Empty 49.0 44.758 -8.7% 1.09x (?)
CxxStringConversion.cxx.to.swift 181.5 169.0 -6.9% 1.07x (?)
DataAppendDataMediumToMedium 3189.231 2975.0 -6.7% 1.07x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
BinaryFloatingPointConversionFromBinaryInteger.o 28406 28094 -1.1% 1.01x

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 140.667 168.5 +19.8% 0.83x (?)
UTF8Decode_InitFromCustom_contiguous 143.5 171.545 +19.5% 0.84x (?)
CharacterRecognizer.ascii 127.786 137.692 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
CxxStringConversion.cxx.to.swift 137.5 125.0 -9.1% 1.10x (?)

Code size: -swiftlibs

Regression OLD NEW DELTA RATIO
libswiftSwiftPrivateLibcExtras.dylib 16384 32768 +100.0% 0.50x
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 mini
  Model Identifier: Macmini8,1
  Processor Name: 6-Core Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 32 GB

@hyp
Copy link
Contributor Author

hyp commented Sep 14, 2023

@swift-ci please test windows platform

@hyp
Copy link
Contributor Author

hyp commented Sep 14, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 15, 2023

@swift-ci please test

@hyp hyp marked this pull request as ready for review September 15, 2023 23:29
@hyp
Copy link
Contributor Author

hyp commented Sep 18, 2023

@swift-ci please test

2 similar comments
@hyp
Copy link
Contributor Author

hyp commented Sep 25, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 25, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 25, 2023

should be ready now.

@hyp
Copy link
Contributor Author

hyp commented Sep 25, 2023

@swift-ci please benchmark

@hyp
Copy link
Contributor Author

hyp commented Sep 25, 2023

@swift-ci please test source compatibility

The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687
@hyp
Copy link
Contributor Author

hyp commented Sep 26, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Sep 26, 2023

@swift-ci please test source compatibility

@hyp
Copy link
Contributor Author

hyp commented Sep 26, 2023

@swift-ci please benchmark

@hyp hyp merged commit 6ecea1a into swiftlang:main Sep 26, 2023
hjyamauchi added a commit to hjyamauchi/swift that referenced this pull request Nov 13, 2024
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687

Cherrypick commit 4858cb6
Cherrypick PR swiftlang#68481
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ IRGen LLVM IR generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant