23 Commits

Author SHA1 Message Date
Michael Gottesman
e0fdce1fa3 [region-isolation] Convert TransferringOperand to be a bump allocated ptr type from a pointer type.
I need to start tracking the dynamic IsolationRegionInfo for the transferring
operand so I can ignore uses that are part of the same
IsolationRegionInfo. IsolationRegionInfo doesn't fit into a pointer, so just to
keep things the same, I am going to just allocate it.

This is an initial staging commit that tests out the bump ptr allocating without
expanding the type yet.
2024-03-21 14:16:20 -07:00
Michael Gottesman
59cc595f7a Fix unittest 2023-12-01 15:06:51 -08:00
Michael Gottesman
12573d6b52 [region-isolation] Instead of just tracking a single transferring instruction, track all of them.
Previously I avoided doing this since the only problem would be that in a case
where we had two transfer instructions that were in an if-else block, we would
just emit an error for one:

```swift
if boolValue {
  transfer(x)
} else {
  transfer(x) // Only emit error for this transfer!
}

useValue(x)
```

Now that we are tracking at the transfer point if any element in the transfer
was captured in a closure, this becomes an actual semantic issue since if we
track the transfer instruction that isn't reachable from the closure capture, we
will not become more pessimistic:

```swift
if boolValue {
  closure = { useInOut(&x) }
  transfer(x)
} else {
  transfer(x)
}

// Since we grab from the else block, sendableField is allowed to be accessed
// since we do not track that x was captured by reference in a closure.
x.sendableField
useValue(x)
```

To be truly safe, we need to emit both errors.

rdar://119048779
2023-12-01 13:53:57 -08:00
Michael Gottesman
150efb6ef4 [immutable-ptr-set] Change data structure to use T instead of T *, but require T to conform to PointerLikeTypeTraits.
This allows one to place types like PointerIntPair and value types that wrap a
pointer into the pointer set.

I am making this change before I use this data structure in TransferNonSendable
and using ARC to validate that I haven't broken anything.
2023-12-01 13:53:57 -08:00
Evan Wilde
4105b927dd Fixing header locations and changes
This patch fixes a handful of header references that moved, or were
transitively included and aren't anymore.
2023-07-25 12:28:28 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Saleem Abdulrasool
aa4e9cb725 Basic: set the correct storage class for the alignment
`cl` objects to the initialization of the templated type differing in storage
class due to the indication of `constexpr`.  `constexpr` does not give the value
itself a `const` storage class.  However, because the value is not initialized
inline, it does not like the `constexpr` attribute.  Apply the `constexpr` only
on clang, and correct the storage to `const`.
2019-01-18 11:51:34 -08:00
Jordan Rose
8d1e234eb9 Avoid uses of incomplete types in ImmutablePointerSet.h. (#9966)
rdar://problem/32237125
2017-05-31 09:20:18 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
56dfb08727 Port swift/basic to Windows 2016-12-02 16:57:00 +00:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Dan Raviv
29d76f3b68 Canonize swift header files headers and footers
- Added missing ifdef guard in PointerIntEnum header
- Consistent naming convention for ifdef guards
- Consistent 'end namespace swift'
- Consistent single EOL at end of header files
2016-03-23 09:04:12 +02:00
Michael Gottesman
0e2dc7a930 [arc] Once we have finished an iteration of ARC, clear the ImmutablePointerSetFactory.
Previously due to the way that ARC works, it was impossible to trigger any
memory safety issues. That being said the fact that the memory safety here is
non-obvious suggests that the right thing to do is just bite the bullet and
clear the ImmutablePointerSetFactory.
2016-03-10 18:48:03 -08:00
Michael Gottesman
0612d886e9 Add a "hasEmptyIntersection" method to ImmutablePointerSet.
We do this by doing a traversal of our sorted lists in a similar manner as one
would when one is merging two such sets, i.e. one has two iterators and always
advances the iterator that has a value that is less than the other. If we ever
hit a situation where the two iterators equal, we must have a non-empty
intersection.

A unittest that exercises very basic functionality is provided as well.
2016-03-08 14:05:10 -08:00
Michael Gottesman
39b7d2aeae [arc] When we are merging an ImmutablePointerSet and an array, do a quick early check if they are equal. In such a case, we can just return S1. This helps us to avoid needing to hash anything in cases of merging two equivalent pointers. 2016-02-17 00:33:27 -08:00
Michael Gottesman
cca9ef59f1 [arc] When merging ImmutablePointerSets, since they are uniqued, we can bail early on merging the same set by just performing a pointer equality.
Just a drive by I noticed. Should improve compile time.
2016-02-16 18:04:11 -08:00
Michael Gottesman
90dcaa7de3 Rename ImmutablePointerSet::concat => ImmutablePointerSet::merge. 2016-02-16 02:13:56 -08:00
Michael Gottesman
6434e5b032 Some small fixes suggested by Jordan to ImmutablePointerSet.
The larger changes are coming in a subsequent commit.
2016-02-16 02:13:55 -08:00
Michael Gottesman
f09749791a [arc] Move some code that is STL like from ImmutablePointerSet.h -> STLExtras.h
Specifically:

1. set_union_for_each. This is like std::for_each, but it visits its inputs
(which are assumed to be sorted/uniqued sets) in set_union order.
2. is_uniqued_and_sorted.

I also fixed several nits from Jordan.
2016-02-15 14:16:05 -08:00
practicalswift
2f547e9356 [gardening] Use consistent header structure in newly introduced files 2016-02-15 16:47:48 +01:00
practicalswift
1b10113497 [gardening] Fix recently introduced typo: "concatentation" → "concatenation" 2016-02-15 09:26:04 +01:00
Michael Gottesman
0936d3d4b8 [arc] Add a new data structure called ImmutablePointerSet.
This is an immutable data structure with the following properties:

1. All of the sets are sorted and can be iterated over.
2. It takes in a bump ptr allocator and uses that allocator for all
allocations.
3. All concatenation operations involve only one bump ptr allocation.
4. Since we are only storing pointers, the data structure does not need any
destructors to be invoked to be cleaned up. The bumpptrallocator memory just
needs to be freed.

I am going to use this to improve the compile time performance of ARC.
2016-02-14 15:26:59 -08:00