Commit Graph

2864 Commits

Author SHA1 Message Date
Michael Gottesman
39d3264237 [move-only] Make sure that when the borrow to destructure transform emits an error, we clean up the IR appropriately.
This ensures we appropriately eliminate mark_must_check if we error and change
copy_value -> explicit_copy_value.
2023-01-31 15:24:17 -08:00
Meghana Gupta
082750c605 Don't eliminate begin_access [signed] in AccessMarkerElimination 2023-01-31 00:47:26 -08:00
swift-ci
0b49ac49d7 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-29 10:33:27 -08:00
John McCall
b4e1e52553 Merge pull request #63292 from rjmccall/lower-pack-types
Explicitly lower value pack and parameter expansion types in SIL
2023-01-29 13:16:08 -05:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00
swift-ci
c063f50956 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-28 15:14:03 -08:00
nate-chandler
107d8ffe48 Merge pull request #63276 from nate-chandler/rdar104635319
[CanonicalOSSALifetime] Respect access scope on flag.
2023-01-28 15:08:04 -08:00
Nate Chandler
4f845ccc52 [CanOSSALifetime] Option to shrink to scopes.
For most uses, some access scopes must be "respected"--if an extended
value's original lifetime originally extends beyond an access scope, its
canonicalized lifetime must not end _within_ such scopes (although
ending before them is fine).  Currently, to be conservative, the utility
applies this behavior to all access scopes.

For move-only values, however, lifetimes end at final consumes without
regard to access scopes.

Allow this behavior to be controlled by whether or not a
NonLocalAccessBlockAnalysis is provided to the utility in its
constructor.

rdar://104635319
2023-01-28 10:23:22 -08:00
swift-ci
412bb74720 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-27 23:33:02 -08:00
Michael Gottesman
0b4e539a72 Merge pull request #63268 from gottesmm/pr-9e995e89bf43792f8053330f3d07ca04212834fc
[move-only] In the address checker, make sure that load [copy] of copyable fields are not considered loads that need to be consumed.
2023-01-27 23:29:46 -08:00
swift-ci
76fa1bbe0d Merge remote-tracking branch 'origin/main' into rebranch 2023-01-27 17:34:12 -08:00
Michael Gottesman
c9ce3a9722 Merge pull request #63270 from gottesmm/pr-58e55bb70e30107d86e3c437c972c9f0adbce7b4
[move-only] Rather than calling the borrow to destructure transform from the MoveOnlyObjectChecker, make its own pass.
2023-01-27 17:18:21 -08:00
Michael Gottesman
96140ddfe9 [move-only] Rather than calling the borrow to destructure transform from the MoveOnlyObjectChecker, make its own pass.
This is a cleaner separation of concerns. The reason why I did not do this
originally is that I thought I would need to reuse this functionality in the
address checker, but this issue actually does not come up there since we project
the address and then load instead of load and then project.
2023-01-27 14:23:53 -08:00
Michael Gottesman
66df502c0d [move-only] In the address checker, make sure that load [copy] of copyable fields are not considered loads that need to be consumed.
Just something I have been meaning to fix for a little bit.

rdar://104753490
2023-01-27 13:49:13 -08:00
Michael Gottesman
3a538282ff [consume-operator] Rename checker passes to have ConsumeOperator in the name to reduce confusion with MoveChecking passes.
Just trying to eliminate potential confusion.
2023-01-27 13:46:32 -08:00
swift-ci
688d6d7b36 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-27 00:14:44 -08:00
Michael Gottesman
f85430f999 Merge pull request #63255 from gottesmm/pr-f6f932ba70eaa205c45042884148ff1033d9a416
[move-only] Make sure that we insert compensating destroys for phi values
2023-01-27 00:02:00 -08:00
Michael Gottesman
97f742d4cb [move-only] Make sure that we insert compensating destroys for phi values.
rdar://104726000
2023-01-26 19:38:47 -08:00
swift-ci
58a514b85b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-26 18:34:13 -08:00
nate-chandler
2fc7659ed7 Merge pull request #60670 from nate-chandler/lexical_lifetimes/owned_arguments
[SIL] Maintain owned argument lifetimes at inlining.
2023-01-26 18:30:24 -08:00
swift-ci
0ae72a3a9d Merge remote-tracking branch 'origin/main' into rebranch 2023-01-26 07:34:09 -08:00
Michael Gottesman
89176928ee Merge pull request #63213 from gottesmm/rdar103271138
[move-only] Implement borrow+struct_extract to restructure transform
2023-01-26 07:19:10 -08:00
swift-ci
df75f6ee09 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-25 22:33:52 -08:00
swift-ci
281088eb73 Merge pull request #63204 from meg-gupta/ptrauthcodegenpr
Initial support for ptrauth qualified function pointers in C
2023-01-25 22:19:34 -08:00
swift-ci
7658ad805e Merge remote-tracking branch 'origin/main' into rebranch 2023-01-25 20:14:42 -08:00
Anthony Latsis
f5c7e4f09e Merge pull request #62684 from valeriyvan/AddressLowering 2023-01-26 07:05:13 +03:00
swift-ci
e0b16dbdf4 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-25 16:07:15 -08:00
Michael Gottesman
885eb21d37 [noimplicitcopy] Changes to borrow+gep -> destructure transform to support noimplicitcopy. 2023-01-25 14:55:52 -08:00
Meghana Gupta
ba052abec1 Add signed access enforcement to begin_access
This will be used for supporting imported c function pointers with custom __ptrauth qualifier.
2023-01-25 14:03:15 -08:00
Nate Chandler
11b76da7fa [OME] Lower move_value to a noop. 2023-01-25 11:39:42 -08:00
Nate Chandler
6f22e43eb5 [MandatoryInlining] Strip all ownership insts.
Previously, just copies and borrows were stripped.  All ownership
instructions, specifically, newly, move_value instructions, should be
stripped.
2023-01-25 11:36:33 -08:00
Valeriy Van
55c3759ef6 Merge identical cases of switch 2023-01-25 20:16:13 +02:00
Andrew Trick
5d0fbaad5c Merge pull request #63210 from atrick/cleanup-prunedliveness
Cleanup PrunedLiveness interface.
2023-01-25 10:13:43 -08:00
Erik Eckstein
7d8bf37e5e change to the new llvm::Optional APIs
This is a follow-up of https://github.com/apple/swift/pull/62217
2023-01-25 09:18:36 +01:00
Andrew Trick
7990dda02b Cleanup PrunedLiveness interface.
In preparation for adding OwnershipLiveness.

Rename Simple LiveRangeSummary to LiveRangeSummary.

Add initializeDefNode helpers to avoid confusion about the argument
type.

Add defBegin/defEnd iterators in MultiDefPrunedLiveness.
2023-01-24 23:26:40 -08:00
Michael Gottesman
6f940b4c4f [move-only] Implement the borrow-gep to destructure transform.
This enables us to emit the appropriate error for consuming uses of fields and
also causes us to eliminate copies exposed by using fields of a move only type
in a non-consuming way.

rdar://103271138
2023-01-24 16:56:11 -08:00
swift-ci
e8faa652bd Merge remote-tracking branch 'origin/main' into rebranch 2023-01-16 04:54:42 -08:00
Max Desiatov
0812484a4a SILOptimizer: remove unused variables and fields (#63018)
Exact warning text:
```
swift/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp:3239:12: warning: variable 'NumMemoryElements' set but not used [-Wunused-but-set-variable]
  unsigned NumMemoryElements = TheMemory.getNumElements();
           ^
1 warning generated.
```
2023-01-16 12:53:07 +00:00
swift-ci
26aac9a2e5 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-13 19:36:02 -08:00
Andrew Trick
058c03ec23 Fix an unused variable warning in AccessEnforcementSelection 2023-01-13 08:55:16 -08:00
swift-ci
bafd157ddf Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:20:12 -08:00
Erik Eckstein
712fd7922b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:48:47 +01:00
Michael Gottesman
1c459b6c5b [move-only-addr] Wire up the move only address checker to Field Sensitive Pruned Liveness Boundary.
This let me fix an issue around hoisting destroy_addr/store [assign] when
working in multi-block cfgs.

I also added some .sil tests.
2023-01-08 21:51:40 -08:00
Michael Gottesman
8e0aeffe62 [move-only-object] Make sure that we also convert copy_value -> explicit_copy_value for pure move only values along side no implicit copy values. 2023-01-08 14:03:52 -08:00
swift-ci
0c6253ebd2 Merge pull request #61824 from meg-gupta/simplifycfgossapr1
Update some parts of SimplifyCFG for OSSA
2023-01-08 03:07:46 -08:00
Meghana Gupta
5d2967ca75 Fix SimplifyCFG::simplifySwitchEnumOnObjcClassOptional for OSSA 2023-01-08 00:15:17 -08:00
Michael Gottesman
5bd2725c23 [basic] Add an operator<<(llvm::raw_ostream &os, const SmallBitVector &) implementation.
For some reason LLVM doesn't provide this. I have written a few versions of this
in the Swift codebase. Makes sense to factor it out before I make another one.
2023-01-06 20:57:39 -08:00
Nate Chandler
356f2b78db [AddressLowering] Added TODO. 2023-01-04 07:54:02 -08:00
Nate Chandler
b3ee1fdc34 [AddrLowering] Copy for out-of-range owned stores.
Skip the store-copy optimization if the store instruction occurs outside
the lifetime of the value being copied.
2023-01-04 07:49:37 -08:00
Nate Chandler
2a81238b88 [AddrLowering] Copy for out-of-range guar stores.
When a copy_value's only use is a store, in some cases, as an
optimization, creating a copy_addr can be skipped.  Whether a value is
such a copy_value is determined by the isStoreCopy predicate.

If the operand of the copy_value is a guaranteed value and any of its
guaranteed roots have live ranges which the store is outside of, skip
this optimization and create the copy_addr.
2023-01-04 07:47:54 -08:00