@@ -89,14 +89,17 @@ class SILLayout final : public llvm::FoldingSetNode,
8989
9090 enum : unsigned {
9191 IsMutable = 0x1 ,
92+ CapturesGenericEnvironment = 0x2 ,
9293 };
9394
94- static constexpr const unsigned NumFlags = 1 ;
95+ static constexpr const unsigned NumFlags = 2 ;
9596
96- static unsigned getFlagsValue (bool Mutable) {
97+ static unsigned getFlagsValue (bool Mutable, bool CapturesGenerics ) {
9798 unsigned flags = 0 ;
9899 if (Mutable)
99100 flags |= IsMutable;
101+ if (CapturesGenerics)
102+ flags |= CapturesGenericEnvironment;
100103
101104 assert (flags >> NumFlags == 0
102105 && " more flags than flag bits?!" );
@@ -109,15 +112,17 @@ class SILLayout final : public llvm::FoldingSetNode,
109112 unsigned NumFields;
110113
111114 SILLayout (CanGenericSignature Signature,
112- ArrayRef<SILField> Fields);
115+ ArrayRef<SILField> Fields,
116+ bool CapturesGenericEnvironment);
113117
114118 SILLayout (const SILLayout &) = delete ;
115119 SILLayout &operator =(const SILLayout &) = delete ;
116120public:
117121 // / Get or create a layout.
118122 static SILLayout *get (ASTContext &C,
119123 CanGenericSignature Generics,
120- ArrayRef<SILField> Fields);
124+ ArrayRef<SILField> Fields,
125+ bool CapturesGenericEnvironment);
121126
122127 // / Get the generic signature in which this layout exists.
123128 CanGenericSignature getGenericSignature () const {
@@ -129,6 +134,12 @@ class SILLayout final : public llvm::FoldingSetNode,
129134 return GenericSigAndFlags.getInt () & IsMutable;
130135 }
131136
137+ // / True if the layout captures the generic arguments it is substituted with
138+ // / and can provide generic bindings when passed as a closure argument.
139+ bool capturesGenericEnvironment () const {
140+ return GenericSigAndFlags.getInt () & CapturesGenericEnvironment;
141+ }
142+
132143 // / Get the fields inside the layout.
133144 ArrayRef<SILField> getFields () const {
134145 return llvm::makeArrayRef (getTrailingObjects<SILField>(), NumFields);
@@ -137,11 +148,13 @@ class SILLayout final : public llvm::FoldingSetNode,
137148 // / Produce a profile of this layout, for use in a folding set.
138149 static void Profile (llvm::FoldingSetNodeID &id,
139150 CanGenericSignature Generics,
140- ArrayRef<SILField> Fields);
151+ ArrayRef<SILField> Fields,
152+ bool CapturesGenericEnvironment);
141153
142154 // / Produce a profile of this locator, for use in a folding set.
143155 void Profile (llvm::FoldingSetNodeID &id) {
144- Profile (id, getGenericSignature (), getFields ());
156+ Profile (id, getGenericSignature (), getFields (),
157+ capturesGenericEnvironment ());
145158 }
146159};
147160
0 commit comments