Commit Graph

23 Commits

Author SHA1 Message Date
Allan Shortlidge
c6aa93889f Tests: Update Radar numbers in a couple tests. 2023-10-06 12:59:41 -07:00
Erik Eckstein
ddf5c40bdf temporarily disable SILOptimizer/OSLogFullOptTest.swift test
rdar://104969234
2023-02-02 20:18:26 +01:00
Erik Eckstein
5e870f2d8d tests: fix SILOptimizer/OSLogFullOptTest.swift
* remove a NEXT requirement, because the optimizer now inserts an additional instruction
* match optional `nonnull` attributes, which are inserted by the new LLVM (in rebranch)
2022-11-08 17:58:01 +01:00
Andrew Trick
7af3b806a7 Disable SILOptimizer/OSLogFullOptTest.swift
Workaround for rdar://102078974 (Swift CI: [main] 1. OSS - Swift
(Tools Opt+Assert, Stdlib DebInfo+Assert, Test Device non_executable)
2022-11-08 00:16:49 -08:00
Erik Eckstein
ed54253d29 SIL Optimizer: remove legacy C++ passes
They were used as a backup during the transition to Swift passes. Now they are not needed anymore.
2022-10-20 18:31:06 +02:00
Anthony Latsis
7fb62f6d9c Gardening: Migrate test suite to GH issues: SILOptimizer (1/2) 2022-09-04 09:35:41 +03:00
Meghana Gupta
d3b0219f32 Update test 2022-08-22 15:27:52 -07:00
Erik Eckstein
0760934936 tests: make the SILOptimizer/OSLogFullOptTest.swift test more flexible
The compiler generates a few more retain/release runtime calls for some reason.
This confuses the complex matched pattern in the test.
2022-07-28 19:16:18 +02:00
Andrew Trick
d149642314 Update OSLogFullOptTest for TargetConstantFolding.
The difference is that these bitcast operations are no longer sunk to their uses:
  %5 = bitcast %swift.refcounted* %1 to %swift.opaque*

The reason is that TargetConstantFolding removes a conditional branch. Then CodeSinking no longer sinks:
  %20 = struct $String (%19 : $_StringGuts)
2022-06-25 00:05:29 -07:00
Arnold Schwaighofer
e9e7776f7d Try to fix test/SILOptimizer/OSLogFullOptTest.swift
Basic block placment has changed

rdar://92802417
2022-05-05 13:47:07 -07:00
Nate Chandler
ea42e2f334 Enabling copy propagation enables lexical lifetimes.
The effect of passing -enable-copy-propagation is both to enable the
CopyPropagation pass to shorten object lifetimes and also to enable
lexical lifetimes to ensure that object lifetimes aren't shortened while
a variable is still in scope and used.

Add a new flag, -enable-lexical-borrow-scopes=true to override
-enable-copy-propagation's effect (setting it to ::ExperimentalLate) on
SILOptions::LexicalLifetimes that sets it to ::Early even in the face of
-enable-copy-propagation.  The old flag -disable-lexical-lifetimes is
renamed to -enable-lexical-borrow-scopes=false but continues to set that
option to ::Off even when -enable-copy-propagation is passed.
2021-12-08 19:13:21 -08:00
Meghana Gupta
c9d124cf82 Move OME lower for non-transparent functions
Move it just before outliner which has not yet been migrated
2021-10-12 08:54:42 -07:00
Andrew Trick
7205e46f41 Disable -O copy propagation (lifetime shortening) by default
Problem: We continue to uncover code that assumes either precise local
variable lifetimes (to the end of the lexical scope) or extended
temporary lifetimes (to the end of the statement). These bugs require
heroic debugging to find the root cause. Because they only show up in
Release builds, they often manifest just before the affected project
“ships” under an impending deadline.

We now have enough information from projects that have been tested
with copy propagation that we can both understand common patterns and
identify some specific APIs that may cause trouble. We know what API
annotations the compiler will need for helpful warnings and can begin
adding those annotations.

Disabling copy propagation now is only a temporary deferral, we will
still need to bring it back by default. However, by then we should
have:

- LLDB and runtime support for debugging deinitialized objects

- A variant of lifetime sortening that can run in Debug builds to
  catch problems before code ships

- Static compiler warnings for likely invalid lifetime assumptions

- Source annotations that allow those warnings to protect programmers
  against existing dangerous APIs

In the meantime...

Projects can experiment with the behavior and gradually migrate.

Copy propagation will automatically be enabled in -enable-ossa-modules
mode. It is important to work toward a single performance
target. Supporting full OSSA and improving ARC performance without
copy propagation would be prohibitively complicated.

rdar://76438920 (Temporarily disable -O copy propagation by default)
2021-04-09 00:12:09 -07:00
Slava Pestov
b9092e4944 Temporarily disable three SILOptimizer tests on 32-bit
The proper fix is tracked by rdar://problem/74359824.
2021-02-15 16:12:43 -05:00
Andrew Trick
2a26f0ca44 Add a missing CHECK line to OSLogFullOptTest.swift
This test was sensitive to arbitrary block ID's because it was missing
the CHECK line that sets a regex used by subsequent checks.

This is also an example of why it helps to use CHECK-LABEL at the end
of a function scope too.
2021-01-17 22:58:54 -08:00
Andrew Trick
93a514c136 Enable the CopyPropagation pass.
For now simply run the pass before SemanticARCOpts. This will probably
be called as a utility from within SemanticARCOpts so it can be
iteratively applied after other ARC-related transformations.
2021-01-16 23:57:14 -08:00
Ben Langmuir
08f4e15bcf [test] Update SILOptimizer/OSLogFullOptTest.swift
After recent changes we have eliminated one of the retain/release pairs.

rdar://71641343
2020-11-20 15:14:04 -08:00
Andrew Trick
72029d46e7 Add REQUIRES: swift_stdlib_no_asserts to dead_array_elim.swift
One of the subtests cannot be fully optimized without
swift_stdlib_no_asserts because, with runtime verification
enabled, "array.finalize" becomes a mutating operation, preventing
SILCombine from deleting it when it removes dead pure
instructions. After inlining, DeadObjectElimination is still
unable to remove the array because a second array is initialized
by copying the first. This problem can be overcome by handling
non-trivial stores in OSSA, as described here:
[OSSA] Improve DeadObjectElimination to handle array copies
https://bugs.swift.org/browse/SR-13782
2020-10-27 11:08:26 -07:00
Josh Learn
1fd6ef95ce [OSLog] Update compiler stubs and tests
The compiler stubs for testing the OSLog implementation are in need of an update. This change updates the stubs to be consistent with the current OSLog implementation, updates the existing tests, and adds new tests for String and metatype interpolations.

rdar://69719729
2020-10-01 12:14:08 -07:00
Meghana Gupta
586de0af75 Fix KnownSafety optimization bugs in ARCSequenceOpts
While doing bottom up dataflow, if we encounter an
unmatched retain instruction, that can pair with a 'KnownSafe'
already visited release instruction, we turn off KnownSafety if the two
RCIdentities mayAlias.
This is done in BottomUpRefCountState::checkAndResetKnownSafety.
In order to determine if a retain is umatched, we look at
IncToDecStateMap. If a retain was matched during bottom up dataflow, it
is always found in IncToDecStateMap with value of the matched release's
BottomUpRefCountState.

Similarly, during top down dataflow, if we encounter an unmatched
release instruction, that can pair with a 'KnownSafe' already
visited retain instruction, we turn off KnownSafety if the two RCIdentities
mayAlias.
This is done in TopDownRefCountState::checkAndResetKnownSafety.
In order to determine if a release is umatched, we look at
DecToIncStateMap. If a release was matched during top down dataflow, it
is always found in DecToIncStateMap with value of the matched retain's
TopDownRefCountState.

For ARCLoopOpts, during bottom up and top down traversal of a region with
a nested loop, we find if the retain/release in the loop summary was
matched or not by looking at the persistent RefCountInstToMatched map.
This map is populated when processing the nested loop region from the
IncToDecStateMap/DecToStateMap which gets thrown away after the loop
region is processed.

This fixes the bugs in both ARCSequenceOpts without loop
support and with loop support.
2020-09-03 00:51:19 -07:00
Robert Widmann
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03:01 -07:00
Erik Eckstein
1de19a1b32 SimplifyCFG: fix a compile time problem with block merging
When merging many blocks to a single block (in the wrong order), instructions are getting moved over and over again.
This is quadratic and can result in very long compile times for large functions.
To fix this, always move the instruction to smaller block to the larger block.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Ravi Kandhadai
b7e8f76108 [stdlib/private][os log] Simplify the OSLogPrototype stdlib-private
module to contain only code necessary for testing the compiler
optimizations and diagnostics. This commit comprises the following changes:

1. Rename the OSLogPrototype module to OSLogTestHelper and rename the files.
2. Make the private module: OSLogTestHelper independent of os overlay.
3. Simplify the os log test suites and make them not perform logging.
4. Enable the os log test suites on all platforms.

<rdar://problem/60542172>
2020-03-27 01:18:04 -07:00