Commit Graph

19 Commits

Author SHA1 Message Date
Erik Eckstein
c89df9ec98 Mandatory optimizations: constant fold boolean literals before the DefiniteInitialization pass
Add a new mandatory BooleanLiteralFolding pass which constant folds conditional branches with boolean literals as operands.

```
  %1 = integer_literal -1
  %2 = apply %bool_init(%1)   // Bool.init(_builtinBooleanLiteral:)
  %3 = struct_extract %2, #Bool._value
  cond_br %3, bb1, bb2
```
->
```
  ...
  br bb1
```

This pass is intended to run before DefiniteInitialization, where mandatory inlining and constant folding didn't run, yet (which would perform this kind of optimization).
This optimization is required to let DefiniteInitialization handle boolean literals correctly.
For example in infinite loops:

```
   init() {
     while true {           // DI need to know that there is no loop exit from this while-statement
       if some_condition {
         member_field = init_value
         break
       }
     }
   }
```
2024-01-10 16:15:57 +01:00
Valeriy Van
b5ab1c85af Fix bug: wrong var used (#62683)
* Fix bug: wrong var used

* Augment tests for cases returning from initializers without initializing all stored properties
2023-01-03 20:57:17 -07:00
Anthony Latsis
075768b7a0 Gardening: Migrate test suite to GH issues: SILOptimizer (2/2) 2022-09-22 03:21:35 +03:00
Luciano Almeida
ddeb1929c4 [DiagnosticQol][SR-14505] Use DeclDescriptive kind in missing return data flow diagnostics (#36952)
* [Diagnostics] Use DeclDescriptiveKind on data flow diagnostics to improve diagnostic message

* [tests] Add regression tests to SILOptimizer/return.swift

* [tests] Adapt other tests to changes of SR-14505

* [Diagnostics] Adapt message for missing return diagnostics, remove article

* [Diagnostics] Adapt message for missing return diagnostics to have a note with fix

* [tests] Adjust tests in validation suit
2021-04-20 08:16:32 -03:00
Minhyuk Kim
7eaabe1996 Simplify unused lvalue warning wording 2021-01-15 22:14:56 +09:00
Luciano Almeida
634ce7de1f [test] Add SR-13753 test cases 2020-12-28 23:00:17 -03:00
Erik Eckstein
0661380516 Fix wrong missing-return error message for an initializer returning an implicitly unwrapped optional
The problem was that the unreachable instruction after the IUO unwrapping error call was interpreted as missing-return-unreachable.

rdar://problem/36611041
2018-01-30 09:07:57 -08:00
Graydon Hoare
8f4266067a [SILOptimizer] Handle a missing case in DataflowDiagnostics.cpp 2017-09-04 20:02:21 -07:00
Robert Widmann
5a2479cb2a Expand the no-return diagnostic
Turn on the noreturn diagnostic for cases where a reachable unreachable
could be encountered.  Previously, the diagnostic would not fire if the
function was marked noreturn and any of its reachable unreachable calls
were around.  While this makes sense from a SILGen perspective (it Just
Crashes tm), it is still wrong.  We need to diagnose *everything* that
has reachable unreachables.
2016-08-18 20:39:24 -07:00
Robert Widmann
fdaddcc5dd Uninhabited != NoReturn
Previously, isNever would return true for an equivalence class of
uninhabited enums.  The rest of the compiler, however, is using this in
places that actually expect just the Never type.  This means that code
like this would compile properly

enum Uninhabited {}
func do() -> Uninhabited { /* No body here */ }

and we wouldn’t diagnose the missing return.
2016-08-18 17:46:32 -07:00
Doug Gregor
b9363fe6bd [SE-0111] Enable SE-0111 by default. 2016-07-29 17:28:24 -07:00
Slava Pestov
ddc51c5917 AST: Implement SE-0102, introducing new semantics for Never alongside @noreturn
No migrator support yet, and the code for @noreturn is still in
place.
2016-07-22 14:56:39 -07:00
Chris Lattner
8746676616 Move @noescape and @autoclosure to their new places in various tests, NFC. 2016-04-15 16:05:35 -07:00
Chris Lattner
0619e57a61 Switch the stdlib to use #file instead of __FILE__, and deprecate the __FILE__ identifiers.
This also updates the tests that would otherwise fail.
2016-02-04 15:08:31 -08:00
ken0nek
3ac60b13f5 Add spaces before and after closure arrow in test 2015-12-23 04:38:46 +09:00
Chris Lattner
0224f2d858 Convert more tests off of ++ and -- 2015-12-21 18:07:37 -08:00
Daniel Duan
239c6629e9 Remove trailing semi-colons in .swift files 2015-12-20 21:12:11 -08:00
Daniel Duan
ebb0c3a204 replaced single-line ++/-- with +=/-= 2015-12-15 09:05:37 -08:00
Andrew Trick
bd35b4789c Move test/SILOptimizer files to reflect lib/SILOptimizer. 2015-12-11 15:53:22 -08:00