Commit Graph

12816 Commits

Author SHA1 Message Date
Arnold Schwaighofer
d925eefdba IRGen: Fix a map entry use-after-free issue in LargeLoadableHeuristic
rdar://139398409
2024-11-07 09:51:16 -08:00
Antonio Frighetto
377c03fa7e [Driver][Frontend] Introduce load-pass-plugin option
Allow dynamic loading of LLVM passes via `load-pass-plugin`
option passed to the Swift compiler driver.
2024-11-07 17:25:24 +01:00
Augusto Noronha
3f8ffaa46c Merge pull request #77176 from augusto2112/spare-bits-debug-2
[DebugInfo] Stop emitting spare bits mask in debug info
2024-11-06 15:46:20 -08:00
Egor Zhdan
418c86df66 Merge pull request #77367 from swiftlang/egorzhdan/irgen-base-subobject
[cxx-interop] Fix IRGen for C++ types that use tail padding of their bases
2024-11-06 22:41:43 +00:00
Arnold Schwaighofer
34c417d9ff Merge pull request #77379 from aschwaighofer/enable_aggressive_reg2mem
Enable heuristic that tries to keep large values in memory
2024-11-06 11:36:33 -08:00
Dario Rexin
47265438b7 Merge pull request #77383 from drexin/wip-139106139
[IRGen+Runtime] Differentiate between pure Swift and regular ObjC ref…
2024-11-05 11:20:22 -08:00
Slava Pestov
3efa770c86 Merge pull request #77371 from slavapestov/fix-issue-77297
IRGen: Make sure loadable error types are mapped into the generic environment too
2024-11-05 03:31:45 -05:00
Dario Rexin
4e7ce5a058 [IRGen+Runtime] Differentiate between pure Swift and regular ObjC references in CVW
rdar://139106139

Regular ObjC references do not have unused bits or extra inhabitants for storing enum tags, because they may be tagged pointers. However, ObjC classes that are implemented in Swift do, so we must differentiate between the two.
2024-11-04 18:52:26 -08:00
Arnold Schwaighofer
6755d0e104 LargeTypesReg2Mem: Ammend heuristic to include projections of block
arguments
2024-11-04 17:06:24 -08:00
Slava Pestov
505c950db8 IRGen: Make sure loadable error types are mapped into the generic environment too
Fixes https://github.com/swiftlang/swift/issues/77297
Fixes rdar://problem/139000360
2024-11-04 14:26:45 -05:00
Egor Zhdan
d3e43bbe7b [cxx-interop] Fix IRGen for C++ types that use tail padding of their bases
In C++, a field of a derived class might be placed into the tail padding of a base class. Swift was not handling this case correctly, causing an asserts-disabled compiler to run out of RAM, and an asserts-enabled compiler to fail with an assertion.

Fixes this IRGen assertion:
```
Assertion failed: (offset >= NextOffset && "adding fields out of order"), function addField, file GenStruct.cpp, line 1509.
```

rdar://138764929
2024-11-04 13:44:43 +00:00
Kavon Farvardin
86601fcbbf Merge pull request #76532 from kavon/samplepgo
Add support for SamplePGO
2024-11-01 17:52:52 -07:00
Augusto Noronha
459c7fdc7b [DebugInfo] Stop emitting spare bits mask in debug info
We're now able to calculate the spare bits mask from other information.
Stop emitting it in debug info.
2024-11-01 15:51:59 -07:00
Kavon Farvardin
19e593bc07 PGO: new -debug-info-for-profiling frontend flag
This achieves the same as clang's `-fdebug-info-for-profiling`, which
emits DWARF discriminators to aid in narrowing-down which basic block
corresponds to a particular instruction address. This is particularly
useful for sampling-based profiling.

rdar://135443278
2024-11-01 11:59:54 -07:00
Kavon Farvardin
2b01714fba PGO: new -profile-sample-use= frontend flag
This is meant to match clang's `-fprofile-sample-use=` and accepts a
file with the same format.

rdar://135443278
2024-11-01 11:59:54 -07:00
Michael Gottesman
3c38c79f7a [region-isolation] Implement MergeIsolationRegionInst.
I am adding this instruction to express artificially that two non-Sendable
values should be part of the same region. It is meant to be used in cases where
due to unsafe code using Sendable, we stop propagating a non-Sendable dependency
that needs to be made in the same region of a use of said Sendable value. I
included an example in ./docs/SIL.rst of where this comes up with @out results
of continuations.
2024-11-01 11:25:53 -07:00
Hamish Knight
df7cac3114 Merge pull request #59141 from hamishknight/wrapping-paper
[AST] Remove ParenType
2024-11-01 16:52:23 +00:00
Arnold Schwaighofer
501f2be057 Merge pull request #77331 from aschwaighofer/large_types_reg2mem_aggressive
LargeTypesReg2Mem: Add a new heuristic that trys harder to keep large     values on the stack
2024-11-01 06:15:18 -07:00
Arnold Schwaighofer
787c996394 LargeTypesReg2Mem: Add a new heuristic that trys harder to keep large
values on the stack

This heuristic can be enabled by passing -Xfrontend
-enable-aggressive-reg2mem.

rdar://123916109
2024-10-31 13:22:06 -07:00
Arnold Schwaighofer
5f396cd13c IRGen: Add indirect peepholes for arguments and return value coercion
Large tuples of values (e.g char[32]) can be passed directly at the abi
boundry but expand to a big explosion of values.

Peephole this explosion at argument passing and return value passing
points to avoid code size growth associated with the explosion.
2024-10-31 13:02:07 -07:00
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Augusto Noronha
cb205b6a79 Merge pull request #77290 from augusto2112/orig-def-spec
[DebugInfo] Handle types with @_originallyDefinedIn in DebugInfo
2024-10-30 15:34:53 -07:00
Augusto Noronha
da690d6153 [DebugInfo] Handle types with @_originallyDefinedIn in DebugInfo
When processing a nominal type that has the @_originallyDefinedIn attribute,
IRGenDebugInfo emits a forward declaration of the type as a child
of the original module, and the type with a specification pointing to
the forward declaration. We do this so LLDB has enough information to
both find the type in reflection metadata (the parent module name) and
find it in the swiftmodule (the module name in the type mangled name).

rdar://137146961
2024-10-29 17:46:45 -07:00
Kuba Mracek
cf7ea301e1 [Concurrency] Fix arm64e ptrauth violations in Embedded Swift Concurrency 2024-10-28 21:16:48 -07:00
Ben Barham
f59b2f19e6 Merge branch 'main' into 2024-rebranch-to-main 2024-10-28 13:03:35 -07:00
Hiroshi Yamauchi
3c501656a1 Merge pull request #76324 from hjyamauchi/issue74866
Fix the IR gen for C++ method calls and refactor around CGFunctionInfo
2024-10-28 12:07:36 -07:00
Hiroshi Yamauchi
fcc1f6b65e Fix the IR gen for C++ method calls and refactor around CGFunctionInfo
In GenCall, fix the IR gen for C++ method calls as under MSVC as the
calling conventions for free functions and C++ methods can be
different. This also fixes the missing inreg (on sret arguments)
issues on Windows ARM64. Also refactor to use CGFunctionInfo
returnInfo isSretAfterThis to detect when to reorder the sret and the
this arguments under MSVC.

In ClagImporter, don't drop the return type for the compound
assignment operators such as operator+= when the return value is a
reference so that the CGFunctionInfo will be correctly indicate an
indirect return for the compound assignment operators.
2024-10-24 15:40:21 -07:00
Ben Barham
746517c9f2 Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `test/IRGen/has_symbol.swift` test updates in rebranch. The new test
    will fail, will fix in the next commit.
2024-10-24 14:20:17 -07:00
Slava Pestov
5190d98e1b Merge pull request #77178 from slavapestov/misc-solver-cleanups
Miscellaneous solver cleanups
2024-10-24 16:52:01 -04:00
Artem Chikin
d0ff56b345 Merge pull request #70564 from artemcm/ExplicitBuildClangTargetIRGen
[Explicit Module Builds] Initialize `ClangImporter`'s `CodeGenerator` using Swift compilation Target Triple.
2024-10-24 09:45:51 -07:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Slava Pestov
5e1e18424b AST: Clean up ExistentialLayout for ParameterizedProtocolType 2024-10-22 20:14:44 -04: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
Alejandro Alonso
c58cc440f0 Support generic but concrete metatypes with hasSymbol 2024-10-22 13:25:47 -07:00
swift-ci
9dcd39a254 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-22 00:42:50 -07:00
Gábor Horváth
266a622b4c Merge pull request #76011 from swiftlang/gaborh/emit-more-metadata
[cxx-interop] Emit type metadata for foreign types more often
2024-10-22 08:18:18 +01:00
Ben Barham
2523660d3b Revert "[DebugInfo] Stop emitting spare bits mask in debug info" 2024-10-21 14:23:04 -07:00
Artem Chikin
0fbbba5154 [Explicit Module Builds] Initialize ClangImporter's 'CodeGenerator' using Swift compilation Target Triple.
As per #65930, the Clang importer's Clang instance may be configured with a different (higher) OS version than the compilation target itself in order to be able to load pre-compiled Clang modules that are aligned with the broader SDK, and match the SDK deployment target against which Swift modules are also built. Code-generation, however, must use the actual compilation target triple. This matches how Swift itself loads Swift module dependencies as well: dependency '.swiftinterface' files are type-checked against the availability epoch and code-generated against the actual compilation triple.

Resolves rdar://113712186
2024-10-21 14:12:23 -07:00
swift-ci
8af1ee5f5f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-21 08:55:27 -07:00
Kuba (Brecka) Mracek
f766900532 Merge pull request #77121 from kubamracek/embedded-leak
[embedded] Fix a memory leak caused by incorrect refcounting logic around doNotFreeBit
2024-10-21 08:55:02 -07:00
swift-ci
7906594f92 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-21 07:34:55 -07:00
Dario Rexin
5b6b462840 Merge pull request #77126 from drexin/wip-138028500
[IRGen] Prevent CVW from being emitted for non-copyable types
2024-10-21 07:32:08 -07:00
Dario Rexin
bbb67d1cc1 [IRGen] Prevent CVW from being emitted for non-copyable types
rdar://138028500

In some cases CVW were emitted for non-copyable types, which should not happen.
2024-10-19 11:08:32 -07:00
Kuba Mracek
8666aef39f [embedded] Fix a memory leak caused by incorrect refcounting logic around doNotFreeBit 2024-10-18 23:19:40 -07:00
swift-ci
bf599de16e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-18 05:18:57 -07:00
Slava Pestov
13da4c2ad3 Merge pull request #77034 from slavapestov/fix-rdar117815191
IRGen: Fix emission of calls to opaque return type metadata access function with packs
2024-10-18 08:11:35 -04:00
swift-ci
96186d8026 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 14:26:57 -07:00
Dario Rexin
95e0a79f06 Merge pull request #77060 from drexin/wip-138074648
[IRGen] Properly handle ObjC class existentials in CVW generation
2024-10-17 14:12:31 -07:00
Augusto Noronha
17926e78fa Merge pull request #77038 from augusto2112/stop-spare-bits-debug
[DebugInfo] Stop emitting spare bits mask in debug info
2024-10-17 10:41:28 -07:00
swift-ci
70ece60b69 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 10:11:01 -07:00