Commit Graph

2864 Commits

Author SHA1 Message Date
Andrew Trick
7c34295c16 Add some tracing to debug DiagnoseStaticExclusivity. 2017-05-16 10:22:49 -07:00
Andrew Trick
886b1f869c Revert "[Exclusivity] Check that accesses are well-formed during diagnostics." 2017-05-15 09:53:59 -07:00
swift-ci
287d43c3ca Merge pull request #9520 from atrick/access_work 2017-05-11 17:37:10 -07:00
Andrew Trick
f78a2ab2d8 [Exclusivity] Check that accesses are well-formed during diagnostics.
This can help catch assumptions in current implementation during testing.
It does not need to be merged to 4.0.
2017-05-11 14:17:35 -07:00
Bob Wilson
e22561bd29 Merge pull request #9482 from atrick/master
Comment typos.
2017-05-10 18:59:23 -07:00
Andrew Trick
c76269ccd9 Comment typos. 2017-05-10 16:37:59 -07:00
Roman Levenstein
946b1d4225 Fix issues with the AddressLowering pass
Override the current SILModuleConvention of the SILModule when we perform the address lowering.
2017-05-10 11:59:43 -07:00
Roman Levenstein
45c2c4af0e Re-factoring: Get rid of useless arguments in "create*Apply" functions
Till now createApply, createTryApply, createPartialApply were taking some arguments like SubstCalleeType or ResultType. But these arguments are redundant and can be easily derived from other arguments of these functions. There is no need to put the burden of their computation on the clients of these APIs.

The removal of these redundant parameters simplifies the APIs and reduces the possibility of providing mismatched types by clients, which often happened in the past.
2017-05-10 08:03:37 -07:00
Andrew Trick
dd31c40995 [Exclusivity] Disable dynamic enforcement in noescape closures. 2017-05-08 17:27:26 -07:00
Devin Coughlin
0777cccb71 [Exclusivity] Make static access conflict an error in Swift 4 mode.
When static enforcement of exclusive access is enabled, make access conflicts an
error in Swift 4 mode. They will remain a warning in Swift 3 mode.
2017-05-06 19:13:53 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
practicalswift
d4abd21f00 [gardening] Remove duplicate #include 2017-05-04 15:23:11 +02:00
swift-ci
26719c6e12 Merge pull request #9198 from devincoughlin/access-enforcement-closure-capture 2017-05-02 19:40:38 -07:00
Devin Coughlin
de9c646804 [Exclusivity] Use dynamic enforcement on boxes whose projections escape
In AccessEnforcementSelection, treat passing a projection from a box to
a partial_apply as an escape to force using dynamic enforcement on the box.

This will now correctly use dynamic enforcement on variables that are taken
as inout and also captured by storage address in a closure:

  var x = ...

  x.mutatingMethod { ... use x ...}

but does pessimize some of our existing enforcement into dynamic since
access enforcement selection.

Ideally we would distinguish between escaping via an nonescaping closures
(which can only conflict with accesses that are in progress) and
escaping via escaping closures (which can conflict for any reachable code
after the escape)
2017-05-02 14:54:12 -07:00
Michael Gottesman
c55c0f8bfd [gardening] Eliminate two else returns. 2017-05-02 10:22:03 -07:00
Michael Gottesman
503774e5a7 [gardening] Standardize usage of auto in if-dyncast pattern in cleanupCalleeValue.
The if-dyncast pattern is this construct:

(1) if (auto *x = dyn_cast<SILInstruction>(f)).

In this function, we were sometimes using 'auto *' and othertimes we were
writing out the full type. This commit standardizes on 'auto *'.
2017-05-02 10:21:58 -07:00
Andrew Trick
ab0d0184e8 Add tracing to AccessMarkerElimination. 2017-05-01 22:36:56 -07:00
Andrew Trick
195da33d1d [Exclusivity] Add deserialization callbacks from the optimizer.
AccessMarkerElimination now registers a callback so that any subsequently
deserialized function bodies will have access markers stripped for optimization.

rdar:31908496 Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of
              incompatible type!") in SILPerformanceInliner
2017-05-01 21:50:44 -07:00
Bob Wilson
84d1630727 Merge pull request #9142 from shajrawi/loadable_by_addr_split
Code Size: Pass large loadable types by address instead of by value - Updated Version
2017-05-01 12:56:38 -07:00
Saleem Abdulrasool
51ef30732e SIL: IWYU (NFC)
Include CommandLine.h from LLVM Support.
2017-04-30 14:33:35 -07:00
Joe Shajrawi
d17258cac7 @in_constant calling convention - part of passing large loadable types by address 2017-04-30 10:13:02 -07:00
Andrew Trick
2336a87866 [Exclusivity] Enable access markers for the entire -Onone pipeline.
Dynamic markers are still conditional on the command line option.
2017-04-28 21:33:09 -07:00
Andrew Trick
f469fb73db [Exclusivity] Allow AccessEnforcementSelection to run before DI. 2017-04-28 21:33:09 -07:00
Robert Widmann
42c59554a0 Introduce the Space Engine
Implement exhaustiveness checking in Sema with rich error messages.  The
algorithm used is a variant of the one described in Fengyun Liu's paper
"A Generic Algorithm for Checking Exhaustivity of Pattern Matching"
published in the EPFL conference, and Luc Maranget's seminal paper
"Warnings for Pattern Matching"

The Space Engine views pattern matching as a problem of projecting the
scrutinee of a pattern-match into a "Space", then iteratively
constructing a Space from the cases.  Taking the difference of this
master space and the covered spaces yields the "holes" left over or
reveals a completely covered space.

The algorithm also extends trivially to redundancy checks in patterns,
but that check is already implemented in SILGen and this algorithm does
not improve upon it.
2017-04-28 02:06:39 -04:00
Saleem Abdulrasool
8741e4cd20 Merge pull request #8971 from compnerd/siloptimizer-iwyu
SILOptimizer: IWYU CommandLine.h (NFC)
2017-04-26 20:08:38 -07:00
swift-ci
962c71a2f1 Merge pull request #9056 from atrick/access 2017-04-26 18:10:28 -07:00
Andrew Trick
e8b0947897 [Exclusivity] Allow testing the -Onone pipeline with access markers.
Markers are always eliminated before -O passes.

At -Onone, markers can be enabled via command line for all -Onone passes.
2017-04-26 17:32:48 -07:00
Michael Gottesman
237a00bc07 [upstream-update] Include a header directly rather than relying on transitive includes.
This causes breakage with some changes coming from upstream.
2017-04-26 16:50:13 -07:00
Andrew Trick
0f70130852 [Exclusivity] Eliminate unpaired access instructions before optimization. 2017-04-26 09:02:47 -07:00
Andrew Trick
b872ae80c1 [Exclusivity] AccessMarkerEnforcementSelection support for unpaired markers. 2017-04-26 09:02:34 -07:00
Andrew Trick
f00381933b [Exclusivity] Fix PredictableMemOps to handle access markers. 2017-04-26 09:00:50 -07:00
practicalswift
ab5aaeb359 Merge pull request #9001 from practicalswift/gardening-20170425
[gardening] Unused variables. Unused diagnostics. Namespace comments. Typos.
2017-04-26 09:28:24 +02:00
Andrew Trick
39cd8126a6 [Exclusivity] Reenable AccessEnforcementSelection assert. 2017-04-25 15:58:11 -07:00
practicalswift
ff827e0455 [gardening] Fix recently introduced typos 2017-04-25 21:03:44 +02:00
practicalswift
861f70e13d [gardening] Use consistent spacing 2017-04-25 21:03:43 +02:00
Michael Gottesman
a89752f77a [gardening] Eliminate unused variable warnings from non-asserts build. 2017-04-24 16:08:06 -07:00
Andrew Trick
e461f4809c [Exclusivity] Temporarily disable an assert in AccessEnforcementSelector.
This pass doesn't do anything useful downstream yet, so it's safe to temporarily
disable the assert.

Reenable after fixing:
<rdar://problem/31797132> [Exclusivity] lldb asserts in AccessEnforcementSelector
2017-04-24 14:46:41 -07:00
Saleem Abdulrasool
7e64abd48d SILOptimizer: IWYU CommandLine.h (NFC) 2017-04-24 13:46:47 -07:00
Andrew Trick
48ecd6d563 [Exclusivity] Enable SILGen access marker emission by default.
This has no measurable effect on benchmarks and does not affect
standard library compile time.
2017-04-24 08:32:15 -07:00
Devin Coughlin
9cdff5fe00 [Exclusivity] Improve static enforcement diagnostics
Static diagnostics now refer to the identifier for the variable requiring
exclusive diagnostics. Additionally, when two accesses conflict we now always
emit the main diagnostic on the first modifying access and the note on either
the second modifying access or the read.

The diagnostics also now highlight the source range for the expression
beginning the access.
2017-04-23 11:39:25 -07:00
Roman Levenstein
f6b8b7d233 Merge pull request #8897 from swiftix/new-integer-perf-improvements
Performance improvements for new integers
2017-04-21 06:38:27 -07:00
swift-ci
ec0c300024 Merge pull request #8906 from gottesmm/small_fixes 2017-04-20 19:47:45 -07:00
swift-ci
a7895aee34 Merge pull request #8895 from devincoughlin/exclusivity-static-check-class-properties 2017-04-20 18:48:25 -07:00
Michael Gottesman
d25328f995 [di] Add a debugging option to trigger an unreachable when DI fails instead of continuing.
This enables one to easily stop in the debugger when one hits a DI error.
2017-04-20 18:34:57 -07:00
Roman Levenstein
2326cb7f38 [constant-propagation] Simplify comparisons with Int.max
Make use of the following inequalities:
1) Int.max >= X, X <= Int.max are always true for any signed integer X
2) Int.max < X, X > Int.max are always false for any signed integer X
3) For any X of the same size as Int.max and any n>=1 , (X>>n) is always <= Int.max, that is (X>>n) <= Int.max and Int.max >= (X>>n) are always true.
     At the same time (X>>n) > Int.max and  Int.max < (X>>n) is always false.
4)  X < 0 is always false, if X is known to be a result of an unsigned operation with overflow checks enabled.
     X >= 0 is always true, if X is known to be a result of an unsigned operation with overflow checks enabled.
2017-04-20 15:27:59 -07:00
Devin Coughlin
77611e6ef9 [Exclusivity] Add best-effort static checking for class stored properties.
Add a simple, best-effort static check for exclusive access for stored
class properties. For safety these properties must be checked dynamically,
also -- but we'll now diagnose statically if we see an obvious violation.
2017-04-20 14:27:09 -07:00
practicalswift
797c2d8118 [gardening] Fix end of namespace comments 2017-04-20 22:01:01 +02:00
practicalswift
c79af78a7f Merge pull request #8878 from practicalswift/gardening-20170420
[gardening] Remove unused diagnostics. Fix end of namespace comments. Match parameter name. Use override as appropriate.
2017-04-20 21:52:15 +02:00
practicalswift
431e5a1440 [gardening] Use consistent end of namespace comments 2017-04-20 13:47:10 +02:00
Michael Gottesman
af8c90e5e6 [gardening] Some small type editing of comments and code style improvements. 2017-04-19 19:15:16 -07:00