Skip to content

Commit 9964697

Browse files
committed
Update to match llvm r278513: share code for embedded sentinel traits.
Nothing at all should be changing here, this is just rearranging code.
1 parent 3fd92f8 commit 9964697

File tree

9 files changed

+36
-98
lines changed

9 files changed

+36
-98
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ namespace llvm {
316316
// ilist_traits for SILBasicBlock
317317
//===----------------------------------------------------------------------===//
318318

319+
template <>
320+
struct ilist_sentinel_traits<::swift::SILBasicBlock> :
321+
public ilist_half_embedded_sentinel_traits<::swift::SILBasicBlock> {};
322+
319323
template <>
320324
struct ilist_traits<::swift::SILBasicBlock> :
321325
public ilist_default_traits<::swift::SILBasicBlock> {
@@ -326,20 +330,11 @@ public ilist_default_traits<::swift::SILBasicBlock> {
326330

327331
private:
328332
friend class ::swift::SILFunction;
329-
mutable ilist_half_node<SILBasicBlock> Sentinel;
330333

331334
SILFunction *Parent;
332335

333336
public:
334337

335-
SILBasicBlock *createSentinel() const {
336-
return static_cast<SILBasicBlock*>(&Sentinel);
337-
}
338-
void destroySentinel(SILBasicBlock *) const {}
339-
340-
SILBasicBlock *provideInitialHead() const { return createSentinel(); }
341-
SILBasicBlock *ensureHead(SILBasicBlock*) const { return createSentinel(); }
342-
static void noteHead(SILBasicBlock*, SILBasicBlock*) {}
343338
static void deleteNode(SILBasicBlock *BB) { BB->~SILBasicBlock(); }
344339

345340
void addNodeToList(SILBasicBlock *BB) {

include/swift/SIL/SILCoverageMap.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,16 @@ namespace llvm {
138138
// ilist_traits for SILCoverageMap
139139
//===----------------------------------------------------------------------===//
140140

141+
template <>
142+
struct ilist_sentinel_traits<::swift::SILCoverageMap> :
143+
public ilist_half_embedded_sentinel_traits<::swift::SILCoverageMap> {};
144+
141145
template <>
142146
struct ilist_traits<::swift::SILCoverageMap> :
143147
public ilist_default_traits<::swift::SILCoverageMap> {
144148
typedef ::swift::SILCoverageMap SILCoverageMap;
145149

146-
private:
147-
mutable ilist_half_node<SILCoverageMap> Sentinel;
148-
149150
public:
150-
SILCoverageMap *createSentinel() const {
151-
return static_cast<SILCoverageMap*>(&Sentinel);
152-
}
153-
void destroySentinel(SILCoverageMap *) const {}
154-
155-
SILCoverageMap *provideInitialHead() const { return createSentinel(); }
156-
SILCoverageMap *ensureHead(SILCoverageMap*) const { return createSentinel(); }
157-
static void noteHead(SILCoverageMap*, SILCoverageMap*) {}
158151
static void deleteNode(SILCoverageMap *VT) { VT->~SILCoverageMap(); }
159152

160153
private:

include/swift/SIL/SILDefaultWitnessTable.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,16 @@ class SILDefaultWitnessTable : public llvm::ilist_node<SILDefaultWitnessTable>,
176176

177177
namespace llvm {
178178

179+
template <>
180+
struct ilist_sentinel_traits<::swift::SILDefaultWitnessTable> :
181+
public ilist_half_embedded_sentinel_traits<::swift::SILDefaultWitnessTable> {};
182+
179183
template <>
180184
struct ilist_traits<::swift::SILDefaultWitnessTable> :
181185
public ilist_default_traits<::swift::SILDefaultWitnessTable> {
182186
typedef ::swift::SILDefaultWitnessTable SILDefaultWitnessTable;
183187

184-
private:
185-
mutable ilist_half_node<SILDefaultWitnessTable> Sentinel;
186-
187188
public:
188-
SILDefaultWitnessTable *createSentinel() const {
189-
return static_cast<SILDefaultWitnessTable*>(&Sentinel);
190-
}
191-
void destroySentinel(SILDefaultWitnessTable *) const {}
192-
193-
SILDefaultWitnessTable *provideInitialHead() const { return createSentinel(); }
194-
SILDefaultWitnessTable *ensureHead(SILDefaultWitnessTable*) const { return createSentinel(); }
195-
static void noteHead(SILDefaultWitnessTable*, SILDefaultWitnessTable*) {}
196189
static void deleteNode(SILDefaultWitnessTable *WT) { WT->~SILDefaultWitnessTable(); }
197190

198191
private:

include/swift/SIL/SILFunction.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -749,23 +749,16 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
749749

750750
namespace llvm {
751751

752+
template <>
753+
struct ilist_sentinel_traits<::swift::SILFunction> :
754+
public ilist_half_embedded_sentinel_traits<::swift::SILFunction> {};
755+
752756
template <>
753757
struct ilist_traits<::swift::SILFunction> :
754758
public ilist_default_traits<::swift::SILFunction> {
755759
typedef ::swift::SILFunction SILFunction;
756760

757-
private:
758-
mutable ilist_half_node<SILFunction> Sentinel;
759-
760761
public:
761-
SILFunction *createSentinel() const {
762-
return static_cast<SILFunction*>(&Sentinel);
763-
}
764-
void destroySentinel(SILFunction *) const {}
765-
766-
SILFunction *provideInitialHead() const { return createSentinel(); }
767-
SILFunction *ensureHead(SILFunction*) const { return createSentinel(); }
768-
static void noteHead(SILFunction*, SILFunction*) {}
769762
static void deleteNode(SILFunction *V) { V->~SILFunction(); }
770763

771764
private:

include/swift/SIL/SILGlobalVariable.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,16 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
196196

197197
namespace llvm {
198198

199+
template <>
200+
struct ilist_sentinel_traits<::swift::SILGlobalVariable> :
201+
public ilist_half_embedded_sentinel_traits<::swift::SILGlobalVariable> {};
202+
199203
template <>
200204
struct ilist_traits<::swift::SILGlobalVariable> :
201205
public ilist_default_traits<::swift::SILGlobalVariable> {
202206
typedef ::swift::SILGlobalVariable SILGlobalVariable;
203207

204-
private:
205-
mutable ilist_half_node<SILGlobalVariable> Sentinel;
206-
207208
public:
208-
SILGlobalVariable *createSentinel() const {
209-
return static_cast<SILGlobalVariable*>(&Sentinel);
210-
}
211-
void destroySentinel(SILGlobalVariable *) const {}
212-
213-
SILGlobalVariable *provideInitialHead() const { return createSentinel(); }
214-
SILGlobalVariable *ensureHead(SILGlobalVariable*) const {
215-
return createSentinel();
216-
}
217-
static void noteHead(SILGlobalVariable*, SILGlobalVariable*) {}
218209
static void deleteNode(SILGlobalVariable *V) {}
219210

220211
private:

include/swift/SIL/SILInstruction.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5432,25 +5432,19 @@ SILFunction *ApplyInstBase<Impl, Base, false>::getCalleeFunction() const {
54325432

54335433
namespace llvm {
54345434

5435+
template <>
5436+
struct ilist_sentinel_traits<::swift::SILInstruction> :
5437+
public ilist_half_embedded_sentinel_traits<::swift::SILInstruction> {};
5438+
54355439
template <>
54365440
struct ilist_traits<::swift::SILInstruction> :
54375441
public ilist_default_traits<::swift::SILInstruction> {
54385442
using SILInstruction = ::swift::SILInstruction;
54395443

54405444
private:
5441-
mutable ilist_half_node<SILInstruction> Sentinel;
5442-
54435445
swift::SILBasicBlock *getContainingBlock();
54445446

54455447
public:
5446-
SILInstruction *createSentinel() const {
5447-
return static_cast<SILInstruction*>(&Sentinel);
5448-
}
5449-
void destroySentinel(SILInstruction *) const {}
5450-
5451-
SILInstruction *provideInitialHead() const { return createSentinel(); }
5452-
SILInstruction *ensureHead(SILInstruction*) const { return createSentinel(); }
5453-
static void noteHead(SILInstruction*, SILInstruction*) {}
54545448
static void deleteNode(SILInstruction *V) {
54555449
SILInstruction::destroy(V);
54565450
}

include/swift/SIL/SILVTable.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,15 @@ class SILVTable : public llvm::ilist_node<SILVTable>,
113113

114114
namespace llvm {
115115

116+
template <>
117+
struct ilist_sentinel_traits<::swift::SILVTable> :
118+
public ilist_half_embedded_sentinel_traits<::swift::SILVTable> {};
119+
116120
template <>
117121
struct ilist_traits<::swift::SILVTable> :
118122
public ilist_default_traits<::swift::SILVTable> {
119123
typedef ::swift::SILVTable SILVTable;
120124

121-
private:
122-
mutable ilist_half_node<SILVTable> Sentinel;
123-
124-
public:
125-
SILVTable *createSentinel() const {
126-
return static_cast<SILVTable*>(&Sentinel);
127-
}
128-
void destroySentinel(SILVTable *) const {}
129-
130-
SILVTable *provideInitialHead() const { return createSentinel(); }
131-
SILVTable *ensureHead(SILVTable*) const { return createSentinel(); }
132-
static void noteHead(SILVTable*, SILVTable*) {}
133125
static void deleteNode(SILVTable *VT) { VT->~SILVTable(); }
134126

135127
private:

include/swift/SIL/SILWitnessTable.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,16 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
281281

282282
namespace llvm {
283283

284+
template <>
285+
struct ilist_sentinel_traits<::swift::SILWitnessTable> :
286+
public ilist_half_embedded_sentinel_traits<::swift::SILWitnessTable> {};
287+
284288
template <>
285289
struct ilist_traits<::swift::SILWitnessTable> :
286290
public ilist_default_traits<::swift::SILWitnessTable> {
287291
typedef ::swift::SILWitnessTable SILWitnessTable;
288292

289-
private:
290-
mutable ilist_half_node<SILWitnessTable> Sentinel;
291-
292293
public:
293-
SILWitnessTable *createSentinel() const {
294-
return static_cast<SILWitnessTable*>(&Sentinel);
295-
}
296-
void destroySentinel(SILWitnessTable *) const {}
297-
298-
SILWitnessTable *provideInitialHead() const { return createSentinel(); }
299-
SILWitnessTable *ensureHead(SILWitnessTable*) const { return createSentinel(); }
300-
static void noteHead(SILWitnessTable*, SILWitnessTable*) {}
301294
static void deleteNode(SILWitnessTable *WT) { WT->~SILWitnessTable(); }
302295

303296
private:

lib/Sema/Constraint.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,23 +582,17 @@ class Constraint final : public llvm::ilist_node<Constraint>,
582582
namespace llvm {
583583

584584
/// Specialization of \c ilist_traits for constraints.
585+
template<>
586+
struct ilist_sentinel_traits<swift::constraints::Constraint>
587+
: public ilist_half_embedded_sentinel_traits<swift::constraints::Constraint> {};
588+
585589
template<>
586590
struct ilist_traits<swift::constraints::Constraint>
587591
: public ilist_default_traits<swift::constraints::Constraint> {
588592
typedef swift::constraints::Constraint Element;
589593

590594
static Element *createNode(const Element &V) = delete;
591595
static void deleteNode(Element *V) { /* never deleted */ }
592-
593-
Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
594-
static void destroySentinel(Element *) {}
595-
596-
Element *provideInitialHead() const { return createSentinel(); }
597-
Element *ensureHead(Element *) const { return createSentinel(); }
598-
static void noteHead(Element *, Element *) {}
599-
600-
private:
601-
mutable ilist_half_node<Element> Sentinel;
602596
};
603597

604598
} // end namespace llvm

0 commit comments

Comments
 (0)