Skip to content

cherry-pick patches for LLVM ilist changes #6009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions include/swift/SIL/SILBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
/// The ordered set of instructions in the SILBasicBlock.
InstListType InstList;

friend struct llvm::ilist_sentinel_traits<SILBasicBlock>;
friend struct llvm::ilist_traits<SILBasicBlock>;
SILBasicBlock() : Parent(nullptr) {}
void operator=(const SILBasicBlock &) = delete;
Expand Down Expand Up @@ -332,26 +331,17 @@ struct ilist_traits<::swift::SILBasicBlock>

private:
friend class ::swift::SILFunction;
mutable ilist_half_node<SILBasicBlock> Sentinel;

SILFunction *Parent;
using block_iterator = simple_ilist<SILBasicBlock>::iterator;

public:
SILBasicBlock *createSentinel() const {
return static_cast<SILBasicBlock *>(&Sentinel);
}
void destroySentinel(SILBasicBlock *) const {}

SILBasicBlock *provideInitialHead() const { return createSentinel(); }
SILBasicBlock *ensureHead(SILBasicBlock *) const { return createSentinel(); }
static void noteHead(SILBasicBlock *, SILBasicBlock *) {}
static void deleteNode(SILBasicBlock *BB) { BB->~SILBasicBlock(); }

void addNodeToList(SILBasicBlock *BB) {}

void transferNodesFromList(ilist_traits<SILBasicBlock> &SrcTraits,
ilist_iterator<SILBasicBlock> First,
ilist_iterator<SILBasicBlock> Last);
block_iterator First, block_iterator Last);

private:
static void createNode(const SILBasicBlock &);
Expand Down
11 changes: 0 additions & 11 deletions include/swift/SIL/SILCoverageMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,7 @@ struct ilist_traits<::swift::SILCoverageMap> :
public ilist_default_traits<::swift::SILCoverageMap> {
typedef ::swift::SILCoverageMap SILCoverageMap;

private:
mutable ilist_half_node<SILCoverageMap> Sentinel;

public:
SILCoverageMap *createSentinel() const {
return static_cast<SILCoverageMap*>(&Sentinel);
}
void destroySentinel(SILCoverageMap *) const {}

SILCoverageMap *provideInitialHead() const { return createSentinel(); }
SILCoverageMap *ensureHead(SILCoverageMap*) const { return createSentinel(); }
static void noteHead(SILCoverageMap*, SILCoverageMap*) {}
static void deleteNode(SILCoverageMap *VT) { VT->~SILCoverageMap(); }

private:
Expand Down
11 changes: 0 additions & 11 deletions include/swift/SIL/SILDefaultWitnessTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,7 @@ struct ilist_traits<::swift::SILDefaultWitnessTable> :
public ilist_default_traits<::swift::SILDefaultWitnessTable> {
typedef ::swift::SILDefaultWitnessTable SILDefaultWitnessTable;

private:
mutable ilist_half_node<SILDefaultWitnessTable> Sentinel;

public:
SILDefaultWitnessTable *createSentinel() const {
return static_cast<SILDefaultWitnessTable*>(&Sentinel);
}
void destroySentinel(SILDefaultWitnessTable *) const {}

SILDefaultWitnessTable *provideInitialHead() const { return createSentinel(); }
SILDefaultWitnessTable *ensureHead(SILDefaultWitnessTable*) const { return createSentinel(); }
static void noteHead(SILDefaultWitnessTable*, SILDefaultWitnessTable*) {}
static void deleteNode(SILDefaultWitnessTable *WT) { WT->~SILDefaultWitnessTable(); }

private:
Expand Down
11 changes: 0 additions & 11 deletions include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,18 +775,7 @@ struct ilist_traits<::swift::SILFunction> :
public ilist_default_traits<::swift::SILFunction> {
typedef ::swift::SILFunction SILFunction;

private:
mutable ilist_half_node<SILFunction> Sentinel;

public:
SILFunction *createSentinel() const {
return static_cast<SILFunction*>(&Sentinel);
}
void destroySentinel(SILFunction *) const {}

SILFunction *provideInitialHead() const { return createSentinel(); }
SILFunction *ensureHead(SILFunction*) const { return createSentinel(); }
static void noteHead(SILFunction*, SILFunction*) {}
static void deleteNode(SILFunction *V) { V->~SILFunction(); }

private:
Expand Down
13 changes: 0 additions & 13 deletions include/swift/SIL/SILGlobalVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,7 @@ struct ilist_traits<::swift::SILGlobalVariable> :
public ilist_default_traits<::swift::SILGlobalVariable> {
typedef ::swift::SILGlobalVariable SILGlobalVariable;

private:
mutable ilist_half_node<SILGlobalVariable> Sentinel;

public:
SILGlobalVariable *createSentinel() const {
return static_cast<SILGlobalVariable*>(&Sentinel);
}
void destroySentinel(SILGlobalVariable *) const {}

SILGlobalVariable *provideInitialHead() const { return createSentinel(); }
SILGlobalVariable *ensureHead(SILGlobalVariable*) const {
return createSentinel();
}
static void noteHead(SILGlobalVariable*, SILGlobalVariable*) {}
static void deleteNode(SILGlobalVariable *V) {}

private:
Expand Down
16 changes: 3 additions & 13 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class SILInstruction : public ValueBase,public llvm::ilist_node<SILInstruction>{
/// used for debug info and diagnostics.
SILDebugLocation Location;

friend llvm::ilist_sentinel_traits<SILInstruction>;
SILInstruction() = delete;
void operator=(const SILInstruction &) = delete;
void operator delete(void *Ptr, size_t) = delete;
Expand Down Expand Up @@ -5536,28 +5535,19 @@ struct ilist_traits<::swift::SILInstruction> :
using SILInstruction = ::swift::SILInstruction;

private:
mutable ilist_half_node<SILInstruction> Sentinel;

swift::SILBasicBlock *getContainingBlock();

public:
SILInstruction *createSentinel() const {
return static_cast<SILInstruction*>(&Sentinel);
}
void destroySentinel(SILInstruction *) const {}
using instr_iterator = simple_ilist<SILInstruction>::iterator;

SILInstruction *provideInitialHead() const { return createSentinel(); }
SILInstruction *ensureHead(SILInstruction*) const { return createSentinel(); }
static void noteHead(SILInstruction*, SILInstruction*) {}
public:
static void deleteNode(SILInstruction *V) {
SILInstruction::destroy(V);
}

void addNodeToList(SILInstruction *I);
void removeNodeFromList(SILInstruction *I);
void transferNodesFromList(ilist_traits<SILInstruction> &L2,
ilist_iterator<SILInstruction> first,
ilist_iterator<SILInstruction> last);
instr_iterator first, instr_iterator last);

private:
void createNode(const SILInstruction &);
Expand Down
12 changes: 0 additions & 12 deletions include/swift/SIL/SILVTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,6 @@ struct ilist_traits<::swift::SILVTable> :
public ilist_default_traits<::swift::SILVTable> {
typedef ::swift::SILVTable SILVTable;

private:
mutable ilist_half_node<SILVTable> Sentinel;

public:
SILVTable *createSentinel() const {
return static_cast<SILVTable*>(&Sentinel);
}
void destroySentinel(SILVTable *) const {}

SILVTable *provideInitialHead() const { return createSentinel(); }
SILVTable *ensureHead(SILVTable*) const { return createSentinel(); }
static void noteHead(SILVTable*, SILVTable*) {}
static void deleteNode(SILVTable *VT) { VT->~SILVTable(); }

private:
Expand Down
11 changes: 0 additions & 11 deletions include/swift/SIL/SILWitnessTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,7 @@ struct ilist_traits<::swift::SILWitnessTable> :
public ilist_default_traits<::swift::SILWitnessTable> {
typedef ::swift::SILWitnessTable SILWitnessTable;

private:
mutable ilist_half_node<SILWitnessTable> Sentinel;

public:
SILWitnessTable *createSentinel() const {
return static_cast<SILWitnessTable*>(&Sentinel);
}
void destroySentinel(SILWitnessTable *) const {}

SILWitnessTable *provideInitialHead() const { return createSentinel(); }
SILWitnessTable *ensureHead(SILWitnessTable*) const { return createSentinel(); }
static void noteHead(SILWitnessTable*, SILWitnessTable*) {}
static void deleteNode(SILWitnessTable *WT) { WT->~SILWitnessTable(); }

private:
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/Address.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "IRGen.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/ADT/ilist.h"
#include "llvm/IR/DerivedTypes.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ ArchetypeType *TypeConverter::getExemplarArchetype(ArchetypeType *t) {

// Otherwise, use this archetype as the exemplar for future similar
// archetypes.
Types.ExemplarArchetypeStorage.push_back({t});
Types.ExemplarArchetypeStorage.push_back(new ExemplarArchetype(t));
Types.ExemplarArchetypes.InsertNode(&Types.ExemplarArchetypeStorage.back(),
insertPos);
return t;
Expand Down
3 changes: 1 addition & 2 deletions lib/SIL/SILBasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ void SILBasicBlock::moveAfter(SILBasicBlock *After) {
void
llvm::ilist_traits<swift::SILBasicBlock>::
transferNodesFromList(llvm::ilist_traits<SILBasicBlock> &SrcTraits,
llvm::ilist_iterator<SILBasicBlock> First,
llvm::ilist_iterator<SILBasicBlock> Last) {
block_iterator First, block_iterator Last) {
assert(&Parent->getModule() == &SrcTraits.Parent->getModule() &&
"Module mismatch!");

Expand Down
3 changes: 1 addition & 2 deletions lib/SIL/SILInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ void llvm::ilist_traits<SILInstruction>::removeNodeFromList(SILInstruction *I) {

void llvm::ilist_traits<SILInstruction>::
transferNodesFromList(llvm::ilist_traits<SILInstruction> &L2,
llvm::ilist_iterator<SILInstruction> first,
llvm::ilist_iterator<SILInstruction> last) {
instr_iterator first, instr_iterator last) {
// If transferring instructions within the same basic block, no reason to
// update their parent pointers.
SILBasicBlock *ThisParent = getContainingBlock();
Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/Analysis/ARCAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,7 @@ SILInstruction *swift::findReleaseToMatchUnsafeGuaranteedValue(
RCFI.getRCIdentityRoot(UnsafeGuaranteedI->getOperand(0));

// Look before the "unsafeGuaranteedEnd".
for (auto ReverseIt = SILBasicBlock::reverse_iterator(
UnsafeGuaranteedEndI->getIterator()),
for (auto ReverseIt = ++UnsafeGuaranteedEndI->getIterator().getReverse(),
End = BB.rend();
ReverseIt != End; ++ReverseIt) {
SILInstruction &CurInst = *ReverseIt;
Expand Down
5 changes: 2 additions & 3 deletions lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ bool COWArrayOpt::isArrayValueReleasedBeforeMutate(
}

static SILInstruction *getInstBefore(SILInstruction *I) {
auto It = SILBasicBlock::reverse_iterator(I->getIterator());
auto It = ++I->getIterator().getReverse();
if (I->getParent()->rend() == It)
return nullptr;
return &*It;
Expand Down Expand Up @@ -939,8 +939,7 @@ stripValueProjections(SILValue V,
/// by the array bounds check elimination pass.
static SILInstruction *
findPrecedingCheckSubscriptOrMakeMutable(ApplyInst *GetElementAddr) {
for (auto ReverseIt =
SILBasicBlock::reverse_iterator(GetElementAddr->getIterator()),
for (auto ReverseIt = ++GetElementAddr->getIterator().getReverse(),
End = GetElementAddr->getParent()->rend();
ReverseIt != End; ++ReverseIt) {
auto Apply = dyn_cast<ApplyInst>(&*ReverseIt);
Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/Mandatory/GuaranteedARCOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ struct GuaranteedARCOptsVisitor

static SILBasicBlock::reverse_iterator
getPrevReverseIterator(SILInstruction *I) {
auto Iter = std::next(I->getIterator());
return std::next(SILBasicBlock::reverse_iterator(Iter));
return std::next(I->getIterator().getReverse());
}

bool GuaranteedARCOptsVisitor::visitDestroyAddrInst(DestroyAddrInst *DAI) {
Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@ SILCombiner::visitInjectEnumAddrInst(InjectEnumAddrInst *IEAI) {
return nullptr;
}

for (llvm::iplist<SILInstruction>::reverse_iterator InsIt(
CurrIns->getIterator());
for (auto InsIt = ++CurrIns->getIterator().getReverse();
InsIt != CurrBB->rend(); ++InsIt) {
SILInstruction *Ins = &*InsIt;
if (Ins == DataAddrInst) {
Expand Down
10 changes: 0 additions & 10 deletions lib/Sema/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,6 @@ struct ilist_traits<swift::constraints::Constraint>

static Element *createNode(const Element &V) = delete;
static void deleteNode(Element *V) { /* never deleted */ }

Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
static void destroySentinel(Element *) {}

Element *provideInitialHead() const { return createSentinel(); }
Element *ensureHead(Element *) const { return createSentinel(); }
static void noteHead(Element *, Element *) {}

private:
mutable ilist_half_node<Element> Sentinel;
};

} // end namespace llvm
Expand Down