Skip to content
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
2 changes: 2 additions & 0 deletions include/swift/SILOptimizer/Analysis/EscapeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
case EscapeState::Global:
return true;
}

llvm_unreachable("Unhandled EscapeState in switch.");
}

/// Returns the content node if of this node if it exists in the graph.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Analysis/IVAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace swift {
class IVInfo : public SCCVisitor<IVInfo> {
public:
typedef llvm::SmallVectorImpl<ValueBase *> SCCType;
friend class SCCVisitor;
friend SCCVisitor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right way to fix this is just friend SCCVisitor;, not to make the visit method public.

Copy link
Contributor Author

@hughbe hughbe Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error: “class template has already been declared as a non-class template”

I think the fix is to change this to friend class SCCVisitor<IVInfo> which compiles in VS. I'm running a full build now to make sure.

EDIT: friend SCCVisitor also works, so I went for your suggestion instead


public:

Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/ARC/ARCRegionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ static bool isARCSignificantTerminator(TermInst *TI) {
case TermKind::CheckedCastAddrBranchInst:
return true;
}

llvm_unreachable("Unhandled TermKind in switch.");
}

// Visit each one of our predecessor regions and see if any are blocks that can
Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ static bool isARCSignificantTerminator(TermInst *TI) {
case TermKind::CheckedCastAddrBranchInst:
return true;
}

llvm_unreachable("Unhandled TermKind in switch.");
}

/// Analyze a single BB for refcount inc/dec instructions.
Expand Down
36 changes: 36 additions & 0 deletions lib/SILOptimizer/ARC/RefCountState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ bool BottomUpRefCountState::isRefCountStateModified() const {
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled TermKind in switch.");
}

/// Returns true if given the current lattice state, do we care if the value
Expand All @@ -155,6 +157,8 @@ bool BottomUpRefCountState::valueCanBeDecrementedGivenLatticeState() const {
case LatticeState::Decremented:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// If advance the state's sequence appropriately for a decrement. If we do
Expand All @@ -169,6 +173,8 @@ bool BottomUpRefCountState::handleDecrement() {
case LatticeState::Decremented:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Returns true if given the current lattice state, do we care if the value we
Expand All @@ -182,6 +188,8 @@ bool BottomUpRefCountState::valueCanBeUsedGivenLatticeState() const {
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Given the current lattice state, if we have seen a use, advance the
Expand All @@ -202,6 +210,8 @@ bool BottomUpRefCountState::handleUser(
case LatticeState::None:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Returns true if given the current lattice state, do we care if the value
Expand All @@ -216,6 +226,8 @@ valueCanBeGuaranteedUsedGivenLatticeState() const {
case LatticeState::MightBeUsed:
return true;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Given the current lattice state, if we have seen a use, advance the
Expand All @@ -242,6 +254,8 @@ bool BottomUpRefCountState::handleGuaranteedUser(
case LatticeState::None:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

// Returns true if the passed in ref count inst matches the ref count inst
Expand Down Expand Up @@ -279,6 +293,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) {
case LatticeState::MightBeDecremented:
return true;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

bool BottomUpRefCountState::merge(const BottomUpRefCountState &Other) {
Expand Down Expand Up @@ -577,6 +593,8 @@ bool TopDownRefCountState::isRefCountStateModified() const {
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Returns true if given the current lattice state, do we care if the value
Expand All @@ -590,6 +608,8 @@ bool TopDownRefCountState::valueCanBeDecrementedGivenLatticeState() const {
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// If advance the state's sequence appropriately for a decrement. If we do
Expand All @@ -606,6 +626,8 @@ bool TopDownRefCountState::handleDecrement(
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Returns true if given the current lattice state, do we care if the value
Expand All @@ -619,6 +641,8 @@ bool TopDownRefCountState::valueCanBeUsedGivenLatticeState() const {
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Given the current lattice state, if we have seen a use, advance the
Expand All @@ -639,6 +663,8 @@ bool TopDownRefCountState::handleUser(SILInstruction *PotentialUser,
case LatticeState::MightBeUsed:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Returns true if given the current lattice state, do we care if the value
Expand All @@ -654,6 +680,8 @@ valueCanBeGuaranteedUsedGivenLatticeState() const {
case LatticeState::MightBeDecremented:
return true;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

/// Given the current lattice state, if we have seen a use, advance the
Expand All @@ -680,6 +708,8 @@ bool TopDownRefCountState::handleGuaranteedUser(
case LatticeState::None:
return false;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

// Returns true if the passed in ref count inst matches the ref count inst
Expand Down Expand Up @@ -713,6 +743,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) {
case LatticeState::MightBeUsed:
return true;
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

bool TopDownRefCountState::merge(const TopDownRefCountState &Other) {
Expand Down Expand Up @@ -908,6 +940,8 @@ raw_ostream &operator<<(raw_ostream &OS,
case LatticeState::MightBeDecremented:
return OS << "MightBeDecremented";
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
Expand All @@ -923,6 +957,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
case LatticeState::MightBeDecremented:
return OS << "MightBeDecremented";
}

llvm_unreachable("Unhandled LatticeState in switch.");
}

} // end namespace llvm
2 changes: 2 additions & 0 deletions lib/SILOptimizer/Analysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &OS, AliasResult R) {
case AliasResult::PartialAlias: return OS << "PartialAlias";
case AliasResult::MustAlias: return OS << "MustAlias";
}

llvm_unreachable("Unhandled AliasResult in switch.");
}

SILValue getAccessedMemory(SILInstruction *User) {
Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static bool isSafeNonExitTerminator(TermInst *TI) {
case TermKind::TryApplyInst:
return false;
}

llvm_unreachable("Unhandled TermKind in switch.");
}

static bool isTrapNoReturnFunction(ApplyInst *AI) {
Expand Down
4 changes: 4 additions & 0 deletions lib/SILOptimizer/Analysis/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ namespace llvm {
case CGForDotView::PointsTo: return "";
case CGForDotView::Deferred: return "color=\"gray\"";
}

llvm_unreachable("Unhandled CGForDotView in switch.");
}
};
} // end llvm namespace
Expand Down Expand Up @@ -823,6 +825,8 @@ const char *EscapeAnalysis::CGNode::getTypeStr() const {
case NodeType::Argument: return "Arg";
case NodeType::Return: return "Ret";
}

llvm_unreachable("Unhandled NodeType in switch.");
}

void EscapeAnalysis::ConnectionGraph::dump() const {
Expand Down
8 changes: 6 additions & 2 deletions lib/SILOptimizer/IPO/CapturePromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,16 @@ class ReachingBlockSet {

bool test(unsigned ID) const {
assert(ID / BITWORD_SIZE < NumBitWords && "block ID out-of-bounds");
return Bits[ID / BITWORD_SIZE] & (1L << (ID % BITWORD_SIZE));
unsigned int modulus = ID % BITWORD_SIZE;
long shifted = 1L << modulus;
return Bits[ID / BITWORD_SIZE] & shifted;
}

void set(unsigned ID) {
unsigned int modulus = ID % BITWORD_SIZE;
long shifted = 1L << modulus;
assert(ID / BITWORD_SIZE < NumBitWords && "block ID out-of-bounds");
Bits[ID / BITWORD_SIZE] |= 1L << (ID % BITWORD_SIZE);
Bits[ID / BITWORD_SIZE] |= shifted;
}

ReachingBlockSet &operator|=(const ReachingBlockSet &RHS) {
Expand Down
4 changes: 4 additions & 0 deletions lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ static bool isNonMutatingArraySemanticCall(SILInstruction *Inst) {
case ArrayCallKind::kArrayUninitialized:
return false;
}

llvm_unreachable("Unhandled ArrayCallKind in switch.");
}

/// \return true if the given retain instruction is followed by a release on the
Expand Down Expand Up @@ -825,6 +827,8 @@ static bool mayChangeArrayValueToNonUniqueState(ArraySemanticsCall &Call) {
case ArrayCallKind::kArrayUninitialized:
return true;
}

llvm_unreachable("Unhandled ArrayCallKind in switch.");
}

/// Check that the array value stored in \p ArrayStruct is released by \Inst.
Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/Mandatory/ConstantPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,7 @@ processFunction(SILFunction &F, bool EnableDiagnostics,

// Eagerly DCE. We do this after visiting all users to ensure we don't
// invalidate the uses iterator.
auto UserArray = ArrayRef<SILInstruction *>(&*FoldedUsers.begin(),
FoldedUsers.size());
ArrayRef<SILInstruction *> UserArray = FoldedUsers.getArrayRef();
if (!UserArray.empty()) {
InvalidateInstructions = true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct DIMemoryUse {
bool isValid() const { return Inst != nullptr; }

bool usesElement(unsigned i) const {
return i >= FirstElement && i < FirstElement+NumElements;
return i >= FirstElement && i < static_cast<unsigned>(FirstElement+NumElements);
}

/// onlyTouchesTrivialElements - Return true if all of the accessed elements
Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ SILInstruction *SILCombiner::optimizeBuiltinCanBeObjCClass(BuiltinInst *BI) {
case TypeTraitResult::CanBe:
return nullptr;
}

llvm_unreachable("Unhandled TypeTraitResult in switch.");
}

static unsigned getTypeWidth(SILType Ty) {
Expand Down
4 changes: 3 additions & 1 deletion lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,9 @@ SILCombiner::visitInjectEnumAddrInst(InjectEnumAddrInst *IEAI) {
SILBasicBlock *DefaultBB = nullptr;

if (SEI->hasDefault()) {
auto *IL = B.createIntegerLiteral(SEI->getLoc(), IntTy, APInt(32, SEI->getNumCases(), false));
auto *IL = B.createIntegerLiteral(
SEI->getLoc(), IntTy,
APInt(32, static_cast<uint64_t>(SEI->getNumCases()), false));
DefaultValue = SILValue(IL);
DefaultBB = SEI->getDefaultBB();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/Utils/FunctionSignatureOptUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static bool isSpecializableRepresentation(SILFunctionTypeRepresentation Rep) {
case SILFunctionTypeRepresentation::Block:
return false;
}

llvm_unreachable("Unhandled SILFunctionTypeRepresentation in switch.");
}

/// Returns true if F is a function which the pass know show to specialize
Expand Down
4 changes: 4 additions & 0 deletions lib/SILOptimizer/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ SILLinkage swift::getSpecializedLinkage(SILFunction *F, SILLinkage L) {
// functions from the stdlib which are specialized in another module).
return SILLinkage::Private;
}

llvm_unreachable("Unhandled SILLinkage in switch.");
}

/// Remove all instructions in the body of \p BB in safe manner by using
Expand Down Expand Up @@ -2714,6 +2716,8 @@ bool swift::calleesAreStaticallyKnowable(SILModule &M, SILDeclRef Decl) {
case Accessibility::Private:
return true;
}

llvm_unreachable("Unhandled Accessibility in switch.");
}

void swift::hoistAddressProjections(Operand &Op, SILInstruction *InsertBefore,
Expand Down
2 changes: 2 additions & 0 deletions lib/SILOptimizer/Utils/SILInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,6 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) {
case ValueKind::MarkUninitializedBehaviorInst:
llvm_unreachable("not valid in canonical sil");
}

llvm_unreachable("Unhandled ValueKind in switch.");
}