Commit Graph

12816 Commits

Author SHA1 Message Date
Kuba Mracek
9c77074cac [Mangling] Establish a new mangling prefix for Embedded Swift: $e 2024-12-02 15:01:24 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Gábor Horváth
04de3492d2 Merge pull request #77855 from swiftlang/gaborh/refactor-findctors
[cxx-interop] Simplify finding copy/move ctors in IRGen
2024-12-02 10:42:22 +00:00
Erik Eckstein
6a0b7d1f8c ObjectOutliner: create outlined arrays as let variables
This will allow load-simplification to replace a load of such an array.
2024-11-28 09:40:12 +01:00
Gabor Horvath
179786b784 [cxx-interop] Simplify finding copy/move ctors in IRGen 2024-11-27 15:51:57 +00:00
Allan Shortlidge
ad7383499b Merge pull request #77758 from tshortli/available-attr-conveniences
AST: `AvailableAttr` cleanup
2024-11-21 13:03:07 -08:00
Hamish Knight
23e3f5f5de Merge pull request #77666 from hamishknight/lets-try-this-again
[AST] Remove `ModuleDecl::addFile`
2024-11-21 20:15:58 +00:00
Pavel Yaskevich
0fe4cea7d7 [AST] Introduce a new type that has associated location in source
This type is intended to be used to wrap compiler synthesized nodes
(i.e. variables) to make it easier for diagnostic to diagnose precise
failure locations.

Consider the situation like:

```
protocol P {}

extension Array: P where Element: P {}

func test<T: P>() -> T {
  $_a = ...
  $_b = ...
  return [$_a, $_b]
}
```

This is a common pattern with result builders.

In this case if one of the elements don't conform to `P` the best
user experience would be to attach diagnostic to the element otherwise
the developers would have to figure out where in result expression
the error occured before attempting to fix it.
2024-11-21 11:01:13 -08:00
Joe Groff
5822bc3685 Merge pull request #77605 from jckarter/capture-metadata-for-fixed-box-to-run-deinit
IRGen: Capture NecessaryBindings in fixed boxes that may invoke deinits.
2024-11-21 09:59:51 -08:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Dario Rexin
86377b32b1 Merge pull request #76743 from swiftlang/coro-pa-context
Fix partial apply forwarder emission for coroutines that are methods of structs with type parameters
2024-11-21 03:05:25 -08:00
Arnold Schwaighofer
c5463bdf92 Merge pull request #68985 from antoniofrighetto/feature/load-pass-plugin
[Driver][Frontend] Introduce `load-pass-plugin` option
2024-11-20 14:22:12 -08:00
Joe Groff
b5e79d5590 IRGen: Capture NecessaryBindings in fixed boxes that may invoke deinits.
Noncopyable types may have user-defined code in their `deinit`s that requires
passing the type's generic parameters, so a box for a captured noncopyable type
needs to capture the generic environment even when the captured type is fixed-
layout. Fixes rdar://138958210.
2024-11-20 11:19:10 -08:00
Nate Chandler
79c62dd5a0 [CoroutineAccessors] Rewrite allocs in LBA.
When replacing a `begin_apply` with an allocation, replace uses of the
old allocation with uses of the new.
2024-11-19 12:57:49 -08:00
Erik Eckstein
4241a2cbfd embedded: Don't emit SILProperties in embedded swift
SILProperties are only needed for resilient builds.

Fixes a crash in IRGen
https://github.com/swiftlang/swift/issues/77682
2024-11-19 10:10:56 +01:00
Felipe de Azevedo Piovezan
3dfee33174 Merge pull request #77655 from felipepiovezan/felipe/fix_code_gen_debug_info
[DebugInfo] Change lowering of SIL instructions to use line 0 when appropriate
2024-11-18 16:31:11 -08:00
Felipe de Azevedo Piovezan
f7f869c88d [DebugInfo] Don't inherit debug location of previous instruction
Prior to this commit, when lowering SIL instructions that should are
"hidden" for the purposes of debugging, the compiler just attaches the
location of the previous instruction in the name of keeping a simpler
line table.

However, this is wrong for many reasons. One such reason is this: at the
start of a basic block, inheriting the previous debug location will
almost certainly cause the instruction to have a random location in the
code, as it will depend on whatever BB was visited previously.

Other examples can be seen in the tests affect by this commit, which
changes lowering to use Line 0 instead of the line number of the
previous instruction.

CodeView doesn't handle line 0 the same way DWARF does, so this commit
preserves the old behavior for the CodeView path.

The test changes here are effectively undoing some of the diffs from
158772c2ab.

rdar://139826231&110187845
2024-11-18 10:23:41 -08:00
Hamish Knight
4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Doug Gregor
c5de02f60e Merge pull request #77628 from DougGregor/clang-importer-parse-request
[Clang importer] Use ParseSourceFileRequest for parsing swift_attr attributes
2024-11-16 01:12:27 -08:00
Felipe de Azevedo Piovezan
9758099e91 [NFC][DebugInfo] Factor out CodeView code into its own function
CodeView has its own needs / limitations for representing line 0.
However, this is adding control flow complexities that make changing the
underlying logic complicated for both cases. Furthermore, the
limitations above may be temporary if we change LLVM's backend; by
having a separate function, we can, in the future, easily unify the code
paths in the future by deleting the function.
2024-11-15 14:20:27 -08:00
Felipe de Azevedo Piovezan
e9fbb17f09 [NFC][DebugInfo] Factor out debug location code
This patch moves, into its own function, the code computing a
`FileAndLocation` for the instruction being lowered (SIL>LLVM IR).
Control flows is simplified as a result.
2024-11-15 14:20:27 -08:00
Doug Gregor
24a12ebc34 Renable GeneratedSourceInfo::Attribute to GeneratedSourceInfo::AttributeFromClang 2024-11-15 09:02:49 -08:00
Slava Pestov
da5ce1289c Merge pull request #77599 from slavapestov/fix-rdar139745699
IRGen: Adjust hacks for keypaths to protocol extension members
2024-11-15 12:02:25 -05:00
Dario Rexin
abfa450e3e Merge pull request #77597 from drexin/wip-139375022
[IRGen] Set minimum runtime availability version for CVW
2024-11-14 06:11:37 -08:00
Doug Gregor
f802b67fc0 Merge pull request #77580 from DougGregor/swift-attr-parsing-fixes
Ensure that buffers containing Clang swift_attr attributes are parsed as attributes
2024-11-14 03:19:16 -08:00
Dario Rexin
c0c31c0613 [IRGen] Set minimum runtime availability version for CVW
rdar://139375022

CVW should not be generated when the deployment target does not have the necessary runtime functions.
2024-11-13 22:36:15 -08:00
Doug Gregor
aa4c548c0f Clang importer: switch swift_attr attribute text cache over to be module-sensitive
We need different buffers for each imported module that has swift_attr attributes,
so cache them appropriately.
2024-11-13 21:19:39 -08:00
Doug Gregor
989c73d014 Ensure that buffers containing Clang swift_attr attributes are parsed as attributes
Previously, they were being parsed as top-level code, which would cause
errors because there are no definitions. Introduce a new
GeneratedSourceInfo kind to mark the purpose of these buffers so the
parser can handle them appropriately.
2024-11-13 21:19:37 -08:00
Allan Shortlidge
d70091f5a1 IRGen: Omit property descriptors from #_hasSymbol checks for static properties.
Property descriptors for static properties were only recently introduced with
SE-438. Since these symbols are not present in Swift libraries that were
compiled with earlier versions of the compiler, it is not safe for
`#_hasSymbol` to check for the property descriptor symbols, since they can be
absent at either link time or runtime.

Resolves rdar://139749275.
2024-11-13 16:00:56 -08:00
Slava Pestov
0a23afcb99 IRGen: Adjust hacks for keypaths to protocol extension members
This was never implemented properly, but it works sometimes.

When the protocol is parameterized, it started crashing in a new way,
because the interface type of an existential is now derived from the
generalization signature, which will have nothing to do with the
signature that IRGen is passing in here.

Tweak the workaround to keep things limping along.

Fixes rdar://problem/139745699
2024-11-13 17:05:25 -05:00
Arnold Schwaighofer
f9941b339a IRGen: Outlined value functions of types that might expand differently in
different TUs must use private linkage

rdar://136376117
2024-11-12 13:03:13 -08:00
Dario Rexin
3301541be5 [IRGen] Fix crash in CVW generation for ObjC references
rdar://139664644

The code that differentiates between regular ObjC and native Swift ObjC references could crash when generics were involved. Instead of through the TypeInfo, we are going directly throught the SILType to the type decl, which avoids the crash caused by casting the TypeInfo.
2024-11-11 16:23:59 -08:00
Allan Shortlidge
0d581c4261 NFC: Use VersionRange::all() to represent "always available".
It doesn't make sense to use `VersionRange::empty()` to represent "universally
available" since something that is available in an empty version range is
effectively never available.
2024-11-09 19:36:03 -08:00
Arnold Schwaighofer
08b3c95883 Merge pull request #77452 from aschwaighofer/enable_async_metadata
IRGen: Enable EmitAsyncFramePushPopMetadata per default
2024-11-08 15:21:58 -08:00
Arnold Schwaighofer
1c1d95a814 EmitAsyncFramePushPopMetadata is currently only supported on MachO
The LLVM pass that emits the sections is hard code for MachOS sections
2024-11-08 09:21:56 -08:00
Arnold Schwaighofer
75f0de019a Merge pull request #77470 from aschwaighofer/builtin_fixed_array_explosion_heuristic
LargeTypesReg2Mem: Don't ignore BuiltinFixedArrayType
2024-11-08 06:36:16 -08:00
Arnold Schwaighofer
61a8e5ad73 Merge pull request #77460 from aschwaighofer/fix_metadata_lookup
IRGen: Metadata lookup failure
2024-11-08 06:30:48 -08:00
Dario Rexin
0d7054b637 Merge pull request #76630 from drexin/wip-135954459
[IRGen] Reintroduce typed throws ABI
2024-11-07 15:56:22 -08:00
Dario Rexin
4ea0c9bbee Merge pull request #77431 from drexin/wip-138487964
[IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects a…
2024-11-07 15:55:08 -08:00
Arnold Schwaighofer
ec5c432e09 LargeTypesReg2Mem: Don't ignore BuiltinFixedArrayType
rdar://139457907
2024-11-07 15:30:17 -08:00
Arnold Schwaighofer
9ae952ee09 IRGen: Metadata lookup failure
Metadata lookup uses getRuntimeReifiedType(X) in places, fill the cache
with key entries for X and getRuntimeReifiedType(X) such that they can be
found on lookup.

rdar://139234543
2024-11-07 13:00:29 -08:00
Dario Rexin
f6e7c16a8a [IRGen] Map types into context in typed throws code gen
Some types that should have been were not mapped into context.
2024-11-07 11:51:58 -08:00
Dario Rexin
03c3d985aa [IRGen] Assign error flag after calling direct error returning async typed throws function 2024-11-07 10:22:54 -08:00
Dario Rexin
26521cd165 [IRGen] Properly handle empty results in direct error return in emitAsyncReturn
When the result is empty, but the error type is not, we have to return an `undef` for the result.
2024-11-07 10:22:53 -08:00
Dario Rexin
60afdd38b6 [IRGen] Fix return value mapping in typed throwing async protocol thunks
The mapping was completely missing, causing compiler crashes.
2024-11-07 10:22:53 -08:00
Dario Rexin
cdcdeb9540 [IRGen] Fix return values for typed throws with empty error
When the error is an empty type, the return value for the error case needs to be an `undef` value of the result type, or `void`, if the result type is `void`
2024-11-07 10:22:53 -08:00
Nate Chandler
5785d4580a [TypedThrows] Don't return undef : void.
LLVM doesn't like undef instances of void.

rdar://135631963
2024-11-07 10:22:53 -08:00
Dario Rexin
ffd9f205b3 [IRGen] Re-introduce typed throws ABI
rdar://135954459
2024-11-07 10:22:49 -08:00
Dario Rexin
3c7b556cf1 [IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects and blocks
rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.
2024-11-07 09:55:40 -08:00