Commit Graph

394 Commits

Author SHA1 Message Date
Artem Chikin
281f84da0f [Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift 2025-03-28 10:30:07 -07:00
Nate Chandler
5eacbfd9d9 [DefaultOverrides] Mangling. 2025-03-25 07:22:14 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Holly Borla
be670da373 Merge pull request #79980 from hborla/closure-body-macro
[Macros] Implement support for function body macros on closures.
2025-03-21 06:19:36 -07:00
Amritpan Kaur
555a486cda [Mangler] Add new mangling schemes. 2025-03-19 10:54:06 -07:00
Holly Borla
31d4f661fc [Macros] Support function body macros on closures. 2025-03-18 20:50:47 -07:00
Konrad `ktoso` Malawski
8c4dea9802 Revert "[concurrency] Add support for HopToMainActorIfNeededThunk." (#79938)
* Revert "[concurrency] Add support for HopToMainActorIfNeededThunk."

This reverts commit 0e0665bfbd.

* remove some last bits of 0e0665b
2025-03-13 06:48:03 +09:00
Nate Chandler
a50a3f022b [CoroutineAccessors] Mangling.
Change the suffix to Twc and demangle.
2025-03-07 11:40:38 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Pavel Yaskevich
1067ead82c [Mangling] Mangle presence of @execution(caller) in a function type
If `@execution(caller)` attribute is present on a function type,
mark its presence in the mangling with `YC` suffix.
2025-02-19 16:48:41 -08:00
Michael Gottesman
cb2d7560a4 [rbi] Fix demangling of sending results.
The issue here is that the demangler (since we have a postfix mangling) parses
parameters/results/etc and then uses earlier postfix type arguments to attach
the relevant types to the parameters/results/etc. Since the flag for a sending
result was placed in between the parameters and results, we get an off by one
error.

Rather than fix that specific issue by introducing an offset for the off by one
error, I used the fact that the impl-function part of the mangling is not ABI
and can be modified to move the bit used to signify a sending result to before
the parameters so the whole problem is avoided.

I also while I was doing this looked through the sending result mangling for any
further issues and fixed them as I found them.

rdar://141962865
2025-01-14 15:38:02 -08:00
John McCall
fa932e736c Fix the demangling of sending result types when combined with isolation
Fixes the immediate problem, but the presence of demangling code in the
runtime means that we'll need a follow-up to fix the compiler so that it
doesn't try to use the demangler to materialize metadata for function types
that have both isolation and a sending result.

rdar://142443925
2025-01-10 21:11:45 -05:00
Kuba Mracek
9c77074cac [Mangling] Establish a new mangling prefix for Embedded Swift: $e 2024-12-02 15:01:24 -08:00
Mike Ash
4a5dc2a6a9 [Demangler] Accept overly short type names if they are NUL terminated
swift_getTypeByMangledNameInContext takes a pointer and a length, but some programs pass a pointer to a NUL-terminated C string and an excessive length, implicitly relying on the terminator to end the string early. This worked previously, but commit 7fe2befd31 made the demangler more strict about bad data. This changes the demangler to successfully parse a name by terminating the name string at a 0 byte encountered where it expects to find an operator. All other cases of bad data continue to be rejected.

rdar://137430048
2024-11-04 11:21:54 -05:00
Allan Shortlidge
12d72bee73 Merge pull request #77275 from tshortli/rebranch-warnings
Gardening: Address some new warnings
2024-10-29 20:17:30 -07:00
Allan Shortlidge
2de8e5afc2 Gardening: Address -Wunused-but-set-variable warnings. 2024-10-29 15:52:53 -07:00
Alejandro Alonso
79689be55f Change integer type mangling
Fix negative mangling
2024-10-29 09:52:22 -07:00
Erik Eckstein
8565c28ce1 demangler: correctly handle function attributes when there is an unmangled suffix 2024-10-24 08:22:00 +02:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Michael Gottesman
0e0665bfbd [concurrency] Add support for HopToMainActorIfNeededThunk.
It is behind the experimental flag GenerateForceToMainActorThunks.
2024-10-17 13:31:39 -07:00
Michael Gottesman
f0f5ad54fd [thunk-lowering] Add support for mangling identity thunks.
This is just again using identity thunks to show that the behavior works before
I add in hop to main actor.
2024-10-17 11:17:38 -07:00
Nate Chandler
df1c4f6b25 [CoroutineAccessors] Add new SILFnTy CoroKind.
For `modify` and `read` coroutines, produce SILFunctionType's whose
coroutineKind is ::YieldOnce2.
2024-10-11 08:25:02 -07:00
Konrad `ktoso` Malawski
dea3b59331 Merge pull request #76250 from ktoso/wip-experimental-isolated-deinit 2024-10-03 17:19:10 +09:00
Nate Chandler
091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Konrad `ktoso` Malawski
d89347bed0 Merge branch 'main' into wip-experimental-isolated-deinit 2024-09-20 18:34:45 +09:00
Dmitrii Galimzianov
df9ecd9a4c [Demangler] Stable parent identifier in OpaqueReturnTypeParent
`OpaqueReturnTypeParent` node now references the parent with a mangled parent name, rather than a parent pointer. This makes trees obtained from different demanglers (or calls to `Demangler::demangleSymbol`) for the same symbol equal.
2024-09-18 01:14:38 +02:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Meghana Gupta
10057523ec Delete lifetime dependence mangling
Mangling this information for future directions like component lifetimes
becomes complex and the current mangling scheme isn't scalable anyway.

Deleting this support for now.
2024-09-05 22:03:58 -07:00
Alejandro Alonso
8a9303b3cf Consistently negate the value from demangling 2024-09-04 15:13:50 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
7c85261a77 Add runtime support 2024-09-04 15:13:27 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Alex Hoppen
c5aa49ba64 Revert "Isolated synchronous deinit" 2024-09-03 18:11:26 -07:00
Mykola Pokhylets
e0ad7bde82 Merge branch 'main' into mpokhylets/isolated-deinit
# Conflicts:
#	include/swift/Basic/Features.def
#	lib/AST/ASTPrinter.cpp
#	lib/AST/FeatureSet.cpp
2024-08-29 11:28:43 +02:00
Erik Eckstein
c8e74b8393 Generic specialization: change the mangling for dropped metatype arguments
Instead of adding a "flag" (`m` in `...Tgm5`) make it more generic to allow to drop any unused argument.
Add all dropped arguments with a `t<n-1>` (where `<n-1>` is empty for n === 0). For example `...Ttt2g5`.
2024-08-26 10:43:15 +02:00
Mykola Pokhylets
50b1313175 Merge branch 'main' into mpokhylets/isolated-deinit
# Conflicts:
#	lib/SILGen/SILGenDistributed.cpp
#	lib/Sema/TypeCheckConcurrency.cpp
2024-08-15 16:58:43 +02:00
Saleem Abdulrasool
194d7cfc87 Merge pull request #75690 from nico/demangle-assertion
[Demangling] Remove includes of swift/Basic/Assertions.h
2024-08-06 14:22:04 -07:00
Saleem Abdulrasool
262ba2b24d Merge pull request #75682 from nico/fpermissive
Fix build error with gcc in swift demangling code
2024-08-05 17:58:46 -07:00
Nico Weber
9d5359d1f8 [Demangling] Remove includes of swift/Basic/Assertions.h
They are not used. Demangling uses `assert()` from <cassert>,
and macros from lib/Demangling/DemanglerAssert.h.

Reverts the lib/Demangling changes from #74184.

No behavior change.
2024-08-05 12:16:00 -04:00
Nico Weber
55d27a780d Fix build error with gcc in swift demangling code
Fixes:

    third_party/swift/include/swift/Demangling/Demangler.h:228:11:
      error: declaration of ‘swift::Demangle::NodeFactory::Slab* swift::Demangle::NodeFactory::Checkpoint::Slab’
             changes meaning of ‘Slab’ [-fpermissive]
      228 |     Slab *Slab;
          |           ^~~~
    third_party/swift/include/swift/Demangling/Demangler.h:47:10:
      note: ‘Slab’ declared here as ‘struct swift::Demangle::NodeFactory::Slab’
       47 |   struct Slab {
          |          ^~~~

No intended behavior change.
2024-08-04 21:39:15 -04:00
Nico Weber
4d630fd5fa Demangling: Fix -Wunused-but-set-variable warnings
No intended behavior change.
2024-08-04 21:09:32 -04:00
Mykola Pokhylets
816d62c972 Merge remote-tracking branch 'upstream/main' into mpokhylets/isolated-deinit
# Conflicts:
#	include/swift/Basic/Features.def
#	lib/SILGen/SILGenDestructor.cpp
#	test/Concurrency/flow_isolation.swift
#	test/abi/macOS/arm64/concurrency.swift
#	test/abi/macOS/x86_64/concurrency.swift
2024-07-11 13:11:59 +02:00
Mykola Pokhylets
b189495518 Introduced isolated deinit as a SIL entity 2024-07-11 13:09:05 +02:00
Meghana Gupta
7d2ff43fe3 Update mangling to support lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
Erik Eckstein
7fe2befd31 Demangler: handle errors in demangleType
Makes sure that invalid runtime type strings result in errors and not fail silently.
In worst case this could lead to wrong reconstructed metatypes which can result in all kind of memory corruption.

relates to rdar://129861211
2024-07-05 11:37:15 +02:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Slava Pestov
9793f77daa AST: New mangling for expansion locations to avoid request cycles
Fixes rdar://127078338.
2024-06-13 17:45:30 -04:00