Commit Graph

9151 Commits

Author SHA1 Message Date
Erik Eckstein
a54502aee9 MemAccessUtils: handle the obsolete allocVector builtin
This builtin was removed. But to be able to parse old Swift.swiftinterface files it is required to handle the builtin in MemAccessUtils.
2025-03-11 08:03:17 +01:00
eeckstein
737b5ec924 Merge pull request #79674 from eeckstein/simplify-open-existential-metatype
Optimizer: Rework peephole optimizations to replace existential (archetypes) with concrete types
2025-03-10 08:18:52 +01:00
eeckstein
d2fe619696 Merge pull request #79845 from eeckstein/memory-lifetime-verifier
MemoryLifetimeVerifier: verify `inject_enum_addr`
2025-03-10 08:17:37 +01:00
eeckstein
cbba008ac3 Merge pull request #79835 from eeckstein/fix-generic-specializer
GenericSpecializer: avoid an infinite loop when looking up GenericSpecializationInformation
2025-03-10 08:15:13 +01:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
nate-chandler
c0ba520fac Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2025-03-07 20:08:42 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Erik Eckstein
8d78f75ea4 MemoryLifetimeVerifier: verify inject_enum_addr
Verify that the enum case payload is alive at the point of an inject_enum_addr
rdar://146315214
2025-03-07 19:58:53 +01:00
Erik Eckstein
810064b7dc Cleanup and additions to AST and SIL Type/CanonicalType
* factor out common methods of AST Type/CanonicalType into a `TypeProperties` protocol.
* add more APIs to AST Type/CanoncialType.
* move `MetatypeRepresentation` from SIL.Type to AST.Type and implement it with a swift enum.
* let `Builder.createMetatype` get a CanonicalType as instance type, because the instance type must not be a lowered type.
2025-03-07 15:59:33 +01:00
Erik Eckstein
aff36b056b SIL: fix cloning of keypath instruction
Don't include type-dependent operands in the argument list of the new keypath instruction.
Also enable the assert, which catches this problem, in release builds.

Fixes a compiler crash.
2025-03-07 15:09:11 +01:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Gábor Horváth
c91e295234 Merge pull request #79576 from swiftlang/gaborh/fix-consume-calling-conv
[cxx-interop] Fix calling convention for rvalue reference params
2025-03-04 02:31:49 -08:00
Meghana Gupta
cf6c4c9422 Merge pull request #79699 from meg-gupta/prboundscheck
Add support for bounds check optimization of Span and InlineArray
2025-03-03 14:32:27 -08:00
Gabor Horvath
00fa738209 [cxx-interop] Fix calling convention for rvalue reference params
In C++, we always expected to invoke the dtor for moved-from objects.
This is not the case for swift. Fortunately, @inCxx calling convention
is already expressing that the caller supposed to destroy the object.
This fixes the missing dtor calls when calling C++ functions taking
rvalue references. Fixes #77894.

rdar://140786022
2025-03-03 11:47:12 +00:00
Andrew Trick
2fe155ac30 OSSALifetimeCompletion: check liveness failure
This transformation is invalid without complete liveness. Add a release assert
to check this. Temporarily hide the assert under -verify-lifetime-completion
until the passes that use this utility are fixed to check escapes.
2025-03-02 23:51:34 -08:00
Andrew Trick
d73a081fe7 Add pointer escape and dependent use tracking to InteriorLiveness
Rig TransitiveAddressWalker to keep track of enough information for passes to
correctly check for pointer escapes and dependence uses. Requires for precise
bail-outs and asserts.
2025-03-02 23:51:34 -08:00
Meghana Gupta
2b072a56c1 Allow duplicating mark_dependence [nonescaping] on addresses 2025-02-28 17:11:59 -08:00
Meghana Gupta
9ce8bb3682 Add a new abstraction FixedStorageSemanticsCall 2025-02-28 09:50:58 -08:00
nate-chandler
30d91d39bf Merge pull request #79625 from nate-chandler/general-coro/20250212/1
[CoroutineAccessors] Use retcon.once variant.
2025-02-27 12:58:49 -08:00
Nate Chandler
dd8cbe3e0a [CoroutineAccessors] Use retcon.once variant.
Allocate a coroutine frame in the caller based on the size in the
corresponding "function pointer" and pass it along with an allocator to
the callee.
2025-02-27 07:53:58 -08:00
Slava Pestov
541757a491 AST: Remove TypeBase::isOpenedExistential()
At one point, OpenedArchetypeType did not exist as a separate subclass
of ArchetypeType, so this method did something. Now, it's just
equivalent to calling is<> or isa<>.

I also removed a couple of asserts that were obvious no-ops as a result.
2025-02-27 09:55:36 -05:00
Andrew Trick
edcaecc09d Fix BorrowedValue::visitInteriorPointerOperandHelper
to handle borrowed-from (as a ForwardingInstruction).
2025-02-25 23:08:55 -08:00
Andrew Trick
5f8b93c66a Fix interior liveness to report the escaping instruction as a use. 2025-02-25 23:08:55 -08:00
Andrew Trick
f29bb44d07 OwnershipUseVisitor::visitInnerBorrowUses: support dependent values
Add liveness support for dependent values: borrowed-from & mark_dependence so
they aren't reported as unknown uses.

Centralize the logic in BorrowingOperand::getScopeIntroducingUserResult
and BorrowingOperand::getDependentUserResult().
2025-02-25 23:08:55 -08:00
Andrew Trick
e8af00769e Remove adjacent phis from OwnershipLiveness.
The extra complexity for traversing phis is not needed now that it handles
borrowed-from instructions. Remove the redundant logic because it complicates
the liveness algorithm and generates confusing results.
2025-02-25 23:08:54 -08:00
Andrew Trick
1cb4d50877 Fix BorrowingOperand::visitScopeEndingUses() invariants.
This API only makes sense for a scoped borrow-introducer such as:
- reborrow
- owned mark_dependence

Borrowing operands that forward guaranteed values do not have scope-ending uses.
2025-02-25 23:08:54 -08:00
Andrew Trick
6fa0b2ec98 Add BorrowedFromInst::isReborrow.
borrowed-from instructions have different ownership semantics if the are
attached to reborrows vs. guaranteed forwarding phis.
2025-02-25 23:08:54 -08:00
Andrew Trick
e78aa38204 Remove BorrowingOperand.getImplicitUses.
It is buggy/misleading because of dead-def handling. The current operand may be
re-pushed if it is a dead borrow scope.
2025-02-25 23:08:54 -08:00
Andrew Trick
b3a445fb55 Fix BorrowingOperand::getBorrowIntroducingUserResult()
To handle borrowing operands that produce a dependence value but do not create a
nested borrow scope. This includes non-reborrow borrowed-from and guaranteed
mark_dependence [nonescaping].
2025-02-25 23:08:54 -08:00
Andrew Trick
f1792d80b3 Fix BorrowingOperand.visitScopeEndingUses
Only return false if the visitor returns false. Clients were ignoring the
result.

If the BorrowingOperand does not create a borrow scope, call visitUnknownUse
instead.

Until we have complete lifetimes, to avoid breaking code that cannot handle dead
defs, consider a dead borrow scope to be an unknown use.
2025-02-25 23:08:54 -08:00
Andrew Trick
0871c962b5 Fix BorrowedFromInst operand ownership.
This instruction obviously borrows its base value. Liveness extends to the uses
of the result.

Code that switches on OperandOwnership assumes that an Instantaneous use does
not propagate any information that may extend liveness.
2025-02-25 23:08:54 -08:00
Alejandro Alonso
5f558fdfe0 Merge pull request #79331 from Azoy/fix-fa-tc
[SIL] Check if our original type is opaque before getting getting FixedArray element type
2025-02-25 15:22:27 -08:00
Alejandro Alonso
a34fb387eb Always use an opaque AP for inline array elements 2025-02-25 09:28:34 -08:00
nate-chandler
468371fe55 Merge pull request #79586 from nate-chandler/rdar145035291
Check file type better in this verifier.
2025-02-25 08:12:47 -08:00
Usama Hameed
500187cf1e Add support for serializing debug_value instructions (#78056)
This patch adds support for serialization of debug value instructions. Enablement is currently gated behind the -experimental-serialize-debug-info flag.

Previously, debug_value instructions were lost during serialization. This made it harder to debug cross module inlined functions.
2025-02-24 20:21:15 -08:00
Nate Chandler
d1f89ea260 Check file type better in this verifier.
Ask the decl directly whether its source file is a sil source file.
2025-02-24 12:50:00 -08:00
Konrad `ktoso` Malawski
09003d6f11 Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d2604f.
2025-02-23 22:59:21 -08:00
Shubham Sandeep Rastogi
51ff672fec Merge pull request #79519 from rastogishubham/SILPrintImplicit
The option -sil-print-debuginfo-verbose will print the values of the fields, implicit, and autoGenerated for a SILLocation, as well as whether the SILLocation is considered hidden from debug information by calling SILLocation::isHiddenFromDebugInfo()

This will help tremendously when figuring out why debug information got lost.
2025-02-22 08:52:28 -08:00
Pavel Yaskevich
520c05b1b8 Merge pull request #79508 from xedin/feature-proof-execution-attrs
[Frontend] Rename `NonIsolatedAsyncInheritsIsolationFromContext` feature and add a feature for `@execution`
2025-02-21 09:07:04 -08:00
Konrad `ktoso` Malawski
4ab5d2604f Merge pull request #77609 from ktoso/wip-task-names
[Concurrency] Task names
2025-02-21 22:28:33 +09:00
Shubham Sandeep Rastogi
15673867d3 Add option -sil-print-debuginfo-verbose
The option -sil-print-debuginfo-verbose will print the values of the
fields, implicit, and autoGenerated for a SILLocation, as well as
whether the SILLocation is considered hidden from debug information
by calling SILLocation::isHiddenFromDebugInfo()
2025-02-20 09:57:02 -08:00
Pavel Yaskevich
e2ff3308be [Frontend] NFC: Rename NonIsolatedAsyncInheritsIsolationFromContext feature
New name is `AsyncCallerExecution` as stated by the proposal.
2025-02-19 20:00:56 -08:00
Michael Gottesman
3ef18eaf1d Merge pull request #79300 from gottesmm/pr-12bede947a34719b34b1aa8ea6c126a6126d6dd6
[concurrency] Implement serialization for execution(caller)/execution(concurrent).
2025-02-19 18:29:02 -08:00
Allan Shortlidge
e8329d292b Parse: Avoid including DiagnosticsParse.h in Parser.h.
This prevents the include of DiagnosticsParse.h from leaking into `.cpp` files
in libraries besides Parse.
2025-02-19 07:56:38 -08:00
Joe Groff
f778170cfb Merge pull request #79351 from jckarter/lifetime-dependence-lowering
SIL: Lower lifetime dependencies when lowering function types.
2025-02-17 07:51:20 -08:00
Joe Groff
c65475628f SIL: Lower lifetime dependencies when lowering function types.
Map the lifetime dependencies described in terms of the formal AST-level parameters
to the correct parameter(s) in the lowered SIL function type. There can be 0, 1,
or many SIL parameters per formal parameter because of tuple exploding. Also,
record which dependencies are on addressable parameters (meaning that the dependency
includes not only the value of the parameter, but its specific memory location).
2025-02-14 09:47:53 -08:00
Doug Gregor
2989770cd6 Merge pull request #79352 from DougGregor/strict-sendable-metatypes
Add StrictSendableMetatypes to require Sendable requirements on metatypes
2025-02-14 03:40:36 -08:00
Meghana Gupta
cf22bced31 Merge pull request #79315 from meg-gupta/typevaluecse
Add CSE support for type_value instruction and add a few bounds check tests for InlineArray
2025-02-13 20:54:26 -08:00