Commit Graph

33 Commits

Author SHA1 Message Date
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Evan Wilde
5b40e5e50a Cast bitfields to unsigned int for optional return
Bit-fields don't convert to reference types automatically, so converting
them to unsigned int so that they can be returned in the
`std::optional`.
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
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Erik Eckstein
8ca0143279 Remove uses of std::iterator
It's deprecated in C++17
2022-11-14 09:35:40 +01:00
Meghana Gupta
b1c0bd3096 Minor cleanup in ARCSequenceOpts (#33578)
* Remove NewInsts from ARCSequenceOpts

* Remove more instances of InsertPts

* Address comments from #33504

* Make bottom up loop traversal simpler. Use better apis

* Update LoopRegion printer with more info
2020-08-24 21:21:11 -07:00
swift-ci
da686f2aa7 Merge remote-tracking branch 'origin/master' into master-next 2019-10-09 17:09:31 -07:00
Jordan Rose
a1ea211f22 Add llvm::iterator_range to LLVM.h
If we're going to get rid of swift::IteratorRange, let's make
llvm::iterator_range easy to use.

No functionality change.
2019-10-08 15:24:06 -07:00
Jordan Rose
7b0d081965 Remove IteratorRange in favor of llvm::iterator_range
Now that llvm::iterator_range has 'empty', there's not enough reason to
keep our own version of it in the Swift repo.

No functionality change.
2019-10-08 11:23:28 -07:00
swift-ci
8b82982f5f Merge remote-tracking branch 'origin/master' into master-next 2019-09-06 11:29:41 -07:00
swift-ci
b9d1078bf6 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 11:23:41 -07:00
Nate Chandler
d2270b9e85 [SIL] Updated instruction worklist.
- Replaced usage of raw map and vector with the type that wraps the
  combination (BlotSetVector); that provided a significant deduplication
  since a sizeable portion of the worklist's implementation was in
  vector and map management now provided by the BlotSetVector.
- Templated over the type of map and vector used by the blot set vector.
- Added SmallSILInstructionWorklist where the map and vector are
  specified to be SmallDenseMap and SmallVector respectively.
- Replaced usages of bare ValueBase with usages of SILValue.
- Renamed zap to resetChecked.

Added a bit of functionality to BlotSetVector, specifically to support
SILInstructionWorklist:

- Made insert return not just the index that the potentially-inserted
  item is at on return but additionally whether an insertion occurred,
  matching the behavior of llvm::DenseMap::insert.
- Added a method to reserve capacity in the backing vector and map:
  BlotSetVector::reserve.
- Added a method to free extra storage used by the backing vector and
  map: BlotSetVector::clear.
- Modified SmallBlotSetVector's template parameters so that only a value
  and size can be specified--that type will always use SmallVector and
  SmallDenseMap for its superclass' VectorT and MapT template
  parameters.
- Updated variable names.
2019-09-06 09:10:26 -07:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
Gwen Mittertreiner
dff6b6e258 Removed uses of PointerUnion3
PointerUnion was generalized to be variadic. Replaced uses of
PointerUnion3 with PointerUnion

See also: git-svn-id:
https://llvm.org/svn/llvm-project/llvm/trunk@360962
91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-20 16:02:41 -07:00
Jordan Rose
793b335d0e [SIL] Clarify ownership in FunctionAnalysisBase w/ std::unique_ptr
I also thought I was fixing a performance issue by changing
invalidateFunction not to /insert/ new entries into the map, but
I guess those entries were present in practice. So this is just
a cleanup to make ownership easier.
2018-08-09 12:40:10 -07:00
Joe Shajrawi
2fb0dff321 LoopRegionAnalysis: fix a bug in the reverse_iterator
The reverse iterator initialization got the initializations of its rbegin() and rend() reversed (pun intended)
2018-07-25 14:46:59 -07:00
Michael Gottesman
56d100f493 [analysis] Standardize AnalysisKind by moving it out of SILAnalysis into its own "struct enum" in a non-nested scope.
Generally in the SIL/SILOptimizer libraries we have been putting kinds in the
swift namespace, not a nested scope in a type in swift (see ValueKind as an
example of this).
2018-07-15 11:00:33 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
Michael Gottesman
406a7c9962 [loop-region] Track the backedges of all loop regions.
We already computed this information so this is just storing information
we were already computing.

One thing to note is that in code with canonicalized loops, we will
always only have one backedge. But we would like loop region to be
correct even in the case of non-canonicalized code so we support having
multiple back edges. But since the common case is 1 backedge, we
optimize for that case.

This commit contains updated tests and also updates to the loop region graph
viewer so that it draws backedges as green arrows from the loop to its backedge
subregions. The test updates were done by examining each test case by hand.
2016-03-14 22:37:06 -07:00
Michael Gottesman
3fd5e80b39 [loop-region] Change LoopRegion::getParentID() to return the optional ParentID instead of attempting to use the value and asserting. 2016-03-14 22:37:06 -07:00
Michael Gottesman
5f72810ad3 Add a range adaptor for std::count and update various trivial usages in the compiler to use this API instead. 2016-03-08 14:58:13 -08:00
Jordan Rose
66189ffac9 Convert many more classes to use llvm::TrailingObjects.
I only intend to do SIL instructions after this; I'm leaving the runtime alone.
2016-02-09 08:57:19 -08:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
Michael Gottesman
7b17debfbd Revert "[loop-region] Add in an assert that we should always have a block result for getRegionForNonLocalSuccessors. NFC."
This reverts commit 81e7bdfe1b.

This is not true in non-loop canonicalized SIL. It is true in loop-canonicalized
SIL though. So I need to fix the test to avoid the assert.
2016-01-07 20:46:12 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Michael Gottesman
472efd46c6 [loop-region-analysis] Store the exiting regions from loops that we compute and used to just throw away.
I need this for loop-arc since I need to be able to analyze all "loop-exits"
when I just have the parent loop region. We are already computing this
information and throwing it away, so there should be no compile time impact.
2015-12-15 02:02:39 -06:00
practicalswift
c6e8459187 Fix typos. 2015-12-14 11:13:30 +01:00
practicalswift
d436cbd701 Fix typo: auxillary → auxiliary 2015-12-14 00:11:16 +01:00
Andrew Trick
84450b4c43 Reorganize SILOptimizer directories for better discoverability.
(Headers first)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 12:34:51 -08:00