@@ -989,8 +989,13 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
989
989
// / The allocator for the connection graphs in Function2ConGraph.
990
990
llvm::SpecificBumpPtrAllocator<FunctionInfo> Allocator;
991
991
992
+ // TODO: Use per-function caches, at least for Resilient types, to use Maximal
993
+ // expansion.
994
+
992
995
// / Cache for isPointer().
993
996
PointerKindCache pointerKindCache;
997
+ // / Cache for checking the aggregate pointerness of class properties.
998
+ PointerKindCache classPropertiesKindCache;
994
999
995
1000
SILModule *M;
996
1001
@@ -1014,6 +1019,12 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
1014
1019
1015
1020
PointerKind findCachedPointerKind (SILType Ty, const SILFunction &F) const ;
1016
1021
1022
+ PointerKind findClassPropertiesPointerKind (SILType Ty,
1023
+ const SILFunction &F) const ;
1024
+
1025
+ PointerKind findCachedClassPropertiesKind (SILType Ty,
1026
+ const SILFunction &F) const ;
1027
+
1017
1028
// Returns true if the type \p Ty must be a reference or must transitively
1018
1029
// contain a reference and no other pointer or address type.
1019
1030
bool hasReferenceOnly (SILType Ty, const SILFunction &F) const {
@@ -1114,6 +1125,10 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
1114
1125
bool canEscapeToUsePoint (SILValue value, SILInstruction *usePoint,
1115
1126
ConnectionGraph *conGraph);
1116
1127
1128
+ // / Common implementation for mayReleaseReferenceContent and
1129
+ // / mayReleaseAddressContent.
1130
+ bool mayReleaseContent (SILValue releasedPtr, SILValue liveAddress);
1131
+
1117
1132
friend struct ::CGForDotView;
1118
1133
1119
1134
public:
@@ -1163,8 +1178,38 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
1163
1178
bool canEscapeTo (SILValue V, DestroyValueInst *DVI);
1164
1179
1165
1180
// / Return true if \p releasedReference deinitialization may release memory
1166
- // / pointed to by \p accessedAddress.
1167
- bool mayReleaseContent (SILValue releasedReference, SILValue accessedAddress);
1181
+ // / pointed to by \p liveAddress.
1182
+ // /
1183
+ // / This determines whether a direct release of \p releasedReference, such as
1184
+ // / destroy_value or strong_release may release memory pointed to by \p
1185
+ // / liveAddress. It can also be used to determine whether passing a
1186
+ // / reference-type call argument may release \p liveAddress.
1187
+ // /
1188
+ // / This does not distinguish between a call that releases \p
1189
+ // / releasedReference directly, vs. a call that releases one of indirect
1190
+ // / references.The side effects of releasing any object reachable from \p
1191
+ // / releasedReference are a strict subset of the side effects of directly
1192
+ // / releasing the parent reference.
1193
+ bool mayReleaseReferenceContent (SILValue releasedReference,
1194
+ SILValue liveAddress) {
1195
+ assert (!releasedReference->getType ().isAddress () &&
1196
+ " expected a potentially nontrivial value, not an address" );
1197
+ return mayReleaseContent (releasedReference, liveAddress);
1198
+ }
1199
+
1200
+ // / Return true if accessing memory at \p accessedAddress may release memory
1201
+ // / pointed to by \p liveAddress.
1202
+ // /
1203
+ // / This makes sense for determining whether accessing indirect call argument
1204
+ // / \p accessedAddress may release memory pointed to by \p liveAddress.
1205
+ // /
1206
+ // / "Access" to the memory can be any release of a reference pointed to by \p
1207
+ // / accessedAddress, so '@in' and '@inout' are handled the same.
1208
+ bool mayReleaseAddressContent (SILValue accessedAddress,
1209
+ SILValue liveAddress) {
1210
+ assert (accessedAddress->getType ().isAddress () && " expected an address" );
1211
+ return mayReleaseContent (accessedAddress, liveAddress);
1212
+ }
1168
1213
1169
1214
// / Returns true if the pointers \p V1 and \p V2 can possibly point to the
1170
1215
// / same memory.
0 commit comments