Skip to content

Commit 0aa2eae

Browse files
committed
AccessEnforcementOpts high-level comments.
1 parent a5f44c5 commit 0aa2eae

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

lib/SILOptimizer/Transforms/AccessEnforcementOpts.cpp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212
///
13+
/// Pass order dependencies:
14+
///
15+
/// - Will benefit from running after AccessEnforcementSelection.
16+
///
17+
/// - Should run immediately before the AccessEnforcementWMO to share
18+
/// AccessedStorageAnalysis results.
19+
///
1320
/// This pass optimizes access enforcement as follows:
1421
///
15-
/// Access marker folding: Find begin/end access scopes that are uninterrupted
16-
/// by a potential conflicting access. Flag those as [nontracking] access.
22+
/// **Access marker folding**: Find begin/end access scopes that are
23+
/// uninterrupted by a potential conflicting access. Flag those as [nontracking]
24+
/// access.
1725
///
1826
/// Folding must prove that no dynamic conflicts occur inside of an access
1927
/// scope. That is, a scope has no "nested inner conflicts". The access itself
@@ -39,8 +47,15 @@
3947
/// any path to an access' end of scope has a potentially conflicting access,
4048
/// then that access is marked as a nested conflict.
4149
///
42-
/// Pass order dependencies:
43-
/// - Will benefit from running after AccessEnforcementSelection.
50+
/// **Local access marker removal**
51+
///
52+
/// When none of the local accesses on local storage (box/stack) have nested
53+
/// conflicts, then all the locall accesses may be removed. This is somwhat rare
54+
/// because static diagnostics already promote the obvious cases to static
55+
/// checks. However, there are two reasons that dynamic local markers may be
56+
/// removed: (1) inlining may cause closure access to become local access (2)
57+
/// local storage may truly escape, but none of the the local access scopes
58+
/// cross a call site.
4459
///
4560
/// TODO: Perform another run of AccessEnforcementSelection immediately before
4661
/// this pass. Currently, that pass only works well when run before
@@ -558,9 +573,23 @@ foldNonNestedAccesses(AccessConflictAnalysis::AccessMap &accessMap) {
558573
return changed;
559574
}
560575

576+
/// Perform local access marker elimination.
577+
///
561578
/// Eliminate accesses to uniquely identified local storage for which no
562579
/// accesses can have nested conflicts. This is only valid if the function's
563-
/// local storage cannot be potentially modified by unidentified access.
580+
/// local storage cannot be potentially modified by unidentified access:
581+
///
582+
/// - Arguments cannot alias with local storage, so accessing an argument has no
583+
/// effect on analysis of the current function. When a callee accesses an
584+
/// argument, AccessedStorageAnalysis will either map the accessed storage to
585+
/// a value in the caller's function, or mark it as unidentified.
586+
///
587+
/// - Stack or Box local storage could potentially be accessed via Unidentified
588+
/// access. (Some Unidentified accesses are for initialization or for
589+
/// temporary storage instead, but those should never have Dynamic
590+
/// enforcement). These accesses can only be eliminated when there is no
591+
/// Unidentified access within the function without the [no_nested_conflict]
592+
/// flag.
564593
///
565594
/// This simply invalidates the AccessMap result rather than erasing individual
566595
/// entries.

0 commit comments

Comments
 (0)