Commit Graph

22 Commits

Author SHA1 Message Date
Erik Eckstein
ba4081ee76 Optimizer: replace PredictableMemoryAccessOptimizations with MandatoryRedundantLoadElimination in the pass pipeline
PredictableMemoryAccessOptimizations has become unmaintainable as-is.
RedundantLoadElimination does (almost) the same thing as PredictableMemoryAccessOptimizations.
It's not as powerful but good enough because PredictableMemoryAccessOptimizations is actually only needed for promoting integer values for mandatory constant propagation.
And most importantly: RedundantLoadElimination does not insert additional copies which was a big problem in PredictableMemoryAccessOptimizations.

Fixes rdar://142814676
2025-02-07 11:30:35 +01:00
Erik Eckstein
7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Andrew Trick
af86ad1e16 Test predictable memopt mark_dependence semantics.
Unit tests for mark_dependence support. Required to fix unsafeAddress.
2024-10-15 16:52:07 -07:00
Erik Eckstein
4316a7cf05 ConstExpr: look through sendable function conversions 2024-03-13 09:58:31 +01:00
Nate Chandler
5a6873b98f [SILOptimizer] Remove DestroyHoisting pass.
It's no longer used.
2024-02-19 11:41:38 -08:00
Andrew Trick
f1bb2e8a82 constant_evaluable_subset - update test to enable optimization
Constant evaluation actually requires optimization to kick in. At
least in some of the tests. For example, alloc_box must be promoted.
2021-12-13 21:35:14 -08:00
Andrew Trick
b689b1dabe Rename GuaranteedARCOpts to MandatoryARCOpts.
This bleeds into the implementation where "guaranteed" is used
everywhere to talk about optimization of guaranteed values. We need to
use mandatory to indicate we're talking about the pass pipeline.
2021-03-02 22:20:13 -08:00
Josh Learn
7cbc21b60a Allow constant interpreter to skip builtin instructions from profiling instrumentation 2020-07-17 13:30:30 -04:00
Ravi Kandhadai
682bb316c0 [Constant Evaluator] Add support for displaying assertion/precondition
failure messages and fatalError messages, when such errors happen
during constant evaluation.
2020-01-28 15:18:25 -08:00
Ravi Kandhadai
c198c1a2aa [Constant Evaluator] Add support for BinaryInteger.description which
converts an integer to a string. This patch adds a @_semantics
annotation to the BinaryInteger.description function.
2020-01-27 21:13:50 -08:00
swift-ci
b890bcb3c2 Merge pull request #28899 from ravikandhadai/constexpr-checked-casts 2020-01-13 14:45:32 -08:00
Michael Gottesman
5b557afbbe [sil] Now that we aren't using mark-uninitialized-fixup anywhere, remove it. 2020-01-02 12:10:36 -08:00
Ravi Kandhadai
ef254c0e9c [Constant Evaluator] Add support for evaluating checked_cast_br
instruction and store_borrow.
2019-12-20 09:29:20 -08:00
Ravi Kandhadai
861c0aaca9 [OSLogOptimization][stdlib/private] Make string interpolation methods
of OSLogMessage constant evaluable and remove @_transparent annotation
from the methods. Also, improve diagnostics in the OSLogOptimization
pass as now it rely on seeing the appendInterpolation/Literal calls.
2019-10-29 19:35:37 -07:00
Ravi Kandhadai
981dca5a65 [Constant Evaluator] Add support for thin_to_thick_function SIL instruction,
and fix bugs in the evaluator in the implementation of array.append, and in
loading/linking external function.
2019-10-15 19:09:14 -07:00
Ravi Kandhadai
940119c5ff [Constant Evaluator] Add support for interpreting SIL code with
partial applies (i.e., closure creations).

A new SymbolicValue: SymbolicClosure represents a closure. It
tracks the SILFunction corresponding to the target of the closure
and the SIL and Symbolic Values of the captured arguments. The
representation does not impose that all captured values must have an
associated symbolic value. This allows the evaluator to track
creations of closures whose captured arguments or bodies are not
constant evaluable.

This commit does not add support for closure applications. It only
adds suppport for closure creations, which correspond to partial_apply
instructions in SIL.
2019-10-11 18:54:19 -07:00
Ravi Kandhadai
7189c09720 Merge pull request #27344 from ravikandhadai/constexpr-arrays
[Constant Evaluator] Support Arrays in the constant evaluator.
2019-09-25 17:15:20 -07:00
Ravi Kandhadai
8f96e8f463 [Constant Evaluator][Test] Add a couple of tests to check whether
the evaluator can detect fatal errors at compile time.
2019-09-24 18:21:06 -07:00
Marc Rasi
874bb1df25 [Constant Evaluator] Support Array constants in the constant
evaluator. Add support for evaluating array initializations
and array append.
2019-09-24 15:18:14 -07:00
Ravi Kandhadai
22861ec0fd [Constant Evaluator] Pass assert configuartion option to the
evaluator to precisely evaluate Builtin.assert_configuration.

Unify UnknownReason::Trap and UnknownReason::AssertionFailure error
values in the constant evaluator, now that we have 'condfail_message'
SIL instruction, which provides an error message for the traps.
2019-09-18 17:35:46 -07:00
Ravi Kandhadai
032442da93 [Constant Evaluator] Add a new sil-opt pass to check constant evaluability
of Swift code snippets. Add a new test: constant_evaluable_subset_test.swift
that tests Swift code snippets that are expected to be constant evaluable and
those that are not.
2019-09-16 18:49:19 -07:00