Skip to content

Commit 03e8394

Browse files
authored
Merge pull request #6009 from bob-wilson/ilist-changes
cherry-pick patches for LLVM ilist changes
2 parents af6dc69 + 872276e commit 03e8394

17 files changed

+14
-118
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
4545
/// The ordered set of instructions in the SILBasicBlock.
4646
InstListType InstList;
4747

48-
friend struct llvm::ilist_sentinel_traits<SILBasicBlock>;
4948
friend struct llvm::ilist_traits<SILBasicBlock>;
5049
SILBasicBlock() : Parent(nullptr) {}
5150
void operator=(const SILBasicBlock &) = delete;
@@ -332,26 +331,17 @@ struct ilist_traits<::swift::SILBasicBlock>
332331

333332
private:
334333
friend class ::swift::SILFunction;
335-
mutable ilist_half_node<SILBasicBlock> Sentinel;
336334

337335
SILFunction *Parent;
336+
using block_iterator = simple_ilist<SILBasicBlock>::iterator;
338337

339338
public:
340-
SILBasicBlock *createSentinel() const {
341-
return static_cast<SILBasicBlock *>(&Sentinel);
342-
}
343-
void destroySentinel(SILBasicBlock *) const {}
344-
345-
SILBasicBlock *provideInitialHead() const { return createSentinel(); }
346-
SILBasicBlock *ensureHead(SILBasicBlock *) const { return createSentinel(); }
347-
static void noteHead(SILBasicBlock *, SILBasicBlock *) {}
348339
static void deleteNode(SILBasicBlock *BB) { BB->~SILBasicBlock(); }
349340

350341
void addNodeToList(SILBasicBlock *BB) {}
351342

352343
void transferNodesFromList(ilist_traits<SILBasicBlock> &SrcTraits,
353-
ilist_iterator<SILBasicBlock> First,
354-
ilist_iterator<SILBasicBlock> Last);
344+
block_iterator First, block_iterator Last);
355345

356346
private:
357347
static void createNode(const SILBasicBlock &);

include/swift/SIL/SILCoverageMap.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,7 @@ struct ilist_traits<::swift::SILCoverageMap> :
143143
public ilist_default_traits<::swift::SILCoverageMap> {
144144
typedef ::swift::SILCoverageMap SILCoverageMap;
145145

146-
private:
147-
mutable ilist_half_node<SILCoverageMap> Sentinel;
148-
149146
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*) {}
158147
static void deleteNode(SILCoverageMap *VT) { VT->~SILCoverageMap(); }
159148

160149
private:

include/swift/SIL/SILDefaultWitnessTable.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,7 @@ struct ilist_traits<::swift::SILDefaultWitnessTable> :
181181
public ilist_default_traits<::swift::SILDefaultWitnessTable> {
182182
typedef ::swift::SILDefaultWitnessTable SILDefaultWitnessTable;
183183

184-
private:
185-
mutable ilist_half_node<SILDefaultWitnessTable> Sentinel;
186-
187184
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*) {}
196185
static void deleteNode(SILDefaultWitnessTable *WT) { WT->~SILDefaultWitnessTable(); }
197186

198187
private:

include/swift/SIL/SILFunction.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -775,18 +775,7 @@ struct ilist_traits<::swift::SILFunction> :
775775
public ilist_default_traits<::swift::SILFunction> {
776776
typedef ::swift::SILFunction SILFunction;
777777

778-
private:
779-
mutable ilist_half_node<SILFunction> Sentinel;
780-
781778
public:
782-
SILFunction *createSentinel() const {
783-
return static_cast<SILFunction*>(&Sentinel);
784-
}
785-
void destroySentinel(SILFunction *) const {}
786-
787-
SILFunction *provideInitialHead() const { return createSentinel(); }
788-
SILFunction *ensureHead(SILFunction*) const { return createSentinel(); }
789-
static void noteHead(SILFunction*, SILFunction*) {}
790779
static void deleteNode(SILFunction *V) { V->~SILFunction(); }
791780

792781
private:

include/swift/SIL/SILGlobalVariable.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,7 @@ struct ilist_traits<::swift::SILGlobalVariable> :
201201
public ilist_default_traits<::swift::SILGlobalVariable> {
202202
typedef ::swift::SILGlobalVariable SILGlobalVariable;
203203

204-
private:
205-
mutable ilist_half_node<SILGlobalVariable> Sentinel;
206-
207204
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*) {}
218205
static void deleteNode(SILGlobalVariable *V) {}
219206

220207
private:

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class SILInstruction : public ValueBase,public llvm::ilist_node<SILInstruction>{
7777
/// used for debug info and diagnostics.
7878
SILDebugLocation Location;
7979

80-
friend llvm::ilist_sentinel_traits<SILInstruction>;
8180
SILInstruction() = delete;
8281
void operator=(const SILInstruction &) = delete;
8382
void operator delete(void *Ptr, size_t) = delete;
@@ -5536,28 +5535,19 @@ struct ilist_traits<::swift::SILInstruction> :
55365535
using SILInstruction = ::swift::SILInstruction;
55375536

55385537
private:
5539-
mutable ilist_half_node<SILInstruction> Sentinel;
5540-
55415538
swift::SILBasicBlock *getContainingBlock();
55425539

5543-
public:
5544-
SILInstruction *createSentinel() const {
5545-
return static_cast<SILInstruction*>(&Sentinel);
5546-
}
5547-
void destroySentinel(SILInstruction *) const {}
5540+
using instr_iterator = simple_ilist<SILInstruction>::iterator;
55485541

5549-
SILInstruction *provideInitialHead() const { return createSentinel(); }
5550-
SILInstruction *ensureHead(SILInstruction*) const { return createSentinel(); }
5551-
static void noteHead(SILInstruction*, SILInstruction*) {}
5542+
public:
55525543
static void deleteNode(SILInstruction *V) {
55535544
SILInstruction::destroy(V);
55545545
}
55555546

55565547
void addNodeToList(SILInstruction *I);
55575548
void removeNodeFromList(SILInstruction *I);
55585549
void transferNodesFromList(ilist_traits<SILInstruction> &L2,
5559-
ilist_iterator<SILInstruction> first,
5560-
ilist_iterator<SILInstruction> last);
5550+
instr_iterator first, instr_iterator last);
55615551

55625552
private:
55635553
void createNode(const SILInstruction &);

include/swift/SIL/SILVTable.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,6 @@ struct ilist_traits<::swift::SILVTable> :
118118
public ilist_default_traits<::swift::SILVTable> {
119119
typedef ::swift::SILVTable SILVTable;
120120

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*) {}
133121
static void deleteNode(SILVTable *VT) { VT->~SILVTable(); }
134122

135123
private:

include/swift/SIL/SILWitnessTable.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,18 +286,7 @@ struct ilist_traits<::swift::SILWitnessTable> :
286286
public ilist_default_traits<::swift::SILWitnessTable> {
287287
typedef ::swift::SILWitnessTable SILWitnessTable;
288288

289-
private:
290-
mutable ilist_half_node<SILWitnessTable> Sentinel;
291-
292289
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*) {}
301290
static void deleteNode(SILWitnessTable *WT) { WT->~SILWitnessTable(); }
302291

303292
private:

lib/IRGen/Address.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "IRGen.h"
2121
#include "llvm/IR/Value.h"
2222
#include "llvm/IR/Argument.h"
23+
#include "llvm/IR/Function.h"
2324
#include "llvm/IR/Instruction.h"
2425
#include "llvm/ADT/ilist.h"
2526
#include "llvm/IR/DerivedTypes.h"

lib/IRGen/GenType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ ArchetypeType *TypeConverter::getExemplarArchetype(ArchetypeType *t) {
11051105

11061106
// Otherwise, use this archetype as the exemplar for future similar
11071107
// archetypes.
1108-
Types.ExemplarArchetypeStorage.push_back({t});
1108+
Types.ExemplarArchetypeStorage.push_back(new ExemplarArchetype(t));
11091109
Types.ExemplarArchetypes.InsertNode(&Types.ExemplarArchetypeStorage.back(),
11101110
insertPos);
11111111
return t;

lib/SIL/SILBasicBlock.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ void SILBasicBlock::moveAfter(SILBasicBlock *After) {
170170
void
171171
llvm::ilist_traits<swift::SILBasicBlock>::
172172
transferNodesFromList(llvm::ilist_traits<SILBasicBlock> &SrcTraits,
173-
llvm::ilist_iterator<SILBasicBlock> First,
174-
llvm::ilist_iterator<SILBasicBlock> Last) {
173+
block_iterator First, block_iterator Last) {
175174
assert(&Parent->getModule() == &SrcTraits.Parent->getModule() &&
176175
"Module mismatch!");
177176

lib/SIL/SILInstruction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ void llvm::ilist_traits<SILInstruction>::removeNodeFromList(SILInstruction *I) {
7979

8080
void llvm::ilist_traits<SILInstruction>::
8181
transferNodesFromList(llvm::ilist_traits<SILInstruction> &L2,
82-
llvm::ilist_iterator<SILInstruction> first,
83-
llvm::ilist_iterator<SILInstruction> last) {
82+
instr_iterator first, instr_iterator last) {
8483
// If transferring instructions within the same basic block, no reason to
8584
// update their parent pointers.
8685
SILBasicBlock *ThisParent = getContainingBlock();

lib/SILOptimizer/Analysis/ARCAnalysis.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,8 +1137,7 @@ SILInstruction *swift::findReleaseToMatchUnsafeGuaranteedValue(
11371137
RCFI.getRCIdentityRoot(UnsafeGuaranteedI->getOperand(0));
11381138

11391139
// Look before the "unsafeGuaranteedEnd".
1140-
for (auto ReverseIt = SILBasicBlock::reverse_iterator(
1141-
UnsafeGuaranteedEndI->getIterator()),
1140+
for (auto ReverseIt = ++UnsafeGuaranteedEndI->getIterator().getReverse(),
11421141
End = BB.rend();
11431142
ReverseIt != End; ++ReverseIt) {
11441143
SILInstruction &CurInst = *ReverseIt;

lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ bool COWArrayOpt::isArrayValueReleasedBeforeMutate(
907907
}
908908

909909
static SILInstruction *getInstBefore(SILInstruction *I) {
910-
auto It = SILBasicBlock::reverse_iterator(I->getIterator());
910+
auto It = ++I->getIterator().getReverse();
911911
if (I->getParent()->rend() == It)
912912
return nullptr;
913913
return &*It;
@@ -939,8 +939,7 @@ stripValueProjections(SILValue V,
939939
/// by the array bounds check elimination pass.
940940
static SILInstruction *
941941
findPrecedingCheckSubscriptOrMakeMutable(ApplyInst *GetElementAddr) {
942-
for (auto ReverseIt =
943-
SILBasicBlock::reverse_iterator(GetElementAddr->getIterator()),
942+
for (auto ReverseIt = ++GetElementAddr->getIterator().getReverse(),
944943
End = GetElementAddr->getParent()->rend();
945944
ReverseIt != End; ++ReverseIt) {
946945
auto Apply = dyn_cast<ApplyInst>(&*ReverseIt);

lib/SILOptimizer/Mandatory/GuaranteedARCOpts.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ struct GuaranteedARCOptsVisitor
3232

3333
static SILBasicBlock::reverse_iterator
3434
getPrevReverseIterator(SILInstruction *I) {
35-
auto Iter = std::next(I->getIterator());
36-
return std::next(SILBasicBlock::reverse_iterator(Iter));
35+
return std::next(I->getIterator().getReverse());
3736
}
3837

3938
bool GuaranteedARCOptsVisitor::visitDestroyAddrInst(DestroyAddrInst *DAI) {

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,7 @@ SILCombiner::visitInjectEnumAddrInst(InjectEnumAddrInst *IEAI) {
861861
return nullptr;
862862
}
863863

864-
for (llvm::iplist<SILInstruction>::reverse_iterator InsIt(
865-
CurrIns->getIterator());
864+
for (auto InsIt = ++CurrIns->getIterator().getReverse();
866865
InsIt != CurrBB->rend(); ++InsIt) {
867866
SILInstruction *Ins = &*InsIt;
868867
if (Ins == DataAddrInst) {

lib/Sema/Constraint.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,16 +586,6 @@ struct ilist_traits<swift::constraints::Constraint>
586586

587587
static Element *createNode(const Element &V) = delete;
588588
static void deleteNode(Element *V) { /* never deleted */ }
589-
590-
Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
591-
static void destroySentinel(Element *) {}
592-
593-
Element *provideInitialHead() const { return createSentinel(); }
594-
Element *ensureHead(Element *) const { return createSentinel(); }
595-
static void noteHead(Element *, Element *) {}
596-
597-
private:
598-
mutable ilist_half_node<Element> Sentinel;
599589
};
600590

601591
} // end namespace llvm

0 commit comments

Comments
 (0)