Skip to content

Commit 476a859

Browse files
committed
---
yaml --- r: 343743 b: refs/heads/master-rebranch c: 3d0b12e h: refs/heads/master i: 343741: 813f4b6 343739: 2b80fed 343735: 96cbea2 343727: 0380443 343711: 1432671 343679: 7aebf3b
1 parent 15ee003 commit 476a859

File tree

10 files changed

+214
-84
lines changed

10 files changed

+214
-84
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 33011bb6c9d4c5721669b8f44159fb8bea10c5a2
1458+
refs/heads/master-rebranch: 3d0b12e7bc07e518d2bb9e13ae6460c46fd2877c
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/docs/SIL.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,9 @@ except that ``destroy_addr`` may be used even if ``%0`` is of an
25252525
address-only type. This does not deallocate memory; it only destroys the
25262526
pointed-to value, leaving the memory uninitialized.
25272527

2528-
If ``T`` is a trivial type, then ``destroy_addr`` is a no-op.
2528+
If ``T`` is a trivial type, then ``destroy_addr`` is a no-op. However, even a
2529+
memory location ``%a`` with a trivial type must not be accessed after a
2530+
``destroy_addr %a``.
25292531

25302532
index_addr
25312533
``````````

branches/master-rebranch/include/swift/SIL/MemoryLifetime.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,23 @@ class MemoryLocations {
131131
/// \endcode
132132
int parentIdx;
133133

134+
private:
135+
friend class MemoryLocations;
136+
134137
/// Used to decide if a location is completely covered by its sub-locations.
135138
///
136139
/// -1 means: not yet initialized.
137140
int numFieldsNotCoveredBySubfields = -1;
138141

142+
/// The same as ``numFieldsNotCoveredBySubfields``, just for non-trivial
143+
/// fields.
144+
///
145+
/// -1 means: not yet initialized.
146+
int numNonTrivialFieldsNotCovered = -1;
147+
139148
Location(SILValue val, unsigned index, int parentIdx = -1);
149+
150+
void updateFieldCounters(SILType ty, int increment);
140151
};
141152

142153
private:
@@ -156,6 +167,9 @@ class MemoryLocations {
156167
/// small. They can be handled separately with handleSingleBlockLocations().
157168
llvm::SmallVector<SingleValueInstruction *, 16> singleBlockLocations;
158169

170+
/// The bit-set of locations for which numNonTrivialFieldsNotCovered is > 0.
171+
Bits nonTrivialLocations;
172+
159173
public:
160174
MemoryLocations() {}
161175

@@ -220,6 +234,10 @@ class MemoryLocations {
220234
void handleSingleBlockLocations(
221235
std::function<void (SILBasicBlock *block)> handlerFunc);
222236

237+
/// Returns the set of locations for which have non trivial fields which are
238+
/// not covered by sub-fields.
239+
const Bits &getNonTrivialLocations();
240+
223241
/// Debug dump the MemoryLifetime internals.
224242
void dump() const;
225243

@@ -249,11 +267,6 @@ class MemoryLocations {
249267

250268
/// Calculates Location::numFieldsNotCoveredBySubfields
251269
void initFieldsCounter(Location &loc);
252-
253-
/// Only memory locations which store a non-trivial type are considered.
254-
bool shouldTrackLocation(SILType type, SILFunction *inFunction) {
255-
return !type.isTrivial(*inFunction);
256-
}
257270
};
258271

259272
/// The MemoryDataflow utility calculates global dataflow of memory locations.

branches/master-rebranch/lib/AST/ASTMangler.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,9 @@ void ASTMangler::appendOpaqueDeclName(const OpaqueTypeDecl *opaqueDecl) {
736736
if (canSymbolicReference(opaqueDecl)) {
737737
appendSymbolicReference(opaqueDecl);
738738
} else if (auto namingDecl = opaqueDecl->getNamingDecl()) {
739-
llvm::SaveAndRestore<CanGenericSignature> savedSignature(
740-
CurGenericSignature);
739+
CanGenericSignature savedSignature = CurGenericSignature;
741740
appendEntity(namingDecl);
741+
CurGenericSignature = savedSignature;
742742
appendOperator("QO");
743743
} else {
744744
llvm_unreachable("todo: independent opaque type decls");
@@ -2667,11 +2667,11 @@ void ASTMangler::appendConcreteProtocolConformance(
26672667
opaqueSignature->getConformanceAccessPath(opaqueTypeParam, proto);
26682668

26692669
// Append the conformance access path with the signature of the opaque type.
2670-
{
2671-
llvm::SaveAndRestore<CanGenericSignature> savedSignature(
2672-
CurGenericSignature, opaqueSignature->getCanonicalSignature());
2673-
appendDependentProtocolConformance(conformanceAccessPath);
2674-
}
2670+
CanGenericSignature savedSignature = CurGenericSignature;
2671+
CurGenericSignature = opaqueSignature->getCanonicalSignature();
2672+
appendDependentProtocolConformance(conformanceAccessPath);
2673+
CurGenericSignature = savedSignature;
2674+
26752675
appendType(canType);
26762676
appendOperator("HO");
26772677
} else {

0 commit comments

Comments
 (0)