Commit Graph

37 Commits

Author SHA1 Message Date
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Tony Allevato
5f5b24f96e [C++20] Make operator{==,!=}s const.
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
Erik Eckstein
1c844ed29f SIL: remove dangerous SILBasicBlock APIs
`isSuccessorBlock` and `isPredecessorBlock` are dangerous because they can easily lead to quadratic behavior.
Fortunately they are not used anywhere (except in one place for verification, which I rewrote).
2023-03-08 12:20:52 +01:00
Valeriy Van
66615542aa Fix bug: wrong parameters of std::sort 2022-12-19 20:17:15 +02: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
Michael Gottesman
4c803c9583 [gardening] LLVM has its own enumerate impl now. Use that and delete the one swift had.
NFCI.
2019-09-07 00:13:29 -07:00
Bob Wilson
8e330ee344 NFC: Fix indentation around the newly renamed LLVM_DEBUG macro.
Jordan used a sed command to rename DEBUG to LLVM_DEBUG. That caused some
lines to wrap and messed up indentiation for multi-line arguments.
2018-07-21 00:56:18 -07:00
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
Bob Wilson
37e7d1c627 Merge remote-tracking branch 'origin/master' into master-next 2017-01-08 17:07:46 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Bob Wilson
78b28243ff Merge remote-tracking branch 'origin/master' into master-next 2017-01-03 14:22:59 -08:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Bob Wilson
13da3fa8b1 Merge remote-tracking branch 'origin/master' into master-next 2016-12-04 18:16:09 -08:00
Michael Gottesman
38ec08f45f [gardening] Standardize SILBasicBlock successor/predecessor methods that deal with blocks rather than the full successor data structure to have the suffix 'Block'.
This was already done for getSuccessorBlocks() to distinguish getting successor
blocks from getting the full list of SILSuccessors via getSuccessors(). This
commit just makes all of the successor/predecessor code follow that naming
convention.

Some examples:

getSingleSuccessor() => getSingleSuccessorBlock().
isSuccessor() => isSuccessorBlock().
getPreds() => getPredecessorBlocks().

Really, IMO, we should consider renaming SILSuccessor to a more verbose name so
that it is clear that it is more of an internal detail of SILBasicBlock's
implementation rather than something that one should consider as apart of one's
mental model of the IR when one really wants to be thinking about predecessor
and successor blocks. But that is not what this commit is trying to change, it
is just trying to eliminate a bit of technical debt by making the naming
conventions here consistent.
2016-11-27 12:32:51 -08: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
Bob Wilson
9cc68d6c9f Update for clang r283671: remove use of clEnumValEnd. 2016-10-15 11:02:20 -07:00
Bob Wilson
8e3226096e Use pointer_iterator for GraphTraits nodes_iterators.
llvm r279326 changed to consistently dereference iterators to pointers,
so we need to do the same for several of the GraphTraits iterators.
2016-10-15 11:02:20 -07:00
Bob Wilson
d70c85745d Remove NodeType from all GraphTraits.
This is no longer used as of llvm r279475.
2016-10-15 11:02:20 -07:00
Saleem Abdulrasool
9203283628 SILOptimizer: switch to NodeRef
This adds the typedef and switches uses of NodeType * to NodeRef.  This is in
preparation for the eventual NodeRef-ization of the GraphTraits in LLVM.  NFC.
2016-08-25 13:01:11 -07:00
practicalswift
854e82d4dc [SILOptimizer] Remove unused "SuccFilterFnTy" 2016-03-15 13:57:38 +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
saisi
08abcd92c3 fixed niggling typos 2016-01-29 22:22:12 -05:00
practicalswift
33312eac6b [gardening] Remove unreachable/unused/redundant code
* Make parameter naming in forward declaration match definition
* Remove unused argument to function persistAsync(…)
* Remove unused enum ShouldHalt
* Remove unused enum class IsProtocol
* Remove unused function dumpTypeSubstitutionMap()
* Remove unused function template getFirstPairElt(…)
* Remove unused method addConstantWordInWords(…)
* Remove unused method asExistentialTI()
* Remove unused method currentTrackedState()
* Remove unused method getNumBodyParameters()
* Remove unused method getSuccIndex()
* Remove unused method getTypeOfDeclReference(…)
* Remove unused method hasStructWithAtMostOneNonTrivialField(…)
* Remove unused method initForDirectValues()
* Remove unused method nextIfNot(…)
* Remove unused method overwriteLoweredValue(…)
* Remove unused method removeColumn(…)
* Remove unused methods HasSingleDecl() and GetFirstDecl()
* Remove unused methods overwriteLoweredExplosion(…) and setLoweredSingleValue(…)
* Remove unused methods requireRetainablePointerValue(…), getMethodSelfInstanceType(…) and isSelfArchetype(…)
* Remove unused methods setAsEmptyDirect(), setAsSingleDirectUnmanagedFragileValue(…), setAsIndirectAddress(…) and getDirectValues()
* Remove unused struct CachedMemberInfo
* Remove unused struct CallEdit
* Remove unused struct ErrorImportInfo
* Remove unused synonym ConformancePair
* Remove unused variable SemaInfo
* Remove unused variable localDeclNameNode
* Remove unused variables kindToken and kindLoc
2016-01-22 09:43:24 +01:00
practicalswift
6d0eee9b8c Remove unused variables. 2016-01-21 10:33:17 +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
Michael Gottesman
81e7bdfe1b [loop-region] Add in an assert that we should always have a block result for getRegionForNonLocalSuccessors. NFC. 2016-01-07 20:32:05 -08: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
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
Michael Gottesman
a3a329fffb Add some comments to LoopRegionAnalysis that explains a few methods in better detail. NFC. 2015-12-15 02:02:39 -06:00
Michael Gottesman
c29236cc89 When sort/uniqueing exiting regions for processing, unique not by pointer value, but by ID. 2015-12-15 00:36:56 -06:00
Michael Gottesman
f3c8c5a774 Create SILBasicBlock::getSuccessorBlocks().
This just runs a transform range on getSuccessor()'s ArrayRef<SILSuccessor> so
one does not need to always call Successor.getBB() when iterating over successor
blocks. Instead the transform range does that call for you.

I also updated some loops to use this new SILBasicBlock method to make sure that
the code is tested out by tests that are already in tree. All these places
should be functionally the same albeit a bit cleaner.
2015-12-15 00:36:56 -06:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

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 15:14:23 -08:00