Skip to content

Commit 48ecd6d

Browse files
committed
[Exclusivity] Enable SILGen access marker emission by default.
This has no measurable effect on benchmarks and does not affect standard library compile time.
1 parent 8366c61 commit 48ecd6d

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ class SILOptions {
150150
/// Emit checks to trap at run time when the law of exclusivity is violated.
151151
bool EnforceExclusivityDynamic = false;
152152

153-
/// Returns true when either static or dynamic exclusivity enforcement
154-
/// is enabled.
155-
bool isAnyExclusivityEnforcementEnabled() {
156-
return EnforceExclusivityStatic || EnforceExclusivityDynamic;
157-
}
158-
159153
/// Enable the mandatory semantic arc optimizer.
160154
bool EnableMandatorySemanticARCOpts = false;
161155

lib/SIL/SILVerifier.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,32 +1275,28 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
12751275
require(BAI->getType().isAddress(),
12761276
"begin_access operand must have address type");
12771277

1278-
// Any kind of access marker can be used in the raw stage if either kind
1279-
// of enforcement is enabled globally.
1278+
// Any kind of access marker can be used in the raw stage.
12801279
// After the raw stage, only dynamic access markers can be used, and
12811280
// only if dynamic enforcement is enabled globally.
12821281
// Eventually, we should allow access markers to persist in SIL, and
12831282
// even make them obligatory, but we'll need to update a bunch of
12841283
// passes first.
12851284
switch (BAI->getEnforcement()) {
12861285
case SILAccessEnforcement::Unknown:
1287-
require(F.getModule().getOptions().isAnyExclusivityEnforcementEnabled()
1288-
&& BAI->getModule().getStage() == SILStage::Raw,
1286+
require(BAI->getModule().getStage() == SILStage::Raw,
12891287
"access must have known enforcement outside raw stage");
12901288
break;
12911289

12921290
case SILAccessEnforcement::Static:
12931291
case SILAccessEnforcement::Unsafe:
1294-
require(F.getModule().getOptions().isAnyExclusivityEnforcementEnabled()
1295-
&& BAI->getModule().getStage() == SILStage::Raw,
1292+
require(BAI->getModule().getStage() == SILStage::Raw,
12961293
"non-dynamic enforcement is currently disallowed outside "
12971294
"raw stage");
12981295
break;
12991296

13001297
case SILAccessEnforcement::Dynamic:
1301-
require(F.getModule().getOptions().EnforceExclusivityDynamic ||
1302-
(F.getModule().getOptions().EnforceExclusivityStatic &&
1303-
BAI->getModule().getStage() == SILStage::Raw),
1298+
require(F.getModule().getOptions().EnforceExclusivityDynamic
1299+
|| BAI->getModule().getStage() == SILStage::Raw,
13041300
"dynamic access enforcement is only allowed after raw stage when "
13051301
"globally enabled");
13061302
break;

lib/SILGen/SILGenLValue.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ static bool shouldUseUnsafeEnforcement(VarDecl *var) {
135135

136136
Optional<SILAccessEnforcement>
137137
SILGenFunction::getStaticEnforcement(VarDecl *var) {
138-
if (getOptions().EnforceExclusivityStatic)
139-
return SILAccessEnforcement::Static;
140-
return None;
138+
return SILAccessEnforcement::Static;
141139
}
142140

143141
Optional<SILAccessEnforcement>
@@ -152,10 +150,7 @@ SILGenFunction::getDynamicEnforcement(VarDecl *var) {
152150

153151
Optional<SILAccessEnforcement>
154152
SILGenFunction::getUnknownEnforcement(VarDecl *var) {
155-
if (getOptions().EnforceExclusivityStatic ||
156-
getOptions().EnforceExclusivityDynamic)
157-
return SILAccessEnforcement::Unknown;
158-
return None;
153+
return SILAccessEnforcement::Unknown;
159154
}
160155

161156
/// SILGenLValue - An ASTVisitor for building logical lvalues.

lib/SILOptimizer/Mandatory/AccessMarkerElimination.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ struct AccessMarkerElimination : SILModuleTransform {
3535
// Don't bother doing anything unless some kind of exclusivity
3636
// enforcement is enabled.
3737
auto &M = *getModule();
38-
if (!M.getOptions().isAnyExclusivityEnforcementEnabled())
39-
return;
4038

4139
bool removedAny = false;
4240

0 commit comments

Comments
 (0)