Commit Graph

2441 Commits

Author SHA1 Message Date
swift_jenkins
d5eb44364c Merge remote-tracking branch 'origin/master' into master-next 2020-08-25 20:51:29 -07:00
swift-ci
148ba9d66d Merge pull request #33636 from nate-chandler/move-flag-to-SILExtInfo 2020-08-25 20:31:10 -07:00
Joe Groff
6d6165a9db SILOptimizer: Recognize globalinit once functions using an attribute instead of symbol name matching 2020-08-25 17:43:27 -07:00
Joe Groff
d82a767e13 SIL: Add a SILFunction::Purpose for global init once functions 2020-08-25 17:06:09 -07:00
Nate Chandler
94b5f76654 Revert "[SIL] Add SILFunctionType flag for async."
This reverts commit 9b8828848d.
2020-08-25 13:37:26 -07:00
swift_jenkins
adf903d271 Merge remote-tracking branch 'origin/master' into master-next 2020-08-24 20:52:27 -07:00
Slava Pestov
995eb66aa7 AST: Rename SpecializeAttr::getSpecializedSgnature() 2020-08-24 19:16:36 -04:00
Slava Pestov
b0208a134f AST: Move getSugaredType() from GenericEnvironment to GenericSignature
None of this actually involves archetypes, so it can just be an
operation on the GenericSignature itself.
2020-08-24 19:16:36 -04:00
Dan Zheng
48c048f34d [AutoDiff] Fix PullbackCloner tangent value category mismatch issues.
Fix SIL pullback function type calculation: remap original `unowned` results to
the correct pullback parameter convention depending on the `TangentVector` type
lowering.

Make `PullbackCloner` visitors for the following instructions check and handle
tangent value categories: `struct`, `struct_extract`, `tuple`, `destructure_tuple`.

Add differentiation tests for `Optional` struct and class stored properties,
exercising the instruction visitors above.

Resolves SR-13430.
2020-08-24 10:39:23 -07:00
swift_jenkins
96c2015e0c Merge remote-tracking branch 'origin/master' into master-next 2020-08-19 15:10:01 -07:00
Nate Chandler
9b8828848d [SIL] Add SILFunctionType flag for async. 2020-08-19 11:29:58 -07:00
Nate Chandler
4145ef7a12 Revert "[SIL] Add flag to SILFunction to indicate async."
This reverts commit 6b28c2fe89.
2020-08-19 11:29:16 -07:00
Vedant Kumar
cfd38c42a1 [Profiler] Assign counter to IfStmt condition
Push a region to cover any expressions within an IfStmt condition.

rdar://67280997
2020-08-18 14:05:24 -07:00
Alex Efremov
a434ee8598 [AutoDiff] Fix PullbackCloner tangent value category mismatch crash (#33512)
Fix semantic member getter pullback generation crash due to tangent value category mismatch.

Resolves SR-13411.
2020-08-17 18:31:12 -07:00
Slava Pestov
61104cf9c6 SIL: Clean up AbstractionPattern::getLayoutConstraint() 2020-08-15 03:09:12 -04:00
Slava Pestov
253c0ac692 SIL: Generalize some explicit requiresClass() checks to use layout constraints 2020-08-15 03:09:12 -04:00
Slava Pestov
b07a17efed Merge branch 'master' into objc-protocols-have-a-layout-constraint 2020-08-14 18:02:01 -04:00
David Zarzycki
1e940c2c7e [NFC] Fix -Wsuggest-override warnings
LLVM, as of 77e0e9e17daf0865620abcd41f692ab0642367c4, now builds with
-Wsuggest-override. Let's clean up the swift sources rather than disable
the warning locally.
2020-08-13 16:17:46 -04:00
Varun Gandhi
90f5730026 [NFC] Refactor getNativeSILFunctionType to use a lambda. (#33440) 2020-08-13 12:43:34 -07:00
Slava Pestov
92bc89b78f GSB: Add an inferred AnyObject constraint to @objc protocol requirement signatures
This simplifies GenericSignatureImpl::requiresClass(), which no longer
has to look through the conformances of the equivalence class.
2020-08-13 00:23:47 -04:00
Slava Pestov
198519c75f SIL: Fix TypeExpansionContext() constructor to get the right DeclContext from a SILFunction
Using the SILFunction's DeclContext produces the wrong result for
the @main function, because it returns the ModuleDecl even in
a non-WMO build.

Instead, let's always just use SILModule::getAssociatedContext(),
which also simplifies the code here.

Fixes <rdar://problem/66791399>.
2020-08-12 15:24:21 -04:00
Slava Pestov
bfb1e91b17 Merge pull request #33419 from slavapestov/incorrect-generic-signature-in-type-lowering
SIL: Don't canonicalize struct field and enum element types against the wrong signature
2020-08-12 14:52:23 -04:00
Dan Zheng
bf2ef3934d [AutoDiff] NFC: make LinearFunctionExtractInst inherit UnaryInstructionBase. (#33418)
Remove ad-hoc operand list and operand getters.
2020-08-11 22:20:58 -07:00
Slava Pestov
5ad4fa8b07 SIL: Don't canonicalize struct field and enum element types against the wrong signature
The replacement types of the substitution map are either going
to be contextual types, or interface types using some generic
signature. There is no requirement that this generic signature
is the generic signature of the type declaration itself.

By using the generic signature of the type declaration, we
could incorrectly canonicalize generic parameters to concrete
types if the type itself was defined in a constrained extension,
as in the test case here.

Fixes <rdar://problem/65272763>.
2020-08-11 22:54:19 -04:00
Erik Eckstein
755f6aa2e4 AST, SIL: Remove UTF16 encoding from StringLiteralExpr and StringLiteralInst
The UTF16 encoding is not used (anymore). I think it became obsolete with the switch to the UTF8 String representation.
2020-08-06 19:09:09 +02:00
Nate Chandler
6b28c2fe89 [SIL] Add flag to SILFunction to indicate async.
Includes boilerplate to parse and print as well as to serialize and
deserialize.
2020-08-05 16:22:48 -07:00
Dan Zheng
849c63634c [AutoDiff] Fix differentiation for non-wrt inout parameters. (#33304)
Fix SIL differential function type calculation to handle non-wrt `inout`
parameters.

Patch `SILFunctionType::getDifferentiabilityResultIndices` to prevent returning
empty result indices for `@differentiable` function types with no formal results
where all `inout` parameters are `@noDerivative`. TF-1305 tracks a robust fix.

Resolves SR-13305.

Exposes TF-1305: parameter/result differentiability hole for `inout` parameters.
2020-08-05 09:34:06 -07:00
swift-ci
b2d2cf05b6 Merge pull request #33252 from zoecarver/cxx/rename-is-cxx-non-trivial 2020-08-04 11:23:31 -07:00
zoecarver
6e4e478047 [NFC] [cxx-interop] Rename IsCxxNotTriviallyCopyable -> IsCxxNonTrivial.
`IsCxxNonTrivial` is set for a variety or reasons, for example, it's set
when the struct contains bitfields, has a custom destructor, or a custom
copy constructor. The name `IsCxxNotTriviallyCopyable` only implies the
latter.
2020-08-04 08:45:15 -07:00
Michael Gottesman
12ffdd3765 Merge pull request #32885 from gottesmm/pr-9162e369eb8d716656842a8502a098f9c43a8423
[ownership] Update LowerAggregateInstrs for Ownership
2020-08-03 16:41:28 -07:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Michael Gottesman
ba46bc44d2 [lower-agg-instrs] Update for ossa.
For now I am trying out /not/ expanding when ownership is enabled. I still fixed
the problems in it though. I also put in a force expand everything pass to make
sure that in ossa we can still successfully go down this code path if we want
to.

The reason why I think this is the right thing to do is that the original reason
why lower aggregate instrs was written was to help the low level arc optimizer
(which only runs on non-ossa code). To the high level arc optimizer this is just
noise and will keep the IR simpler.

Another thing to note is that I updated the code so it should work in both ossa
and non-ossa. In order to not perturb the code too much, I had to add a small
optimization to TypeLowering where when ownership is disabled, we do not reform
aggregates when copying. Instead, we just return the passed in value. This makes
the pass the same when optimizing in both modes.
2020-08-03 10:42:34 -07:00
Varun Gandhi
270b5dc7a6 Merge pull request #33118 from varungandhi-apple/vg-builder-pattern-ExtInfo
Refactor ExtInfo to use the builder pattern for construction.
2020-08-03 10:30:05 -07:00
Michael Gottesman
c6ebea4b6b [sil] Define emitLowered{Load,Store} in type lowering and expose emitLowered{Copy,Load,Destroy,Store}Value on SILBuilder via emit*Operation methods.
This is in preparation for fixing lower aggregate instrs. These helpers allow
for one to pass down a type expansion qualifier for emitLowered{Load,Store} to
use when emitting lowered copy, destroys as part of emitting aggregate
operations in non-ossa like load [copy].
2020-08-03 10:19:08 -07:00
Erik Eckstein
ba7ecfb2c4 SIL: small refactoring of swift::findInitializer
NFC
2020-08-03 12:01:29 +02:00
Varun Gandhi
29188e3fe7 [AST] Update equality for ExtInfo to take Clang types into account.
In the future, we will remove the UseClangFunctionTypes language option, but we
temporarily need the scaffolding for equality checks to be consistent in all
places.
2020-07-31 13:55:55 -07:00
Varun Gandhi
f219e58ada [NFC] Refactor ExtInfo to use a builder-pattern based API.
Since the two ExtInfos share a common ClangTypeInfo, and C++ doesn't let us
forward declare nested classes, we need to hoist out AnyFunctionType::ExtInfo
and SILFunctionType::ExtInfo to the top-level.

We also add some convenience APIs on (AST|SIL)ExtInfo for frequently used
withXYZ methods. Note that all non-default construction still goes through the
builder's build() method.

We do not add any checks for invariants here; those will be added later.
2020-07-31 13:55:55 -07:00
Slava Pestov
0ef12ec8aa SIL: Replace some calls to getDeclaredType() with getDeclaredInterfaceType() 2020-07-31 13:39:02 -04:00
Joe Groff
cc358ba8fb PruneVTables: Keep SILModule's vtable lookup table in sync with updates.
And add a verifier check to ensure the cache remains synced.
2020-07-23 20:40:49 -07:00
Zoe Carver
a8f02db1f4 [Gardening] [NFC] Re-order headers in SILDeclRef.cpp with clang-format. (#32969) 2020-07-21 14:07:28 -07:00
Josh Learn
768a404c0c Merge pull request #32911 from guitard0g/oslog_profiling
[Constant Evaluator] Skip code-coverage instrumentation during constant evaluation
2020-07-20 15:29:01 -04:00
Josh Learn
7cbc21b60a Allow constant interpreter to skip builtin instructions from profiling instrumentation 2020-07-17 13:30:30 -04:00
Holly Borla
61cb9a5f4f Merge pull request #32866 from hborla/property-wrapper-autoclosure
[Property Wrappers] Use autoclosure information from CSApply to compute `VarDecl::getPropertyWrapperInitValueInterfaceType`
2020-07-17 09:16:05 -07:00
Suyash Srijan
88cad6ba17 [SIL] Look through optionals in an unowned type's referent type during type classification (#32927) 2020-07-17 14:17:34 +01:00
Holly Borla
28a817b271 [Property Wrappers] Treat default wrapped values that are noescape
autoclosures the same way we treat default arguments that are
noescape autoclosures.
2020-07-15 10:02:35 -07:00
Brent Royal-Gordon
0e569f5d9e Add support for #fileID
This temporarily breaks -enable-experimental-concise-pound-file.

fixup adding #fileID
2020-07-13 14:05:13 -07:00
Brent Royal-Gordon
7f91145efc [NFC] Rename “MagicFileString” -> “FileID”
Doing this NFC renaming first helps clarify the functional changes to come.
2020-07-13 14:05:13 -07:00
Michael Gottesman
adec7551c1 Merge pull request #32756 from gottesmm/eager_specializer_fix
[ownership] Fix the eager specializer for ownership
2020-07-10 12:43:37 -07:00
zoecarver
13632d4c9c [cxx-interop] Mark types with a destructor a non-trivial.
Any C++ type that isn't trivially copyable is now also not a trivial type. This will preserve the destructor (among other things).
2020-07-10 08:51:30 -07:00
Michael Gottesman
ac3109a21d [eager-specializer] Fix for ownership and add a bunch of missing code coverage for ossa.
Specifically, we were missing a bunch of coverage around specializing guaranteed
parameters and non-trivial values in general.
2020-07-09 21:46:19 -07:00