Commit Graph

2441 Commits

Author SHA1 Message Date
Erik Eckstein
04e0907ab0 SIL: rename Type.instanceTypeOfMetatype -> Type.loweredInstanceTypeOfMetatype
The same for SILType

It needs to be made clear that this is not the "original", but the lowered SIL type.

NFC
2024-07-29 17:33:36 +02:00
Andrew Trick
3316a58ba7 Allow move_value of trivial values.
Required for SIL level local variable scopes.
2024-07-26 08:27:31 -07:00
Andrew Trick
075d3a42c1 Add SILValue::isFromVarDecl utility. 2024-07-26 08:27:31 -07:00
Konrad `ktoso` Malawski
eb675c222e [Distributed] Correct tbd handling for distributed thunks (#74935) 2024-07-26 16:52:18 +09:00
Nate Chandler
cfdbd992cd [Test] Underscored instruction_move_before.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:25 -07:00
Nate Chandler
47a874a322 [Test] Underscored is_lexical.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:25 -07:00
Nate Chandler
bf65f21cc8 [Test] Underscored is_sil_trivial.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
d6071c636b [Test] Underscored get_ownership_kind.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Becca Royal-Gordon
7dd8914d88 Merge pull request #75431 from beccadax/objcimpl-private-property 2024-07-24 10:46:26 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Becca Royal-Gordon
9cffd4528d Fix objcImpl SILGen crash with initial value
The initial value expressions of stored properties in objcImpl classes were being incorrectly marked as serializable. As a result, the compiler would crash with a SIL verification failure if one of them called a non-public function or initializer.

Fix this problem by not marking these initial value expression functions as serializable. Code in other modules should not call them anyway, since they think of the class as a pure ObjC class.

Fixes rdar://114874429.
2024-07-23 16:17:30 -07:00
Mykola Pokhylets
816d62c972 Merge remote-tracking branch 'upstream/main' into mpokhylets/isolated-deinit
# Conflicts:
#	include/swift/Basic/Features.def
#	lib/SILGen/SILGenDestructor.cpp
#	test/Concurrency/flow_isolation.swift
#	test/abi/macOS/arm64/concurrency.swift
#	test/abi/macOS/x86_64/concurrency.swift
2024-07-11 13:11:59 +02:00
Mykola Pokhylets
485965a759 Reviewed code comments. Fixed typos and addressed some TODOs 2024-07-11 13:09:06 +02:00
Mykola Pokhylets
28a06feaad Added isolated deallocator to TBDGen 2024-07-11 13:09:06 +02:00
Mykola Pokhylets
d7248e3acf Fixed linkage logic for isolated deallocating deinit 2024-07-11 13:09:06 +02:00
Mykola Pokhylets
d4e449b62d SILGen for isolated deinit 2024-07-11 13:09:05 +02:00
Mykola Pokhylets
b189495518 Introduced isolated deinit as a SIL entity 2024-07-11 13:09:05 +02:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Meghana Gupta
154989463b Add support for lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
3fcda140bb AST: ModuleDecl::checkConformance() is a static method 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
nate-chandler
04debd3536 Merge pull request #74922 from nate-chandler/lifetime-completion/20240701/1
[LifetimeCompletion] Flag ends synthesized in dead-ends.
2024-07-04 00:23:57 -07:00
Nate Chandler
b150a484f2 [SIL] Add dead_end flag to dealloc_box. 2024-07-03 15:26:59 -07:00
Nate Chandler
a8cc3bfdda [SIL] Add dead_end flag to destroy_value. 2024-07-03 15:26:59 -07:00
Nate Chandler
91fe12aab4 [NFC] SIL: Typed debug_value.poisonRefs. 2024-07-03 14:53:30 -07:00
Meghana Gupta
12484ff919 Merge pull request #74842 from meg-gupta/addopenpackedgecase
Fix isTriviallyDuplicatable to handle open_pack_element
2024-07-01 10:53:53 -07:00
Meghana Gupta
5282194682 Fix isTriviallyDuplicatable to handle open_pack_element
SILInstruction::clone doesn't know how to clone instructions that produce
the archetype uuid. SILCloner is equipped to handle such instructions.

Optimizations like LoopRotate use  SILInstruction::clone and will be
incorrect for such instructions.

rdar://130047619
2024-06-29 13:42:05 -07:00
Ben Barham
d8f381e660 Merge pull request #74804 from bnbarham/rename-equals
Update `StringRef::equals` references to `operator==`
2024-06-28 11:22:20 -07:00
Ben Barham
d72f5b12c4 Update StringRef::equals references to operator==
`equals` has been deprecated upstream, use `operator==` instead.
2024-06-27 19:14:06 -07:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
Erik Eckstein
655494495e use the new ASSERT macro for two asserts which should also fire in a release-built compiler 2024-06-27 09:49:29 +02:00
Joe Groff
636a19d11b Merge pull request #74707 from jckarter/consume-during-borrow-checks
MoveOnlyAddressChecker: More robust checking for consume-during-borrow.
2024-06-26 08:22:04 -07:00
Joe Groff
27a8852290 MoveOnlyAddressChecker: More robust checking for consume-during-borrow.
- While an opaque borrow access occurs to part of a value, the entire scope of
  the access needs to be treated as a liveness range, so add the `EndAccess`es
  to the liveness range.
- The SIL verifier may crash the compiler on SILGen-generated code when the
  developer's source contains consume-during-borrow code patterns. Allow
  `load_borrow` instructions to be marked `[unchecked]`, which suppresses
  verifier checks until the move checker runs and gets a chance to properly
  diagnose these errors.

Fixes rdar://124360175.
2024-06-25 14:10:02 -07:00
Erik Eckstein
718ea4b018 replace require with the new ASSERT macro 2024-06-25 10:45:55 +02:00
Michael Gottesman
f781ad366d [sending] Compensate in SILGen for a typechecker bug where we do not properly mark actor isolated async closures passed to an inheritActorContext argument as being Sendable.
The reason why I am fixing this is that otherwise, we get a warning when one
creates an actor isolated closure and pass it into a task, e.x.:

```swift
@MainActor func test() {
  // We would get a warning on the closure below saying that we are sending
  // a closure that is MainActor isolated.
  Task {
    ...
  }
}
```
2024-06-21 02:24:03 -07:00
Tim Kientzle
598e5104ef Merge pull request #74184 from tbkka/tbkka-assertions2
Add `#include "swift/Basic/Assertions.h"` to a lot of source files
2024-06-20 12:13:28 -07:00
Joe Groff
f6cfa083af Merge pull request #74525 from jckarter/sil-function-type-typed-throws-substitution
Include error type when considering whether a SILFunctionType needs its substitutions.
2024-06-20 10:36:44 -07:00
Ellie Shin
24652007af Merge pull request #74531 from apple/elsh/static-witness-linker-workaround
[PackageCMO] Workaround for static witness thunk linker issue.
2024-06-18 21:23:46 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Ellie Shin
c94ba2568a [PackageCMO] Workaround for static witness thunk linker issue.
PR #74468 rolled back conformance serialized kind to IsNotSerialized
for non-public decls. This caused static witness thunks to be
removed while use site expects them, causing linker issues.
This PR provides a workaround until a proper fix is made.

rdar://130103572
2024-06-18 16:23:05 -07:00
Slava Pestov
cb1605f26f Merge pull request #74414 from slavapestov/pack-element-var
SIL: Fix lowering for 'var's whose types contain local archetypes
2024-06-18 17:14:50 -04:00
Joe Groff
11df4fa1c3 Include error type when considering whether a SILFunctionType needs its substitutions.
Fixes rdar://128205122.
2024-06-18 09:56:51 -10:00
Slava Pestov
e4d6108e11 SIL: Fix lowering for 'var's whose types contain local archetypes
A mutable 'var' becomes a SILBoxType, and we need to plumb the
correct generic signature through here too.

Fixes https://github.com/apple/swift/issues/71921.
2024-06-18 11:45:41 -04:00
Ellie Shin
534c35b08b [PackageCMO] Optimize witness thunks.
- Keep witness thunk linkage private for a package protocol member in SILGen.
- Optimize private/hidden functions during Package CMO; if they don't contain
references that have private/hidden symbols, serialize them and set the linkage
to shared. For unserialized witness thunks, set the linkage to package, so the
witness table itself can be serialized.
- Update witness table and vtable serialization.

Resolves rdar://129976582
2024-06-17 13:06:46 -07:00
Ellie Shin
32a24f9264 Merge pull request #74416 from apple/elsh/pcmo-global
[PackageCMO] Global var and accessor linkage should be kept private/hidden in SILGen.
2024-06-14 12:21:01 -07:00
eeckstein
64962dca02 Merge pull request #74419 from eeckstein/release-asserts
SIL: enable some SIL linkage related asserts in release builds
2024-06-14 17:18:23 +02:00
Konrad `ktoso` Malawski
2ec717b115 [Concurrency] TaskExecutor ownership fixes (#74000) 2024-06-14 22:56:33 +09:00
Erik Eckstein
532535faad SIL: enable some SIL linkage related asserts in release builds
To catch wrong linkage bugs with a release-built compiler

related to rdar://129318806
2024-06-14 11:55:14 +02:00
Ellie Shin
0a734c2a62 [PackageCMO] Global var and accessor linkage should be kept private/hidden in SILGen.
This PR contains changes that ensure the following:
* Global accessor linkage is kept hidden if its decl is resilient.
  - LinkageLimit::Never is returned for Global Accessor if its decl is resilient.
  - Since it's kept hidden, the use site should not expect a call to a global accessor
    if the static var decl being accessed is resilient. The bypassing resilience logic
    in AbstractStorageDecl::isResilient(accessingModule, decl) has been removed; to be
    addressed in Package CMO optimization pass.
* sil_global linkage is kept private if its decl is resilient.

Resolves rdar://129829925
2024-06-14 01:34:34 -07:00