Commit Graph

10994 Commits

Author SHA1 Message Date
Dario Rexin
021d524056 [IRGen] Pass component generic sig when emitting key path component f… (#64871)
* [IRGen] Pass component generic sig when emitting key path component for external property

rdar://101179225

When no generic environment was present, we passed nullptr, which is not correct when the property uses an external associated type, causing crashes in IRGen. In those cases, we have to pass the component generic sig instead.

* Fix test
2023-04-07 13:58:47 -07:00
Dario Rexin
4d1b1d7368 [IRGen] Prevent overflow in RecordField with large explosions (#64828)
rdar://99415586

Exploding very large types could cause an overflow, which in turn caused a crash later in IRGen.
Fixed by increasing width of the variables in question from 16 to 32 bit and adding an overflow check.
2023-04-07 13:55:02 -07:00
Dario Rexin
57dc5a6d42 [IRGen] Add flags to enable or disable generation of layout string value witnesses (#64819)
rdar://107477762
2023-04-07 13:45:52 -07:00
Saleem Abdulrasool
0301e03cc3 TDBGen: add a workaround for a workaround for async PWT
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (#64900).

Thanks to @DougGregor and @aschwaighofer for the discussion on this!
2023-04-06 09:01:55 -07:00
Slava Pestov
db058a4f9c Merge pull request #64753 from slavapestov/variadic-conformances
Fixes for conformances of variadic generic types
2023-04-06 08:18:22 -04:00
Slava Pestov
d3f0cbeea3 IRGen: Fix conformances of variadic generic types
Fixes rdar://107480494.
2023-04-05 23:42:16 -04:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Adrian Prantl
158772c2ab Rebase SILScope generation on top of ASTScope.
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
2023-04-04 15:20:11 -07:00
Slava Pestov
3d9a79e4b1 Merge pull request #64777 from slavapestov/sil-optimizer-variadic-generics
SIL optimizer fixes for variadic generics
2023-04-03 11:30:03 -04:00
Slava Pestov
7ad2365278 AST: Introduce PackType::unwrapSingletonPackExpansion() 2023-04-02 23:04:00 -04:00
Saleem Abdulrasool
c8f88175d8 IRGen: attribute correct linkage to Windows DSO handle
Partially address the incorrect handling for the `#dsohandle` on
Windows.

We were previously emitting a local definition for this external
constant, and worse yet, not marking the definition for COMDAT.  It is
unclear what definition would win ultimately (implementation defined),
as we had a definition as well as the linker synthesized value. We can
change the SIL linkage for this type to `DefaultForDeclaration` which
will give it `available_externally` and default visibility and storage
which is closer to what we desire.  However, because we do not track the
LLVM variables and apply heuristics for lowering the
`SILGlobalVariable`, we would attribute it with imported DLL Storage.
This would then cause us to fail at link time (amusingly enough link.exe
will report a LNK1000).  Special case the variable and track that we are
targeting a windows environment in the `UniversalLinkageInfo` so that we
do not special case this on other platforms.

This also has the nice side effect of allowing us to remove the special
case in the TBD handling.

Fixes: #64741
2023-04-02 10:08:16 -07:00
Richard Wei
eb8e984b97 [Macros] Private discriminators for outermost-private MacroExpansionDecl (#64813)
Add a private discriminator to the mangling of an outermost-private `MacroExpansionDecl` so that declaration macros in different files won't have colliding macro expansion buffer names.

rdar://107462515
2023-03-31 20:36:29 -07:00
Slava Pestov
8563229c4a IRGen: Fix binding element archetypes when we have concrete pack conformances 2023-03-31 22:18:09 -04:00
Allan Shortlidge
d140fbee9a IRGen: Skip lowering unavailable types nested in extensions.
Part of rdar://107425181
2023-03-31 09:36:42 -07:00
Allan Shortlidge
367dbd069d IRGen: Skip lowering unavailable opaque type descriptors.
Part of rdar://107425181
2023-03-31 09:36:42 -07:00
swift-ci
f8348be544 Merge pull request #64772 from DougGregor/type-reconstruction-diag-message
[Assertions] Provide the flag to dodge the "type reconstruction" assertions
2023-03-30 12:51:05 -07:00
Doug Gregor
cff79e632a [Assertions] Provide the flag to dodge the "type reconstruction" assertions.
When the compiler aborts due to a type reconstruction error, ask the
user to submit a bug report and provide the flag needed to disable
this check.
2023-03-30 10:09:00 -07:00
Egor Zhdan
00b327f1ed [cxx-interop] Do not try linking with swiftstd
This fixes an ld warning:
```
ld: warning: Could not find or use auto-linked library ‘swiftstd’
```

`swiftstd` was renamed to `swiftCxxStdlib`. We were still trying to link with `swiftstd` for some time to allow building with hosttools and to keep the CI green, however a new toolchain was released since the module was renamed, so this is no longer needed.

rdar://107412807
2023-03-30 11:43:50 +01:00
Arnold Schwaighofer
3f8b9e2ef2 Merge pull request #64638 from aschwaighofer/indirect_shared_async_fp
IRGen: Don't directly call async functions that have weak/linkonce_odr linkage
2023-03-29 06:56:32 -07:00
Slava Pestov
8a6bb30c4c IRGen: Heap-allocate metadata and witness table packs captured by escaping closures 2023-03-28 21:44:53 -04:00
Slava Pestov
cca91797ed IRGen: Hollow out NecessaryBindings
This removes the "optimization" where a function type, metatype or
tuple type was split up into structural components, because it seems
that in general we need this structural type metadata again.

Similarly, this no longer tries to split up dependent concrete
conformances and instead passes the witness table in the context.

This makes the context larger potentially, but it avoids calls to
metadata access functions and swift_getWitnessTable() every time the
closure is invoked.
2023-03-28 19:21:45 -04:00
Slava Pestov
5e69db0d52 IRGen: Start plumbing shapes through NecessaryBindings 2023-03-28 19:21:45 -04:00
Slava Pestov
a57ecb36ed IRGen: Clean up duplication in withOpaqueTypeGenericArgs() 2023-03-28 19:21:45 -04:00
Allan Shortlidge
9a1a2c3b9d Merge pull request #64644 from tshortli/strip-unavailable-code
Introduce `-unavailable-decl-optimization`
2023-03-28 08:53:48 -07:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
Allan Shortlidge
98b4e79d62 IRGen: Implement 'complete' unavailable decl optimization.
Part of rdar://106674022
2023-03-27 11:40:54 -07:00
Arnold Schwaighofer
b142815c3e IRGen: Don't directly call async functions that have weak/linkonce_odr linkage
The async function pointer context size and the async function implementiation are logically tied. Using a different async context pointer context size and async function implementation (from different translation units) is problematic.

rdar://106029807
2023-03-27 07:25:31 -07:00
Alex Lorenz
b5766fd215 [interop] do not assume we need to IRGen destructors of fields inside a record with an explicit destructor 2023-03-26 12:24:57 -07:00
Slava Pestov
8864251dc0 Merge pull request #64597 from slavapestov/fix-indexing-into-on-heap-packs
IRGen: Fix indexing into on-heap packs from emitTypeMetadataPackElementRef()
2023-03-24 19:26:55 -04:00
Slava Pestov
fd6ff412c5 IRGen: Fix indexing into on-heap packs from emitTypeMetadataPackElementRef() 2023-03-24 13:05:37 -04:00
Dario Rexin
bdbab35453 [IRGen] Use ConditionalDominanceScope in AbstractMetadataAccessor::emit (#64585)
* [IRGen] Use ConditionalDominanceScope in AbstractMetadataAccessor::emit

rdar://103179745

Under certain conditions the missing dominance scope caused a cached witness table ref to be used in a block that it was not available in.

* Fix target in test
2023-03-23 18:34:27 -07:00
Slava Pestov
60ffd84e19 Merge pull request #64561 from slavapestov/constrained-existential-fixes
Fixes for constrained existential types
2023-03-23 19:51:36 -04:00
Dario Rexin
a2d2fef36e [IRGen] Remove dead code from LayoutStringBuilder (#64540) 2023-03-23 12:49:37 -07:00
Slava Pestov
5452a8955a IRGen: Fix createExistentialTypeInfo() for compositions involving ParameterizedProtocolType 2023-03-23 00:53:13 -04:00
Slava Pestov
ac15cdf6ea Merge pull request #64527 from slavapestov/protocol-conformance-cleanup
AST: Rename ProtocolConformance::getSubstitutions() to getSubstitutionMap() and remove ModuleDecl parameter
2023-03-22 20:30:25 -04:00
Slava Pestov
aee9da5f8c Merge pull request #64489 from slavapestov/fix-pack-archetype-folding-irgen
IRGen: Various minor fixes
2023-03-21 22:17:39 -04:00
Slava Pestov
a355c38a34 AST: Rename ProtocolConformance::getSubstitutions() to getSubstitutionMap() and remove ModuleDecl parameter 2023-03-21 16:16:34 -04:00
Slava Pestov
b71cf4c0e7 IRGen: Bitcast the storage address when emitting a tuple_pack_element_addr 2023-03-21 14:59:22 -04:00
Slava Pestov
a1aff7b0a6 IRGen: Handle PackArchetypeType in getExemplarArchetype() 2023-03-21 14:59:22 -04:00
Slava Pestov
837075c9d5 IRGen: Use ConditionalDominanceScope in IRGen-generated control flow for pack iteration 2023-03-21 14:59:22 -04:00
Alexis Laferrière
201c4b6205 Merge pull request #64486 from xymus/import-filter-refactor
[Sema] Intro common sets of import filters to simplify calls to `getImportedModules`
2023-03-21 11:10:50 -07:00
Alex Lorenz
b11b897e02 Merge pull request #64493 from hyp/eng/destructor-delete-irgen
[interop] ensure IRGen reaches code referenced through destructor inv…
2023-03-21 06:34:47 -07:00
Alex Lorenz
7320cd877c [interop] ensure IRGen reaches code referenced through destructor invoked using the 'delete' statement in C++ 2023-03-20 17:25:29 -07:00
zoecarver
d283aa050f [cxx-interop] Destroy things 🤷 2023-03-20 15:47:23 -07:00
zoecarver
1e43ba0514 [cxx-interp] Don't select the move contstructor if it hasn't been defined. 2023-03-20 15:47:23 -07:00
zoecarver
a10bf21fcd [cxx-interop] 'Support' C++ move only types; fix a few bugs in the object model.
The implemented object model should now match the object model outlined in the Forward Vision document.
2023-03-20 15:47:22 -07:00
Michael Gottesman
4a309575d7 [sil] Rename [moved] flag on debug_value/alloc_stack to moveable_value_debuginfo.
This is in preparation for wiring up debug info support for noncopyable
values. Originally this flag name made sense since it was set when we performed
consume operator checking. Now I am going to use it for noncopyable types as
well. I think the new name uses_moveable_value_debuginfo actually describes what
the flag is supposed to do, tell IRGen that the value may be moved since it
needs to use moveable value debug info emission.
2023-03-19 15:38:42 -07:00
Konrad `ktoso` Malawski
e0877594da [Concurrency] Custom executors with move-only Job (#63569) 2023-03-18 14:02:43 +09:00
swift-ci
8b2ecdbb4d Merge pull request #64467 from adrian-prantl/use-after-free-name
Fix a use-after-free in IRGenSIL.
2023-03-17 21:23:11 -07:00
Adrian Prantl
0fa64b53c1 Fix a use-after-free in IRGenSIL.
A StringRef of the name is used as key into a DenseMap.
2023-03-17 17:23:08 -07:00