Emit unenforced access markers in SILGen for accesses to local temporaries.

These accesses can't be recognized as obviously local temporaries in the
verification pass, so the only way to exhaustively verify exclusivity is by
added unenforced markers.

SILGen currently only emits unenforced markers under -verify-exlcusivity. Once
opaque values is the only supported SILGen mode, then we should turn the markers
on by default (SILGen should not have different modes of operation).
This commit is contained in:
Andrew Trick
2017-12-11 19:44:36 -08:00
parent 34a968c334
commit 00b5a9db79
6 changed files with 232 additions and 21 deletions

View File

@@ -14,6 +14,7 @@
#include "Cleanup.h"
#include "ExitableFullExpr.h"
#include "Initialization.h"
#include "LValue.h"
#include "RValue.h"
#include "SILGen.h"
#include "Scope.h"
@@ -2156,9 +2157,13 @@ void PatternMatchEmission::emitEnumElementDispatch(
SILValue boxedValue = SGF.B.createProjectBox(loc, origCMV.getValue(), 0);
eltTL = &SGF.getTypeLowering(boxedValue->getType());
if (eltTL->isLoadable()) {
UnenforcedAccess access;
SILValue accessAddress =
access.beginAccess(SGF, loc, boxedValue, SILAccessKind::Read);
ManagedValue newLoadedBoxValue = SGF.B.createLoadBorrow(
loc, ManagedValue::forUnmanaged(boxedValue));
loc, ManagedValue::forUnmanaged(accessAddress));
boxedValue = newLoadedBoxValue.getUnmanagedValue();
access.endAccess(SGF);
}
// The boxed value may be shared, so we always have to copy it.