Commit Graph

2864 Commits

Author SHA1 Message Date
Devin Coughlin
5d59fbc760 [Exclusivity] Teach static enforcement to look through mark_uninitialized
This will be needed to improve the diagnostic text to refer to the variable
accessed.
2017-04-19 18:18:49 -07:00
swift-ci
6eb7c0dbf5 Merge pull request #8853 from devincoughlin/swap-suppression-flag 2017-04-18 18:10:30 -07:00
Devin Coughlin
ae3b13ed2d [Exclusivity] Put suppression for free function swap() behind a flag
And leave suppression off by default for now. We'll use this to evaluate
how often swap() causes exclusivity conflicts to be reported.
2017-04-18 17:21:53 -07:00
practicalswift
a41a501c56 Merge pull request #8835 from practicalswift/gardening-20170418
[gardening] Fix URLs. Fix spacing. Remove unused methods. Fix headers.
2017-04-18 22:59:00 +02:00
John McCall
7a4c761426 Merge pull request #8821 from rjmccall/dynamic-enforcement-vol-1
Basic dynamic enforcement of exclusivity
2017-04-18 13:57:54 -04:00
practicalswift
a029589093 [gardening] Use consistent headers 2017-04-18 19:51:08 +02:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
John McCall
82c2d11632 Allow dynamic access markers in non-raw SIL. 2017-04-17 17:16:13 -04:00
Michael Gottesman
8969d1c9b5 Merge pull request #8807 from gottesmm/di_refactoring
[di] Refactor out the handling of DelegatingInit related code out of ElementCollector into its own class.
2017-04-16 23:52:27 -07:00
swift-ci
9e35ac5070 Merge pull request #8810 from atrick/access 2017-04-16 23:26:51 -07:00
Andrew Trick
3fe16ac03c [Exclusivity] Fix AccessEnforcementSelection to handle unreachable blocks. 2017-04-16 22:46:04 -07:00
Michael Gottesman
bbb89dcdf9 [di] Refactor out the handling of DelegatingInit related code out of ElementCollector into its own class.
There was no real code sharing going on here and instead due to the size of
ElementCollector made it difficult to ascertain without reading the code that
the two code paths are completely separate.

This is a NFC change internal to DIMemoryUseCollector that is not visible
outside of DI.

rdar://31521023
2017-04-16 18:34:10 -07:00
Michael Gottesman
1c803fd732 [gardening] Fix comment. NFC. 2017-04-16 18:33:56 -07:00
Michael Gottesman
35edc11568 [gardening] Be more specific about a type used in a method name. NFC. 2017-04-16 16:49:33 -07:00
Michael Gottesman
3f6c4b96bb [gardening] Some small llvm style cleanups in DiagnoseStaticExclusivity. 2017-04-16 16:49:33 -07:00
swift-ci
272eb461ee Merge pull request #8798 from devincoughlin/static-access-enforcement-swap-suppression 2017-04-15 14:33:47 -07:00
Devin Coughlin
8d180f4bdc [SILDiagnostics] Add suppression for swap() to static access enforcement.
Add a SILLocation-based syntactic suppression for diagnostics of static
access conflicts on the arguments to the Standard Library's swap() free
function. We'll suppress for calls to this function until we have a safe
replacement.
2017-04-15 14:00:38 -07:00
swift-ci
8fc5a664bb Merge pull request #8797 from atrick/access 2017-04-15 13:32:16 -07:00
Andrew Trick
fff80ba77c [Exclusivity] Fix Definite Initialization for Diagnostics.
Handle mutating methods in initializers properly.

This only affects --enforce-exclusivity mode.
It will be unit tested by default soon.
2017-04-15 13:07:05 -07:00
Devin Coughlin
8aa9b3af89 [SILDiagnostics] Move static enforcement enablement early return earlier.
This avoids computing the PostOrderAnalysis when this pass won't use it
because static checks are disabled.
2017-04-15 11:14:59 -07:00
practicalswift
b8ca098949 Merge pull request #8742 from practicalswift/gardening-20170413
[gardening] Use consistent headers. Remove redundant includes. Remove unused methods. Fix typos, etc.
2017-04-15 18:59:30 +02:00
Andrew Trick
915b319810 [AccessEnforce] must handle undef before diagnostics. 2017-04-14 18:28:37 -07:00
practicalswift
6828ed9e1e [gardening] Use isa<T>(o) instead of dyn_cast<T>(o) when result is unused 2017-04-14 17:33:24 +02:00
practicalswift
734ed6834f [gardening] Use correct multi-line block comment 2017-04-14 17:33:24 +02:00
practicalswift
d8d1693814 [gardening] Remove unused variables 2017-04-14 17:33:24 +02:00
Michael Gottesman
67d23b8489 [semantic-sil] Update DIMemoryObjectInfo to recognize destroy_value where it recognizes strong_release.
rdar://31521023
2017-04-13 16:47:45 -07:00
Michael Gottesman
17a51193fc [gardening] Invert if condition to reduce indentation. 2017-04-13 16:44:34 -07:00
Michael Gottesman
84d089b858 [gardening] Reduce indentation level by inverting an if condition. 2017-04-13 16:44:34 -07:00
Michael Gottesman
c6f5d4a75e [gardening] Cleanup DIMemoryObjectInfo::DIMemoryObjectInfo. NFC. 2017-04-13 16:44:33 -07:00
Michael Gottesman
9a55421878 [semantic-sil] Rename another field Releases -> Destroys. 2017-04-13 16:44:33 -07:00
Michael Gottesman
d9218c738f [semantic-sil] Rename "Releases" -> "Destroys". 2017-04-13 16:44:33 -07:00
Michael Gottesman
79ac3c9e49 [gardening] Fix a doyxgen comment. NFC. 2017-04-13 16:44:33 -07:00
Michael Gottesman
a346da3e87 [gardening] Eliminate some else-if in favor of early returns. 2017-04-13 16:44:33 -07:00
Michael Gottesman
6adcc2969e [semantic-sil] Change DefiniteInitialization to use the DIMemoryUseCollectorOwnership header instead of the normal DIMemoryUseCollector.
This is necessary since other passes rely on DIMemoryUseCollector.h and I want
to update each one of them individually to minimize disruption.

rdar://31521023
2017-04-13 16:41:53 -07:00
Andrew Trick
66d42287a6 AccessEnforcementSelector: add support for arguments.
I'm using source-level tests to help bootstrap the -Onone pipeline
with access markers enabled.
2017-04-12 17:33:17 -07:00
swift-ci
7e044743a8 Merge pull request #8716 from devincoughlin/exclusive-access-rehash-crasher 2017-04-11 19:43:49 -07:00
Devin Coughlin
7d271cb444 [SILDiagnostics] Fix an invalidation crash in DiagnoseStaticExclusivity.
Fix a crash when re-hashing the basic-block map would leave behind a dangling
mutable reference.

The irony that the language feature this pass implements would have caught this
issue statically is not lost on me.
2017-04-11 19:14:32 -07:00
Andrew Trick
b308daf311 [SILOpt] fix the ASAN issue in the new pass completely.
LLVM's ilist::erase is actually correct. It just implements a nonstandard remove
method that modifies it's iterator argument.

I forgot to add "continue" statements when fixing the iterator-invalidation problem.
2017-04-11 15:48:24 -07:00
Michael Gottesman
464b61fb36 [semantic-sil] Copy DIMemoryUseCollector.{cpp,h} => DIMemoryUseCollectorOwnership.{cpp,h} so I can update the passes that use this functionality one at a time. 2017-04-11 09:24:36 -07:00
swift-ci
6956926264 Merge pull request #8686 from rjmccall/access-enforcement-selection-pass 2017-04-11 00:49:29 -07:00
John McCall
b9676d2002 Add a SIL pass to select an access enforcement for allocated boxes.
Tests to come.
2017-04-11 03:10:51 -04:00
swift-ci
a0ca9290ce Merge pull request #8670 from devincoughlin/static-enforcement-rpo 2017-04-10 15:25:48 -07:00
Devin Coughlin
d6b99e17df [SILDiagnostics] Change DiagnoseStaticExclusivity to use PostOrderAnalysis
This allows the analysis to potentially be reused.
2017-04-10 14:40:52 -07:00
Andrew Trick
2eb6d48b1c [AccessMarker] Fix a reverse instruction iterator.
I reversed this loop's direction over the instruction list and forgot to change
the order of erasing an instruction with respect to advancing the iterator.

Thankfully ASAN is far smarter than I.

Converting between forward/reverse iterators makes the loop unreadable.
Add an iterator return value to BasicBlock::erase(SILInstruction*).
2017-04-10 14:08:59 -07:00
swift-ci
45fbd87a9b Merge pull request #8662 from devincoughlin/static-enforcement-update 2017-04-10 12:24:58 -07:00
Devin Coughlin
8649165372 [SILDiagnostics] Address style feedback in DiagnoseStaticExclusivity
Address the style aspects of Michael's feedback on
https://github.com/apple/swift/pull/8560
2017-04-10 11:35:14 -07:00
Andrew Trick
4355cad83e Add a pass to eliminate access markers. 2017-04-10 09:47:50 -07:00
Devin Coughlin
bee17f7838 [SILDiagnostics] Add static enforcement of Law of Exclusivity (#8560)
Add a diagnostic pass that emits errors when a violation of the "Law of
Exclusivity" is detected at compile time. The Law of Exclusivity requires
that the access duration of any access to an address not overlap
with an access to the same address unless both accesses are reads.

This pass relies on 'begin_access' and 'end_access' SIL instruction
markers inserted by SILGen to determine when an access to an address begins and
ends. It models the in-progress accesses with a map from storage locations to
the counts of read and write-like accesses in progress for that location.
2017-04-09 21:41:13 -07:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Michael Gottesman
2224584997 [semantic-arc-opts] Teach semantic arc opts how to handle (borrow (copy)) of a guaranteed argument.
rdar://29870610
2017-04-06 16:23:02 -07:00