Commit Graph

7628 Commits

Author SHA1 Message Date
Slava Pestov
e01822ca20 Add regression test for rdar://problem/108319167 2023-07-03 18:41:44 -04:00
Arnold Schwaighofer
a56b148747 Fix validation-test/IRGen tests 2023-06-23 06:57:38 -07:00
Arnold Schwaighofer
90c7193651 More IRGen test to move over 2023-06-14 10:49:50 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Slava Pestov
7cc8063889 SIL: Forgot to pass SubstFlags::PreservePackExpansionLevel in one place 2023-06-07 15:17:54 -04:00
Alastair Houghton
d67354473f Merge pull request #66335 from al45tair/eng/PR-110261712
[Backtracing][Linux] Add support for Linux in the _Backtracing module.
2023-06-07 13:48:46 +01:00
Alastair Houghton
a890ec2c0f [Backtracing][Linux][Tests] Fix verify_all_overlays test.
The `_Backtracing` module has a number of private implementation only
imports that aren't used outside of the module and that don't require
any additional libraries (hence they aren't relevant to the outside
world).  `verify_all_overlays.py` needs to know about these when it
does its test, because it loadas the module as the main module, which
results in implementation only imports being required instead of
ignored.

rdar://110261712
2023-06-07 09:03:50 +01:00
swift-ci
c74fd074c6 Merge pull request #64280 from hamishknight/platypus
[CS] Allow ExprPatterns to be type-checked in the solver
2023-06-06 20:21:45 -07:00
Hamish Knight
7a137d6756 [CS] Allow ExprPatterns to be type-checked in the solver
Previously we would wait until CSApply, which
would trigger their type-checking in
`coercePatternToType`. This caused a number of
bugs, and hampered solver-based completion, which
does not run CSApply. Instead, form a conjunction
of all the ExprPatterns present, which preserves
some of the previous isolation behavior (though
does not provide complete isolation).

We can then modify `coercePatternToType` to accept
a closure, which allows the solver to take over
rewriting the ExprPatterns it has already solved.

This then sets the stage for the complete removal
of `coercePatternToType`, and doing all pattern
type-checking in the solver.
2023-06-07 00:35:01 +01:00
swift-ci
4ef135cc10 Merge pull request #66201 from nate-chandler/dealloc-on-stack-packs
[IRGen] Dealloc on-stack metadata/wtable packs on the dominance frontier.
2023-06-05 13:30:18 -07:00
Eric Miotto
44a40979e5 tsan-ignores-arc-locks.swift: post process test binary on Darwin (#66308)
This allows the `DYLD_LIBRARY_PATH` override to work as expected and
avoid crashes when running.

Addresses rdar://108188149
2023-06-05 12:31:11 -07:00
Nate Chandler
d1ec1e6693 [IRGen] Dealloc metadata packs on dom frontier.
Deallocate dynamic allocas done for metadata/wtable packs.  These
stackrestore calls are inserted on the dominance frontier and then stack
nesting is fixed up.  That was achieved as follows:

Added a new IRGen pass PackMetadataMarkerInserter; it
- determines if there are any instructions which might allocate on-stack
  pack metadata
- if there aren't, no changes are made
- if there are, alloc_pack_metadata just before instructions that could
  allocate pack metadata on the stack and dealloc_pack_metadata on the
  dominance frontier of those instructions
- fixup stack nesting

During IRGen, the allocations done for metadata/wtable packs are
recorded and IRGenSILFunction associates them with the instruction that
lowered.  It must be the instruction after some alloc_pack_metadata
instruction.  Then, when visiting the dealloc_pack_metadata instructions
corresponding to that alloc_pack_metadata, deallocate those packs.
2023-06-05 08:11:28 -07:00
Nate Chandler
0b5a233d73 [GenPack] Always heapify metadata packs.
Until the optimization to leave packs on-stack is in place.  Even then,
we'll want to keep this as a fallback.

rdar://110123679
2023-06-03 07:30:09 -07:00
Nate Cook
fb52491dcd Fix String capacity growth tests for watchOS
watchOS devices can have different allocation characteristics
from other devices. This modifies the string capacity growth
tests to be more flexible about measuring the growth in
capacity, specifically when more is allocated than requested.
2023-06-01 12:11:52 -05:00
Erik Eckstein
92fab06d96 IRGen: fix generation of static enums with function payloads
fixes a compiler crash

rdar://109999583
2023-05-31 14:22:48 +02:00
Erik Eckstein
fe367e8013 Optimizer/IRGen: allow enums in static initializers of globals
The main change here is in IRGen which needs to be able to emit constant enum values.
Use `emitValueInjection` to create the enum constant.
Usually this method creates code in the current function.
But if all arguments to the enum are constant, the builder never has to emit an instruction.
Instead it can constant fold everything and just returns the final constant.

Also, create statically initialized let-globals as constant global (`constant` instead of `global`).
2023-05-25 16:28:41 +02:00
Eric Miotto
1aaaef91cc Relax FileCheck directives for skip_clean_llbuild.test (#66062)
This is needed short term to allow the test to pass when running on
Python 3.11 and later and avoid errors like

```
<stdin>:44:1: note: non-matching line after previous match is here
<string>:1: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
^
```

Long term we want to replace uses of the obsolete `pipes.quotes`
function with `shlex.quotes`.

Addresses rdar://109664710
2023-05-24 08:18:10 -07:00
nate-chandler
efe762de0b Merge pull request #66014 from nate-chandler/rdar109540863
[IRGen] Cast dynamic alloca to appropriate type.
2023-05-19 07:00:08 -07:00
Nate Chandler
4b46622e49 [IRGen] Cast dynamic alloca to appropriate type.
Fix the type of the `alloca` created by `GenPack`'s for type metadata
and witness tables by fixing its callee, `emitDynamicAlloca` to always
return a `StackAddress` whose `Address`' type is the one specified by
the caller.

rdar://109540863
2023-05-18 20:51:54 -07:00
Nate Cook
23c19333df [stdlib] Fix String.reserveCapacity underallocation (#65902)
When called on a string that is not uniquely referenced,
`String.reserveCapacity(_:)` ignores the current capacity, using
the passed-in capacity for the size of its new storage. This can
result in an underallocation and write past the end of the new
buffer.

This fix changes the new size calculation to use the current UTF-8
count as the minimum. Non-native or non-unique strings
now allocate the requested capacity (or space enough for the
current contents, if that's larger than what's requested).

rdar://109275875
Fixes #53483
2023-05-17 12:11:23 -05:00
Alex Hoppen
1eadffcc00 [CodeCompletion] Don’t crash when completing in a parameter position that only constraints one of two primary associated protocol types
When completing, we call `getExistentialType` on the contextual type to get a nice and concise description of the contextual parameter’s type that doesn’t contain archetypes and which we can also serialize into a USR so we are able to calculate type relations for code completion results from the code completion cache.

When completing in a position that has a contextual type which only constrains one of two primary associated protocol types, this fails because `getExistentialType` (which calls `getDependentUpperBounds`) tries to form a `ParameterizedProtocolType`, which fails since not all primary associated types have been constrained.

AFAICT the fix here is to just fall back to the default behavior of returning the plain protocol type instead of `abort`ing.

rdar://108835466
2023-05-10 16:38:30 -07:00
Alex Hoppen
50249551a7 [CodeCompletion] Fix another test that was causing an assertion failure in the stress tester 2023-05-09 17:19:31 -07:00
Hamish Knight
c0e013907e [AST] Allocate PlaceholderTypes in the correct arena
We shouldn't be allocating placeholders for type
variables in the permanent arena, and we should be
caching them such that equality works.

To achieve this, we need to introduce a new
"solver allocated" type property. This is required
because we don't want to mark placeholder types
with type variable originators as themselves having
type variables, as it's not part of their structural
type. Also update ErrorType to use this bit, though
I don't believe we currently create ErrorTypes
with type variable originators.
2023-05-06 20:42:02 +01:00
swift-ci
f31d7cdab4 Merge pull request #65704 from hamishknight/revert-placeholder
Revert "[AST] Allocate PlaceholderTypes in the correct arena"
2023-05-05 14:12:13 -07:00
Hamish Knight
6ae5f1c535 [test] Update test for placeholder revert 2023-05-05 19:43:10 +01:00
Daniel Rodríguez Troitiño
cfb76cc780 [test] Allow customizing swift-ide-test invocations during tests. (#65684)
In some Linux setups, one might need to provide extra arguments to setup
the environment for invocations done during the tests. The Swift
frontend and driver already had a mechanism to provide those arguments
in the shape of `SWIFT_FRONTEND_TEST_OPTIONS` and
`SWIFT_DRIVER_TEST_OPTIONS`. `swift-ide-test` was sadly missing the same
feature, which meant that many tests might fail or tests against the
incorrect environment.

The changes implement the `SWIFT_IDE_TEST_TEST_OPTIONS` mechanism to
cover that gap.
2023-05-05 09:35:45 -07:00
Allan Shortlidge
b12537faaf Merge pull request #65667 from tshortli/swiftinterface-missing-conformance-req-assert
Sema: Fix incorrect assert in TypeCheckProtocol.cpp.
2023-05-05 09:06:30 -07:00
Allan Shortlidge
ba422f96be Sema: Fix incorrect assert in TypeCheckProtocol.cpp.
We can't assume that we will always find a viable witness for a protocol
requirement when typechecking a `.swiftinterface` file. The assert that assumed
there would be a match could fail when building a broken interface or building
a valid interface with a broken SDK, causing crashes instead of emitting
diagnostics.

Resolves rdar://108688535
2023-05-04 16:24:31 -07:00
Hamish Knight
3087afc1f8 Merge pull request #65651 from hamishknight/placeholder
Resolves https://github.com/apple/swift/issues/65650
2023-05-04 19:50:12 +01:00
nate-chandler
74cbe264ca Merge pull request #65636 from nate-chandler/rdar108614878
[IRGen] Check for nil in final class cast opt.
2023-05-04 07:08:37 -07:00
Hamish Knight
b07f7b336e [CS] Improve handling of holes for Named/AnyPatterns
Rather than eagerly binding them to holes if the
sequence element type ends up being Any, let's
record the CollectionElementContextualMismatch fix,
and then if the patterns end up becoming holes,
skip penalizing them if we know the fix was
recorded. This avoids prematurely turning type
variables for ExprPatterns into holes, which
should be able to get better bindings from the
expression provided. Also this means we'll apply
the logic to non-Any sequence types, which
previously we would give a confusing diagnostic
to.
2023-05-04 14:53:58 +01:00
Nate Chandler
70cfa6a05c [IRGen] Check for nil in final class cast opt.
As an optimization, there is a fast-cast to non-final classes that just
compares isa pointers.  If the source of the cast is an Optional<class>,
though, it's not allowed to "directly compare the isa-pointer"; because
the source might be Optional.none, i.e. null.

Add a check for nil when emitting the fast class cast.

rdar://108614878
2023-05-03 18:39:08 -07:00
Arnold Schwaighofer
441b151ba3 Merge pull request #65549 from aschwaighofer/guard_using_clang_for_objc_protocols_by_deploy_target_2nd
IRGen: Only use clang protocol emission on newer deployment targets
2023-05-02 06:47:15 -07:00
swift-ci
7f60847231 Merge pull request #65548 from tbkka/tbkka-32bit-MPE-test
Fix this on 32 bit targets
2023-05-01 17:56:02 -07:00
Arnold Schwaighofer
086bc944f0 IRGen: Only use clang protocol emission on newer deployment targets
We started using clang to emit the _OBJC_PROTOCOL_ definition.

But we would use a different name for the proto_list definition than clang.

"OBJC_LABEL_PROTOCOL$" (objc)
|--> OBJC_PROTOCOL
"\01l_OBJC_LABEL_PROTOCOL$_" (swift)
|--> OBJC_PROTOCOL

If an Objective C object also emitted the same protocol definition you could
end up in a situation where both clang's and swift's proto_list definitions
point to the same protocol definition.

Older linkers don't like that.

rdar://108505376
2023-05-01 13:49:17 -07:00
Tim Kientzle
3f70b051a3 Fix this on 32 bit targets 2023-05-01 12:03:26 -07:00
Arnold Schwaighofer
f403e55a1d Revert "Merge pull request #65516 from aschwaighofer/guard_using_clang_for_objc_protocols_by_deploy_target"
This reverts commit 1a7f342a4e, reversing
changes made to 404b925d8b.
2023-05-01 07:43:56 -07:00
Arnold Schwaighofer
1a7f342a4e Merge pull request #65516 from aschwaighofer/guard_using_clang_for_objc_protocols_by_deploy_target
IRGen: only use clang protocol emission on newer deployment targets
2023-05-01 06:50:46 -07:00
Pavel Yaskevich
366213d90c Merge pull request #65479 from xedin/rdar-108534555
[CSDiagnostics] Teach `diagnoseConflictingGenericArguments` about holes
2023-04-28 17:18:25 -07:00
Arnold Schwaighofer
4416cb3f9b IRGen: only use clang protocol emission on newer deployment targets
Older linkers seemed to have a problem with clang emitted definitions.

rdar://108505376
2023-04-28 15:10:47 -07:00
Pavel Yaskevich
0b7aeed4b8 [CSDiagnostics] Teach diagnoseConflictingGenericArguments about holes
Only fully resolved substitutions are eligible to be considered
as conflicting, if holes are involved in any position that automatically
disqualifies a generic parameter.

Resolves: rdar://108534555
Resolves: https://github.com/apple/swift/issues/63450
2023-04-27 14:58:26 -07:00
Karoy Lorentey
b82ce9c3be [stdlib] Adopt _pointerBitWidth conditional 2023-04-27 13:33:24 -07:00
Julian Lettner
0ce8bfaaec [Sanitizers] Remove obsolete LIT substitution (#65420)
Co-authored-by: Julian Lettner <julian.lettner@apple.com>
2023-04-27 10:41:10 -07:00
Tim Kientzle
060d81f653 Merge pull request #64852 from tbkka/tbkka-RemoteMirror-MPE-zero-sized-plus-generics
[RemoteMirror] Fix handling of generic  and zero-sized cases in MPEs
2023-04-27 08:19:01 -07:00
Slava Pestov
dd0531e890 Merge pull request #65400 from slavapestov/generic-param-shadowing
Sema: Ban shadowing generic parameters from outer scopes
2023-04-26 12:08:51 -04:00
Tim Kientzle
5d67b814f5 Fix case calculation for SPE with zero-sized payload 2023-04-25 15:00:51 -07:00
Slava Pestov
290701cb4d Sema: Ban shadowing generic parameters from outer scopes
Code like that is usually indicative of programmer error, and does not
round-trip through module interface files since there is no source
syntax to refer to an outer generic parameter.

For source compatibility this is a warning, but becomes an error with
-swift-version 6.

Fixes rdar://problem/108385980 and https://github.com/apple/swift/issues/62767.
2023-04-25 17:41:23 -04:00
Tim Kientzle
8da561c8cb More tests! 2023-04-24 16:42:08 -07:00
Pavel Yaskevich
d6019ac466 Merge pull request #65366 from xedin/issue-65360
[CSSolver] Fix a crash in diagnostics related to pattern matching
2023-04-24 16:27:25 -07:00
Pavel Yaskevich
20d7642ca4 [CSGen] Allow expression pattern types to be holes 2023-04-24 10:02:00 -07:00