Commit Graph

64 Commits

Author SHA1 Message Date
Erik Eckstein
8fb002e009 tests: add a missing target-codesign in constant_folded_fp_operations.swift
rdar://119268917
2023-12-07 09:45:02 +01:00
Kavon Farvardin
5672ddfb31 [test] add coverage for rdar://118360449 2023-12-01 10:02:16 -08:00
Kshitij
cc3c51ecb9 [sil-optimizer] Don't constant fold eq comparisons b/w inf and non-inf
This commit modifes the constant folder to not handle equality comparisons b/w
infinity and non-infinity operands. In such comparisons, special floating point
types - Float80 and Float16, may come into play and pattern matching againt them
complicates the constant folding logic more than we'd like.
2023-11-27 11:32:28 -08:00
Kshitij
c800dd731f [sil-optimizer] Add validation tests for constant folded FP arithmetic 2023-11-27 11:32:28 -08:00
Kshitij
97a5a83ae6 [sil-optimizer] Add FP comparison support in constant folder 2023-11-27 11:32:28 -08:00
Nate Chandler
cea0f00598 [InstructionDeleter] Delete dead load [take]s.
Previously, `isScopeAffectingInstructionDead` determined that
an otherwise satisfactory `load` was not dead if it was a `load [take]`.
The immediate effect was that dead `load [take]`s were not deleted.  The
downstream effect was that otherwise dead graphs of instructions would
not be deleted.  This was especially a problem for OSLogOptimization
which deletes a great deal of code.

Here, the InstructionDeleter is taught to compensate for the deletion of
such `load [take]` by inserting `destroy_addr`s in their stead.

rdar://117011668
2023-11-01 14:42:28 -07:00
Erik Eckstein
54d254f100 Optimizer: better handling of the complexity budget in redundant-load-elimination and dead-store-elimination.
Instead of having a budget for each optimized load or store, provide a budget for the whole function.
Fixes a build time problem.

rdar://116877696
2023-10-16 14:44:34 +02:00
Yuta Saito
4c8dc5bcb8 [test] Replace obsolete single_threaded_runtime feature with threading_none
The feature was renamed in 0cf687aa2b but
validation tests were not updated at that time.
2023-10-11 18:14:43 +00:00
Erik Eckstein
09b443d9e3 IRGen: fix emission of constant single-case enums without payload
This is a follow-up of https://github.com/apple/swift/pull/68516 which didn't handle the no-payload case correctly

Fixes a compiler crash

rdar://115666971
2023-09-19 10:28:51 +02:00
Erik Eckstein
9cf0229824 IRGen: fix emission of constant single-case enums
Enums which have a single case with a payload were emitted with wrong field alignement into the data section.

Fixes a miscompile:
rdar://115251963
2023-09-14 12:17:06 +02:00
Hamish Knight
97c3275f6b Add missing %target-codesigns to a couple of tests 2023-09-12 14:45:51 +01:00
Erik Eckstein
885f267362 tests: increase timeout of large_nested_array test
It fails on some jobs intermittently

rdar://115165160
2023-09-11 12:08:47 +02:00
Nate Chandler
d239a14f12 [Test] Required executable_test in executing test.
rdar://115169839
2023-09-08 07:08:59 -07:00
nate-chandler
57e56a0a9e Merge pull request #68342 from nate-chandler/gh68328
[MoveChecker] Complete lifetimes before checking.
2023-09-07 12:20:09 -07:00
Nate Chandler
7713eef817 [MoveValueChecker] Complete lifetimes first.
Before move-checking values, complete the lifetimes of all the values
derived from them via copy, borrow, and move.

Collect all such values and their derived transitive values and then
complete the lifetimes of each, visiting the instructions which produce
them in post-order.

Once OSSALifetimeCommpletion runs as part of SILGenCleanup, this code
can be deleted.
2023-09-07 07:11:24 -07:00
Erik Eckstein
f6f9e75173 AliasAnalysis: use a complexity limit for the isObjReleased function
We already use a complexity limit for other functions in AliasAnalysis.
This is a workaround for quadratic complexity in ARCSequenceOpts.

Fixes a compile time problem
rdar://114352817
2023-09-04 19:52:57 +02:00
Nate Chandler
b3e009003f [Test] Loosened check lines.
The metatype param may or may not be removed from the callee during
specialization.  If it is, there is only one argument, if it is not,
there are two arguments.  None of that is relevant to this test case.
It is just verifying that the strong_retain occurs before the apply.
2023-08-31 15:19:57 -07:00
Nate Chandler
504ce43753 [stdlib] Delete bad @_effects(readonly) annotation
`Dictionary.init(dictionaryLiteral:)` was annotated
`@_effects(readonly)` which means among other things that it doesn't
release any references. Being an init, however, it consumes its
arguments, and so does in fact release.

rdar://114699006
2023-08-30 12:33:58 -07:00
Erik Eckstein
a3822cd2c5 IRGen: fix a problem with 24-bit enum payloads in statically initialized global variables
IRGen crashed in case an enum, which has a 24 bit payload (e.g. three `UInt8`), is used as a payload of another enum, e.g. `Optional`, in a statically initialized global variable.

rdar://112823823
2023-07-26 15:36:31 +02:00
Erik Eckstein
92fab06d96 IRGen: fix generation of static enums with function payloads
fixes a compiler crash

rdar://109999583
2023-05-31 14:22:48 +02:00
Erik Eckstein
fe367e8013 Optimizer/IRGen: allow enums in static initializers of globals
The main change here is in IRGen which needs to be able to emit constant enum values.
Use `emitValueInjection` to create the enum constant.
Usually this method creates code in the current function.
But if all arguments to the enum are constant, the builder never has to emit an instruction.
Instead it can constant fold everything and just returns the final constant.

Also, create statically initialized let-globals as constant global (`constant` instead of `global`).
2023-05-25 16:28:41 +02:00
Nate Chandler
b46232857c [Test] Added optimization test case.
rdar://92652273
2023-03-30 11:04:47 -07:00
Nate Chandler
1a7c4a4d12 [NFC] Renamed DestroyAddrHoisting.
It was previously named SSADestroyHoisting which is rather misleading
considering that it deals with addresses and hoists destroy_addrs.
2023-03-27 14:15:03 -07:00
eeckstein
d154dfda60 Merge pull request #64204 from eeckstein/fix-dce
SILOptimizer: fix a stack overflow in DCE
2023-03-08 17:50:07 +01:00
Erik Eckstein
ca14a08f09 tests: disable many_trys.swift for iOS
For some reason this test times out sometimes when bulding for iOS

rdar://106375480
2023-03-08 12:55:43 +01:00
Erik Eckstein
b741aa0018 SILOptimizer: fix a stack overflow in DCE
For very large control flow graphs the markControllingTerminatorsLive can stack overflow.
Fix this by doing the work iteratively instead of recursively.

rdar://106198943
2023-03-08 12:20:45 +01:00
Erik Eckstein
2d88482c9f EscapeUtils: add a computational limit to avoid quadratic complexity in some corner cases.
The `isEscaping` function is called a lot from ARCSequenceOpt and ReleaseHoisting.
To avoid quadratic complexity for large functions, limit the amount of work what the EscapeUtils are allowed to to.
This keeps the complexity linear.

The arbitrary limit is good enough for almost all functions.
It lets the EscapeUtils do several hundred up/down walks which is much more than needed in most cases.

Fixes a compiler hang
https://github.com/apple/swift/issues/63846
rdar://105795976
2023-02-24 18:58:01 +01:00
Nate Chandler
ed623d7b64 [NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init]
everywhere.
2022-10-27 10:38:54 -07:00
Anthony Latsis
42e47d74f5 Gardening: Migrate test suite to GH issues: validation-test/SILOptimizer 2022-09-20 02:32:29 +03:00
Nate Chandler
d744af576f [Test] Disabled test to investigate.
The test validation-test/SILOptimizer/hoist_destroy_addr.sil is failing
to parse with invalid SIL.  The input will need to be updated.

rdar://98890125
2022-08-19 10:52:59 -07:00
Butta
3933fc0006 [android][test] Fix several tests on the Android CI
- #58975 switched many tests from XFAIL on linux to linux-gnu, so seven
  fail on the Android CI and two natively. They are now explicitly excluded.
- #39605 added several C++ Interop tests, 11 of which fail on the Android CI,
  so disable them for now.
- #42478 removed the @noescape attribute for the non-Android
  SIL/clang-function-types tests, so I remove it for Android too.
- My pull #40779 moved the Swift pointer tags to the second byte, so
  SILOptimizer/concat_string_literals.64 will need to be updated for that,
  disabled it for now.
- Compiler-rt moved the directory in which it places those libraries for
  Android, llvm/llvm-project@a68ccba, so lit.cfg is updated for that.
2022-06-09 14:35:41 +05:30
Ben Barham
efc9469444 Merge pull request #58975 from bnbarham/make-features-consistent
[Tests] Make OS features consistent
2022-05-25 16:02:43 -07:00
Nate Chandler
e39caea26a [Test] Run test with 64-bit SIL on 64-bit arch. 2022-05-24 08:03:11 -07:00
Nate Chandler
24979d48e0 [SSADestroyHoisting] Adopt new utilities.
Instead of doing one or two non-iterative BackwardReachability runs,
do a single run of IterativeBackwardReachability.  During that, pause
after discovery/local dataflow and use VisitBarrierAccessScopes to
determine which end_access instructions in the discovered region are
barriers.  Add those instructions as kills to the dataflow.  Finally run
the global dataflow.

Enables SSADestroyHoisting to hoist destroys over loops.

Addresses a correctness issue where access scopes which were open at
barrier blocks were not promoted to barriers, resulting in destroy_addrs
getting hoisted into unrelated access scopes.
2022-05-21 12:56:51 -07:00
Ben Barham
c163e0fe5e [Tests] Make OS features consistent
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.

Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
2022-05-20 19:51:23 -07:00
Nate Chandler
979196cb16 [Test] For disabling destroy hoisting. 2022-03-17 12:06:53 -07:00
Nate Chandler
f79f26f6ea [Test] Reenabled test.
Added flag to disable destroy hoisting to run line.  Destroy hoisting
will be disabled separately.

rdar://86271875
2022-02-21 08:05:48 -08:00
Nate Chandler
1d939d4201 [Test] Run in right contexts.
The validation-test/SILOptimizer/lexical-lifetimes.swift test uses
concurrency features.  Specified where that means the test can run
appropriately.
2022-01-14 18:31:33 -08:00
Nate Chandler
9b021c9ba7 [Test] Eased check assertion. 2022-01-12 13:15:57 -08:00
Nate Chandler
cb205a6ec0 [Test] Checked variable lifetimes not extend weak.
Verified that lexical lifetimes DO NOT result in a method call to a weak
reference resulting in a strong reference to the object.  Consequently,
even with lexical lifetimes enabled, it is still possible, within a
single scope, for the first method call to an object weakly referenced
to occur but for the second such call not to because the object will
have been deallocated.
2022-01-05 13:00:35 -08:00
Nate Chandler
f48f3ad228 [Test] Checked variable lifetimes extend self.
Verified that when a __consuming method calls a function which takes a
closure that captures self weakly, self is not deallocated until the
call returns.  (Note that this is a behavioral change from what occurs
when lexical borrow scopes are disabled; in that case, self is
deallocated before the call to the function.)
2022-01-05 12:12:01 -08:00
swift-ci
6a752615d6 Merge pull request #40477 from nate-chandler/lexical-lifetimes/reenable-destroy-hoisting 2021-12-09 15:42:02 -08:00
Nate Chandler
59f3b37c35 [SIL] Reenable destroy hoisting under lexical lifetimes.
Until https://github.com/apple/swift/pull/40392 lands, run destroy
hoisting with lexical lifetimes.
2021-12-09 10:42:36 -08: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
Nate Chandler
2356b07427 [Test] Add two lexical lifetime verification tests.
Verify that lexical-lifetimes and copy-propagation interact correctly to
keep objects named by variables alive in a couple interesting cases:
unsafe pointers, synchronization point calls.
2021-12-07 16:29:17 -08:00
Nate Chandler
1961be8845 Renamed flag to -enable-lexical-lifetimes.
Previously, both swift-frontend and sil-opt put lexical lifetimes behind
a flag named -enable-experimental-lexical-lifetimes.  That's redundant.
Here, the experimental portion of the name is dropped.
2021-12-03 17:40:37 -08:00
Nate Chandler
d9b32f243c [Test] Fixed run line for lexical-lifetimes.swift.
rdar://84984903
2021-11-03 16:48:48 -07:00
Nate Chandler
3bb1766a5f [SILOptimizer] Keep lexical lifetime markers.
Previously, TempRValueElimination would peephole simple alloc_stacks,
even when they were lexical; here, they are left for Mem2Reg to properly
handle.

Previously, SemanticARCOpts would eliminate lexical begin_borrows,
incorrectly allowing the lifetime of the value borrowed by them to be
observably shortened.  Here, those borrow scopes are not eliminated if
they are lexical.

Added an executable test that verifies that a local variable strongly
referencing a delegate object keeps that delegate alive through the call
to an object that weakly references the delegate and calls out to it.
2021-10-22 15:00:23 -07:00
Karoy Lorentey
4c12217157 [test] Add missing postprocessing phase to executable stress tests
We need to run utils/swift-darwin-postprocess.py on every executable test on Darwin platforms to work around a dyld issue. (And to ad-hoc sign executables on platforms that need it.)

Add a %target-codesign step to stress tests that are currently missing it.
2021-06-17 13:35:21 -07:00
Holly Borla
11496e2c4c [NFC] Add bugs.swift.org links to disabled tests to track re-enabling. 2021-04-08 23:04:51 -07:00