Commit Graph

84 Commits

Author SHA1 Message Date
Alexander Cyon
4a2942bb4e Fix typos in: cmake, tools, utils, unittests, validation-test
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2024-07-12 02:34:00 +03:00
nate-chandler
a83269ebd1 Merge pull request #74361 from nate-chandler/gh69252
[Test] Add regression test.
2024-06-12 21:21:36 -07:00
Nate Chandler
b1c7999361 [Test] Add regression test.
For https://github.com/apple/swift/issues/69252 .
2024-06-12 14:10:05 -07:00
nate-chandler
689e889297 Merge pull request #74318 from nate-chandler/gh72615
[Test] Add regression test.
2024-06-12 00:13:45 -07:00
Nate Chandler
562e724bbd [Test] Add regression test.
For https://github.com/apple/swift/issues/72615 .
2024-06-11 17:43:18 -07:00
Nate Chandler
d895c34c70 [Test] Add regression test. 2024-06-11 14:57:23 -07:00
Nate Chandler
666f036b82 [Test] Add regression test.
For https://github.com/apple/swift/issues/68128 .
2024-06-05 07:48:50 -07:00
Nate Chandler
cae89a9562 [ConsumeObjectChecker] End lifetimes at consumes.
The checker already verifies that no non-destroy consuming users occur
after any `move_value`s corresponding to `consume` operators applied to
a value.  There may, however, be _destroy_ users after it.

Previously, the checker did not shorten the lifetime from those destroys
up to `move_value`s that appear after those `move_value`s.  The result
was that the value's lifetime didn't end at the `consume`.

Here, the checker is fixed to rewrite the lifetimes so that they both
end at `consume`s and also maintain their lexical lifetimes on paths
away from the `consume`s.  This is done by using
`OwnedValueCanonicalization`/`CanonicalizeOSSALifetime`.

Specifically, it passes the `move_value`s that correspond to
source-level `consume`s as the `lexicalLifetimeEnds` to the
canonicalizer.  Typically, the canonicalizer retracts the lexical
lifetime of the value from its destroys.  When these `move_value`s are
specified, however, instead it retracts them from the lifetime boundary
obtained by maximizing the lifetime within its original lifetime while
maintaining the property that the lifetime ends at those `move_value`s.

rdar://113142446
2024-06-03 15:45:32 -07:00
Joe Groff
10f9289ef8 Enable 'BorrowingSwitch' feature. 2024-05-14 07:31:59 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Nate Chandler
5325a4d5f8 [MoveOnlyAddressChecker] Fix empty struct repr.
An empty struct without a deinit gets a single bit which is used to
track the struct's liveness.  Previously, an empty struct with a deinit
also only got a single bit.  Consequently, when discarding the struct
(i.e. dropping the deinit), there was no bit left to represent the
struct.  This resulted in a failure to track liveness for the value.

rdar://126863003
2024-04-22 08:42:14 -07:00
Nate Chandler
de8f1c0b69 [NoncopyablePartialConsumption] Promote to feature 2024-04-19 12:37:34 -07:00
Nate Chandler
943cc3cc7c [NoncopyablePartialConsumption] Enable.
SE-429 was accepted.

rdar://126275392
2024-04-11 08:19:29 -07:00
Karoy Lorentey
9725b892cc [test] More test updates 2024-03-18 13:27:46 -07:00
nate-chandler
d80854ea3b Merge pull request #72256 from nate-chandler/gh70234
[ConsumeChecker] Check guaranteed arguments.
2024-03-12 14:04:34 -07:00
Nate Chandler
863c919713 [Test] Add regression test.
For https://github.com/apple/swift/issues/70234 .
2024-03-12 08:33:16 -07:00
Nate Chandler
d8a9c428b0 [Test] Add regression test.
For https://github.com/apple/swift/issues/72055 .
2024-03-11 21:08:16 -07:00
Nate Chandler
ae9d501d77 [Test] Mix in another experimental feature. 2024-03-01 21:01:49 -08:00
Nate Chandler
6100a1b495 Allow partial consumption of self in deinit.
Basic support for partial consumption in deinit without full support for
all future uses of drop_deinit.
2024-02-28 15:57:09 -08:00
Meghana Gupta
ad170b6758 Update test lexical-lifetimes.swift 2024-01-08 22:22:08 -08:00
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