Commit Graph

20 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
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
Michael Gottesman
2ce233b134 [gardening] Make count on BlotSetVector const.
Just discovered this as I working on other code.
2022-01-05 17:47:08 -08:00
Michael Gottesman
2e018aff5b [move-function] Implement move function support for address only vars.
I have to make a few other changes to make this work for loadable vars, but I
wanted to get this in.

Behind a flag.
2021-12-07 12:03:01 -08:00
Evan Wilde
102b0c7be1 Add Optional.h to BlotSetVector
It was getting included transitively before, but it isn't anymore due to
refactorings in llvm.
2021-06-24 15:48:41 -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
Michael Gottesman
8e110108d3 [semantic-arc-opts] Eliminate dead trivial instructions /after/ the main loop to avoid issues around adding/removing things from the worklist.
rdar://55127027
2019-09-09 14:52:36 -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
Michael Gottesman
dee2627d0e [semantic-arc-opts] Change semantic arc opts to use a SmallBlotSetVector instead of a SmallSetVector.
Blotting is a trick with Map/Set vectors that involves one assigning None to the
vector at the index mapped to an entry instead of deleting the entry itself from
the vector. This ensures that we do not need to move elements of the vector down
when erasing elements from the worklist.
2019-08-29 17:13:32 -07:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Andrew Trick
9923d5d9cf Fix usability issues with BlotVector.
- Add const getItems().

- Fix const find().

- erase() returns a boolean.

- Set erase() should not perform two lookups.

The implementation is covered by the unit tests with a small addition.

Other trivial API changes are trivially tested in upcoming commits.
2018-03-31 17:39:54 -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
9884c7a0b7 Fix small obvious typo. Thanks for catching this Bob! 2016-10-07 17:20:29 -07:00
danra
5eed1f748b Add missing comment after .h file #endif 2016-03-22 22:59:57 +02:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Michael Gottesman
5fe0b8b34c [loop-arc] Fix a bug in how we process successors and fix the resulting performance issue that resulted.
Previously we represented all successors in a list where each successor
was represented by a SuccessorID. A SuccessorID is essentially an
unsigned int that stores some flags in the lower bits of the
integer. The two flags are: 1. IsDead, 2. IsNonLocal (where non local
means that it is a loop exit edge). When the IsNonLocal flag is not set,
the integer that is actually stored represents the ID of the successor
region. If the IsNonLocal flag is set, then the integer represents the
index in the parent region's successor list of the actual loop exit
successor.

The bug I mentioned was that we were not being careful enough in the
replacement code to distinguish in between successors that were loop
exit successors and those that were not. This could cause us to replace
a loop exit successor whose integer value was the same as the index of a
non-loop exit successor with the non-loop exit successor. This then
would cause us to miscompile and or introduce duplicate values into the
successor list. Luckily an assert I added caught the latter condition.

After I fixed this problem, an interesting performance issue was
exposed. I had assumed when using a list that I would never have more
than 10-20 successors (in general a reasonable assumption). But
introducing loop exit successors adds in an interesting wrinkle, namely
every block with an unreachable terminator will result in a successor
edge. This makes just iterating over a uniqued list really slow.

I solved the issue by writing a new data structure called
BlotSetVector. The interesting thing about BlotSetVector is that all
operations preserve index offsets. This means that if one erases a
value, all other values in the set vector are not moved around in the
internal vector. This is important since a loop exit edge needs to refer
to an invariant offset in the parent region's successor array since we
do not want to have to go through and update large amounts of unrelated
edges every time we erase an edge.

In terms of a test case, this invariant was impossible for me to reproduce since
it is sensitive to the order of successors. Even dumping the file and running
the analysis would not catch it. After 2 days of trying to make a test case I
gave up. But I filed rdar://23228299 to verify that sil-opt can round trip
in memory ordering of various items such as use lists, successors, predecessors,
block ordering, function ordering, etc.

rdar://22238658

Swift SVN r32839
2015-10-23 01:38:09 +00:00