Commit Graph

12816 Commits

Author SHA1 Message Date
Dario Rexin
e6d282f5e2 [IRGen] Fix symbol generation for getEnumTag function for layout strings (#66845)
The type needs to be cleaned up to prevent issues with mangling when it contains archetypes
2023-06-22 07:58:28 -07:00
Egor Zhdan
e064d23d74 Merge pull request #66764 from apple/egorzhdan/cxx-set-insert
[cxx-interop] Allow inserting elements into `std::set` from Swift
2023-06-22 15:26:57 +01:00
Doug Gregor
d3ce40157e Merge pull request #66837 from DougGregor/macro-visit-all-members 2023-06-21 21:34:42 -07:00
Doug Gregor
e306c11a22 [Macros] Ensure that we visit *all* members when emitting memberwise initializer
Fixes rdar://111122261.
2023-06-21 16:12:11 -07:00
Slava Pestov
3676379302 Merge pull request #66814 from slavapestov/variadic-type-conditional-conformance
Conditional conformances for variadic generic types
2023-06-21 17:52:28 -04:00
Meghana Gupta
03b8c49371 Merge pull request #66645 from meg-gupta/mixinremovesmall
Simplify forwarding instruction definitions in SIL
2023-06-21 13:02:13 -07:00
Slava Pestov
c84a14fdc1 IRGen: Conditional conformances for variadic types 2023-06-21 13:42:57 -04:00
Dario Rexin
493a25faae [IRGen+Runtime] Add layout string support for generic single payload enums (#66791) 2023-06-20 20:46:54 -07:00
Andrew Savonichev
31e4465cd1 [DebugInfo] Merge fragments from SIL with fragments created in IRGen (#66448)
SIL variables can be split by SILSROA into separate allocations, each having
op_fragment expressions in debug_value (VarInfo.DIExpr). These allocations can
be further split by IRGen (multiple values in Storage argument).

These "nested" fragments refer to the same DI variable, so it is important to
merge them for the LLVM IR DI expression. The compiler used to ignore fragment
expressions from SIL when IRGen fragments were also present. This led to
incorrect DI info generation, and for some cases even triggered assertions in
LLVM X86 CodeGen:

  DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const
  llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits &&
  "overlapping or duplicate fragments"' failed.

The patch fixes issue #64642. The LIT test is a reduced reproducer from that issue.
2023-06-20 11:37:29 -07:00
Egor Zhdan
b79b65c056 [cxx-interop] Allow inserting elements into std::set from Swift
`std::set::insert` isn't exposed into Swift, because it returns an instance of an unsafe type.

This change adds a Swift overload of `insert` for `std::set` and `std::unordered_set` that has the return type identical to `Swift.Set.insert`: a tuple of `(inserted: Bool, memberAfterInsert: Element)`.

rdar://111036912
2023-06-20 16:56:54 +01:00
Rauhul Varma
2a7895757c Merge pull request #66072 from apple/platform-ccc
Add frontend flag for explicitly setting ccc
2023-06-18 18:32:34 -07:00
Dario Rexin
874b577280 [IRGen] Use EnumImplStrategy to generate getEnumTag function for layo… (#66707)
* [IRGen] Use EnumImplStrategy to generate getEnumTag function for layout strings

rdar://110794898

The implementation in TypeLayout seems to have a bug causing wrong tags to be returned on 32 bit systems.

* Don't use unsupported types in tests
2023-06-16 18:14:48 -07:00
Rauhul Varma
cc0ea25664 Fixup silly compilation errors 2023-06-15 23:27:21 -07:00
Rauhul Varma
6b9fb171bf Address rewview feedback
- Renames ExperimentalPlatformCCallingConvention to
  PlatformCCallingConvention.
- Removes non-arm calling convention support as this feature is working
  around a clang bug for some arm triples which we hope to see resolved.
- Removes misleading MetaVarName from platform-c-calling-convention
  argument.
- Replaces other uses of LLVM::CallingConv::C with
  IGM.getOptions().PlatformCCallingConvention().
2023-06-15 22:06:43 -07:00
Rauhul Varma
19f74e22e6 Add frontend flag for explicitly setting ccc
Adds a new swift-frontend flag to allow users to choose which calling
convention is used to make c function calls. This hidden flag is called
`-experimental-platform-c-calling-convention`.

This behavior is needed to workaround rdar://109431863 (Swift-frontend
produces trapping llvm ir for non-trapping sil). The root cause of this
issue is that IRGen always emits c function calls with llvm's default C
calling convention. However clang may select a different (incompatible)
calling convention for the function, eventually resulting--via
InstCombine and SimplifyCFG--in a trap instead of the function call.
This failure mode is most readily seen with the triple
`armv7em-apple-none-macho` when attempting to call functions taking
struct arguments. Example unoptimized ir below:

```llvm-ir
call void @bar([4 x i32] %17, i32 2), !dbg !109
...
define internal arm_aapcs_vfpcc void @bar(
  [4 x i32] %bar.coerce, i32 noundef %x)
```

In the future it would be better to use the clang importer or some other
tool to determine the calling convention for each function instead of
setting the calling convention frontend invocation wide.

Note: I don't know for sure whether or not clang should be explicitly
annotating these functions with a calling convention instead of
aliasing C to mean ARM_AAPCS_VFP for this particular combination of
`-target`, `-mfloat-abi`, and `-mcpu`.
2023-06-15 21:52:03 -07:00
swift_jenkins
2b8f6b4283 Merge remote-tracking branch 'origin/main' into next 2023-06-15 18:48:12 -07:00
swift-ci
14f71614e5 Merge pull request #66682 from adrian-prantl/109173022
Replace hardcoded special names with call into getUserfacingName()
2023-06-15 18:43:01 -07:00
swift_jenkins
c3773953d1 Merge remote-tracking branch 'origin/main' into next 2023-06-15 17:38:08 -07:00
Adrian Prantl
229ad8ba84 Replace hardcoded special names with call into getUserfacingName()
This fixes an assertion failure when encountering previously unhandled special names.

rdar://110841130
2023-06-15 13:24:59 -07:00
Arnold Schwaighofer
5d5dbd98a4 Merge pull request #66077 from aschwaighofer/wip_enable_opaque_pointers
Enable usage of LLVM's opaque pointer
2023-06-15 11:47:24 -07:00
Meghana Gupta
16c300c2af Remove OwnershipForwardingConversionInst, ConversionInst.
Add new ConversionOperation abstraction, use this in place of ConversionInst
2023-06-15 10:53:28 -07:00
swift_jenkins
58405706d9 Merge remote-tracking branch 'origin/main' into next 2023-06-14 20:15:58 -07:00
Dario Rexin
d74c085fe8 [Runtime+IRGen] Add layout string support for generic singleton enums (#66647) 2023-06-14 20:13:15 -07:00
Arnold Schwaighofer
0d4dec1acb Attempt to fix debug info under opaque pointers
Based on https://github.com/apple/swift/pull/66409

With the observation that the pre-opaque world was using bitcast as an
indication that the storage type and the type of the variable were
different. We can recover this information from the storage type of the
alloca and the storage type of the type info.
2023-06-14 10:49:50 -07:00
Arnold Schwaighofer
e6d070dfd8 Try to only remove comdata if the global is a declaration 2023-06-14 10:49:50 -07:00
swift_jenkins
651c7df94d Merge remote-tracking branch 'origin/main' into next 2023-06-14 09:43:11 -07:00
Dario Rexin
8b48a0d3e0 [Runtime+IRGen] Instantiate layout strings for generic multi payload enum (#66621)
Instantiating layout strings for generic types reduces code size and is expected to improve performance of generic value witnesses.
2023-06-14 09:31:11 -07:00
swift_jenkins
08557bb2b4 Merge remote-tracking branch 'origin/main' into next 2023-06-13 21:24:53 -07:00
Meghana Gupta
5d401fb70a Remove select_value SIL instruction 2023-06-13 14:13:43 -07:00
swift_jenkins
5fd5beaf55 Merge remote-tracking branch 'origin/main' into next 2023-06-12 09:21:54 -07:00
Arnold Schwaighofer
2db4a038c3 Merge pull request #66507 from aschwaighofer/fix_some_globals
IRGen: alloc_global and global_addr instructions need to agree on the storage
2023-06-12 09:15:24 -07:00
swift_jenkins
5963c55ce5 Merge remote-tracking branch 'origin/main' into next 2023-06-09 20:22:59 -07:00
Michael Gottesman
b2a52ff036 [move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen.
SIL Functions are serialized in canonical SIL before they have their final ABI
adjusted for large function arguments. Large function argument ABI is adjusted
to be indirect as part of the transition from canonical SIL to lowered SIL. This
means that if we deserialize a function from another module in canonical SIL and
attempt to call it in IRGen we will call it with the wrong ABI implying if we
reference any fields of the type in the deinit we will most likely crash (among
other potential issues).

This patch fixes the issue by changing IRGen to not lazily deserialize the
moveonly deinit table and its associated functions. Instead if we do not have
our table already deserialized, we just call the function's deinit via the
destroy value deinit table.

rdar://110496872
2023-06-09 15:41:38 -04:00
Arnold Schwaighofer
b6e9c8e51c IRGen: alloc_global and global_addr instructions need to agree on the storage
If the storage is opaque we need to project to the underlying buffer.

rdar://109636344
2023-06-09 11:37:50 -07:00
swift_jenkins
39a5534b52 Merge remote-tracking branch 'origin/main' into next 2023-06-08 16:56:10 -07:00
Alex Lorenz
138def7627 Merge pull request #65922 from hyp/eng/excp-cons-spec
[cxx-interop] evaluate default constructor's unevaluated exception sp…
2023-06-08 15:35:23 -07:00
Alex Lorenz
b0dab0b48c [cxx-interop] evaluate default constructor's unevaluated exception spec if needed when emitting C++ constructor call
Fixes https://github.com/apple/swift/issues/65891
2023-06-08 11:02:29 -07:00
Hamish Knight
4ce0bd0a2e NFC: Disable clang-format for inline bitfields
clang-format tries to impose the wrong formatting
on these, so let's disable it for these blocks.
2023-06-08 18:26:34 +01:00
swift_jenkins
55a12e91d1 Merge remote-tracking branch 'origin/main' into next 2023-06-07 08:18:30 -07:00
Pavel Yaskevich
274a43b040 Merge pull request #66283 from xedin/init-accessors
[Parse/Sema/SIL] Implementation of init accessors feature (under a flag)
2023-06-07 08:16:35 -07:00
swift_jenkins
7de95c65e9 Merge remote-tracking branch 'origin/main' into next 2023-06-07 02:47:00 -07:00
Dario Rexin
fe6f8f5404 [IRGen] Implement support for multi payload enums in layout strings (#66354)
* [IRGen] Implement support for multi payload enums in layout strings

rdar://105837114

* Implement multi payload enum cases in swift_resolve_resilientAccessors

* Add missing const
2023-06-06 23:51:57 -07:00
Holly Borla
ac66a06199 [SIL] Add a new AssignOrInit instruction for init accessors.
This instruction is similar to AssignByWrapperInst, but instead of having
a destination operand, the initialization is fully factored into the init
function operand. Like AssignByWrapper, AssignOrInit has partial application
operands of both the initializer and the setter, and DI will lower the
instruction to a call based on whether the assignment is initialization or
a setter call.
2023-06-06 18:59:10 -07:00
Holly Borla
684ef9c482 [AST] Add a new accessor kind for init accessors. 2023-06-06 18:57:31 -07:00
Michael Gottesman
29672c503a Merge pull request #66381 from gottesmm/noimplicitcopy-borrow-consuming
[borrowing/consuming] Make borrowing and consuming parameters no implicit copy.
2023-06-06 21:41:18 -04:00
Slava Pestov
c30f7dcdd8 Merge pull request #66096 from slavapestov/pack-element-type
Preliminary support for substitution with nested pack expansions
2023-06-06 19:11:52 -04:00
swift_jenkins
2080e071be Merge remote-tracking branch 'origin/main' into next 2023-06-06 12:28:44 -07:00
Andrew Trick
4325c0ae0b Merge pull request #66314 from atrick/fix-dropdeinit
[move-only] Fix SIL representation and SILOptimizer to preserve value deinits
2023-06-06 12:09:34 -07:00
Michael Gottesman
70ab38d9da [move-only] Add a new instruction: moveonlywrapper_to_copyable_box.
I am going to use this to unwrap ${ @moveOnly T } so that I can pass it to
partial_apply that expect a ${ T }
2023-06-06 14:26:22 -04:00
Slava Pestov
be218f5e16 AST: Use PackElementType to model references to pack elements of outer expansions 2023-06-06 14:18:37 -04:00