Commit Graph

11150 Commits

Author SHA1 Message Date
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Slava Pestov
90562a0fe9 IRGen: Fix linkage of opaque type descriptor with @_alwaysEmitIntoClient owner decl 2023-08-18 12:12:50 -04:00
Slava Pestov
99d68ba14c IRGen: Some progress toward tuple conformances 2023-08-18 12:12:50 -04:00
zachary0kent
802e63a778 Merge pull request #67973 from zachary0kent/lazy-immediate-globals
[Immediate] JIT'ing Globals
2023-08-18 08:53:18 -07:00
nate-chandler
c0fa16e7be Merge pull request #68000 from nate-chandler/cherrypick/main/rdar114013709
[IRGen] Cast fixed-size opaque globals.
2023-08-18 06:59:30 -07:00
Nate Chandler
9981a82d01 [IRGen] Cast fixed-size opaque globals.
In https://github.com/apple/swift/pull/66560 , a bug in the lowering of
`global_addr` was fixed.  Part of that fix was to postpone mapping the
type of the global into context until getting the address of the global
and projecting the buffer for the out-of-line value; at that point, the
type is mapped into context and the address is cast.

It introduced an issue for fixed-size globals, however: the type of such
globals was not mapped into context; the result was that the lowered
value set for the corresponding SIL value would have the wrong type.

Fix that by extracting the code which mapped the type into context and
cast the address to the appropriate lowered type into a lambda and call
that lambda both in both the fixed-size (newly) and non-fixed-size (as
before) cases.

rdar://114013709
2023-08-17 17:23:02 -07:00
nate-chandler
8cab09e429 Merge pull request #67966 from nate-chandler/opaque-values/20230816/1/indirect-pack-tuple-handling
[AddressLowering] Handle indexing into variadic tuples.
2023-08-17 14:20:44 -07:00
eeckstein
48695c6e51 Merge pull request #67983 from eeckstein/fix-function-mp-enums
IRGen: fix a problem `convert_function` in a payload of a statically initialized enum
2023-08-17 23:10:10 +02:00
Zak Kent
6aafeec181 [Immediate] [SILGen] Implement on-demand compilation of globals 2023-08-17 11:03:11 -07:00
Zak Kent
a6eb4b44c7 [TBD] Refactored SymbolSourceMap to be a typedef 2023-08-17 09:55:49 -07:00
Felipe de Azevedo Piovezan
cb4aeefe64 Merge pull request #67911 from felipepiovezan/felipe/delete_dead_code
[IRGen] Delete no-op code
2023-08-17 10:01:20 -04:00
Erik Eckstein
b435cf33c6 IRGen: fix a problem conver_function in a payload of a statically initialized enum
This was a stupid oversight. The `flatten` flag needs to be passed through `convert_enum` in `irgen::emitConstantValue`.

Fixes a compiler crash.

rdar://113942221
2023-08-17 10:07:20 +02:00
Pavel Yaskevich
c38b9b1e08 Merge pull request #67945 from xedin/remove-runtimeMetadata
[Frontend] NFC: Remove code and tests related to rejected @runtimeMetadata feature
2023-08-16 17:16:46 -07:00
Nate Chandler
7bddaf36a0 [SIL] Added tuple_pack_extract.
The new instruction is needed for opaque values mode to allow values to
be extracted from tuples containing packs which will appear for example
as function arguments.
2023-08-16 11:15:05 -07:00
Alejandro Alonso
44198d16a4 Merge pull request #67611 from Azoy/raw-types-are-cool!
[WIP] Implement dependent layouts for raw types
2023-08-16 06:55:42 -07:00
Alejandro Alonso
c20ab10cef Use an i32 argument instead of size
more int32

zzz
2023-08-15 19:49:44 -07:00
Meghana Gupta
672565749c Generate appropriate LLVM IR attributes for custom optimization modes set on a SILFunction 2023-08-15 15:45:54 -07:00
Pavel Yaskevich
eee923bc42 [IRGen] [AST] NFC: Remove @runtimeMetadata related code and metadata records 2023-08-15 12:17:31 -07:00
Felipe de Azevedo Piovezan
af6599ff31 [IRGen] Delete no-op code
Commit 5c3ccf5050 added a number of blocks of code which were partially
removed by 39af79f491. This partial remove left lines of code doing nothin; we
remove them here.
2023-08-14 10:02:22 -04:00
Andrew Trick
61c12e4be0 Fix LoadableByAddress to use @in_guaranteed for unowned values
LoadableByAddress was accidentally changing ownership of
direct_unowned values to @in (owned). This generates unsupported SIL
for on-stack partial applies, which now breaks SIL verification.

This also resulted in extra copies of values inside of closure
contexts. Before calling the original function, the value would need to
be copied onto the stack and the context would be destroyed. Now, we
simply pass a pointer directly from the closure context.  See
IRGen/indirect_argument.sil+huge_partial_application.

I'm pretty sure fixing this has no effect on the mangling of public symbols.
2023-08-12 21:21:18 -07:00
Egor Zhdan
8acfbd828e Merge pull request #67866 from apple/egorzhdan/cxx-mutable-rac-iter
[cxx-interop] Add `UnsafeCxxMutableRandomAccessIterator` protocol
2023-08-10 23:17:24 +01:00
Egor Zhdan
3723ff1401 [cxx-interop] Add UnsafeCxxMutableRandomAccessIterator protocol
This will be used to provide a safe overload of `std::vector::erase` in Swift.

`std::vector::erase` is not currently imported into Swift because it returns a C++ iterator.

rdar://113704853
2023-08-10 19:58:51 +01:00
Erik Eckstein
afc0f617e0 Optimizer: support statically initialized globals which contain pointers to other globals
For example:
```
  var p = Point(x: 10, y: 20)
  let o = UnsafePointer(&p)
```

Also support outlined arrays with pointers to other globals. For example:
```
var g1 = 1
var g2 = 2

func f() -> [UnsafePointer<Int>] {
  return [UnsafePointer(&g1), UnsafePointer(&g2)]
}
```
2023-08-10 20:50:36 +02:00
Nate Chandler
f938287710 [SIL] Added unowned_copy_value. 2023-08-08 15:49:17 -07:00
Nate Chandler
c007bae723 [SIL] Added weak_copy_value.
The new instruction wraps a value in a `@sil_weak` box and produces an
owned value. It is only legal in opaque values mode and is transformed
by `AddressLowering` to `store_weak`.
2023-08-08 15:47:13 -07:00
Nate Chandler
e135c5cac7 [SIL] Added strong_copy_weak_value.
The new instruction unwraps an `@sil_weak` box and produces an owned
value. It is only legal in opaque values mode and is transformed by
`AddressLowering` to `load_weak`.
2023-08-08 15:47:13 -07:00
Saleem Abdulrasool
d1b63d6969 Merge pull request #67776 from compnerd/the-missing-link
IRGen: rework linking against CxxStdlib
2023-08-08 15:08:48 -07:00
Alex Lorenz
1addca37a2 Merge pull request #67685 from hyp/eng/hoping-one-day-67674-gets-fixed
[cxx-interop][windows] additional fix for indirect return in methods
2023-08-08 12:13:01 -07:00
Saleem Abdulrasool
1040116e32 IRGen: rework linking against CxxStdlib
Rewrite the handling for the `CxxStdlib` implicit linking to use a
slightly more functional style for filtering.  Additionally, add Windows
to the list providing the overlay.  The Windows linking scenario is a
slightly more complicated as the library names differ between static and
dynamic variants to disambiguate between import libraries and static
libraries.  Take this into account when embedding the library name so
that the linker can find the appropriate content.
2023-08-08 09:03:37 -07:00
Egor Zhdan
6261ee2bb5 Merge pull request #67772 from apple/egorzhdan/cxx-vector-proto
[cxx-interop] Add `CxxVector` protocol
2023-08-07 19:25:57 +01:00
Alex Lorenz
8d81f5e3f7 [cxx-interop][windows] Pass trivial indirect result after 'this' when invoking C++ MSVC ABI method 2023-08-07 11:15:20 -07:00
Egor Zhdan
4acf9c8cf4 [cxx-interop] Add CxxVector protocol
This makes it possible to initialize `std::vector` from a Swift Sequence. This also conforms C++ vectors to `ExpressibleByArrayLiteral`, making it possible, for instance, to pass a Swift array to a C++ function that takes a vector of strings as a parameter.

rdar://104826995
2023-08-07 17:12:12 +01:00
Allan Shortlidge
cb7982d8d5 Merge pull request #67761 from tshortli/ast-unavailable-decl-queries
NFC: Hoist queries for unavailable decl optimizations into the AST library
2023-08-06 10:01:27 -07:00
Tony Allevato
b2fd3eb754 Merge pull request #67707 from allevato/no-u8-prefixes 2023-08-05 21:24:05 -04:00
Slava Pestov
6ae2a1deee Merge pull request #67739 from slavapestov/var-decl-type-in-context
AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
2023-08-04 21:44:22 -04:00
Allan Shortlidge
ca8bf981a4 NFC: Hoist queries for unavailable decl optimizations into the AST library.
Moving the query implementation up to the AST library from SIL will allow
conveniences to be written on specific AST element classes. For instance, this
will allow `EnumDecl` to expose a convenience that enumerates element decls
that are available during lowering.

Also, improve naming and documentation for these queries.
2023-08-04 17:39:26 -07:00
Tony Allevato
300a952ede Replace u8 string literal prefixes with SWIFT_UTF8 macro.
In C++20, `u8` literals create values of type `char8_t` instead of
`char`, and these can't be implicitly converted. This macro
mitigates the difference and allows the same code to compile under
C++14/17 modes and C++20, preserving the `char` type while ensuring
that the text is interpreted as UTF-8.
2023-08-04 16:41:36 -04:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Slava Pestov
59fd29551e IRGen: Emitting metadata for function types containing pack expansion parameters 2023-08-03 22:12:05 -04:00
Alex Lorenz
8449b21d62 [cxx-interop][windows] additional fix for indirect return in methods for MSVC ABI
Fixes https://github.com/apple/swift/pull/67685
2023-08-03 15:07:22 -07:00
Slava Pestov
0f3c43089a IRGen: Refactor function type metadata emission 2023-08-03 16:06:05 -04:00
Slava Pestov
92ad17231e IRGen: Factor out emitFunctionTypeMetadataRef() from EmitTypeMetadataRef 2023-08-03 16:06:05 -04:00
Tony Allevato
b59f5c7c02 Merge pull request #67683 from allevato/c++20-tweaks
[Code Health] Improve eventual C++20 support.
2023-08-03 13:24:06 -04:00
Alejandro Alonso
f840191e14 Emit call to old initialization function for older OSes
Add test

Update raw_layout.swift

Update raw_layout.swift
2023-08-03 09:30:37 -07:00
Tony Allevato
c71c1e193b Ensure types used as std::vector elements are complete.
These were never allowed, but with C++20 making more `vector` functions
`constexpr`, they would start causing build failures in that language
mode.
2023-08-02 15:03:48 -04:00
Pavel Yaskevich
af99e67541 Merge pull request #67651 from xedin/use-all-members-in-gen-class
[IRGen] Use `getAllMembers` instead of `getMembers`
2023-08-02 09:26:48 -07:00
Konrad `ktoso` Malawski
95920b2570 [Concurrency] Fix init task group with flags availability
resolves rdar://112469076
2023-08-02 12:02:27 +09:00
Alejandro Alonso
df17f7be90 Implement dependent layouts for raw types
Update raw_layout.swift

Allow for concrete specializations of raw layout

Make test platform agnostic
2023-08-01 14:09:23 -07:00
Joe Groff
984b4f2387 Merge pull request #67633 from jckarter/raw-layout-initialization
Fix `@_rawLayout` initialization to avoid spurious lifetime ends.
2023-08-01 13:34:29 -07:00
Pavel Yaskevich
e20e4a546c [IRGen] Use getAllMembers instead of getMembers
Discovered while auditing code that uses `getMembers`.
2023-08-01 10:54:16 -07:00