diff --git a/include/swift/SILOptimizer/Analysis/EscapeAnalysis.h b/include/swift/SILOptimizer/Analysis/EscapeAnalysis.h index b9251c382e21..c980edb3a06a 100644 --- a/include/swift/SILOptimizer/Analysis/EscapeAnalysis.h +++ b/include/swift/SILOptimizer/Analysis/EscapeAnalysis.h @@ -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. diff --git a/include/swift/SILOptimizer/Analysis/IVAnalysis.h b/include/swift/SILOptimizer/Analysis/IVAnalysis.h index e338bf59a364..07e916af9a7d 100644 --- a/include/swift/SILOptimizer/Analysis/IVAnalysis.h +++ b/include/swift/SILOptimizer/Analysis/IVAnalysis.h @@ -26,7 +26,7 @@ namespace swift { class IVInfo : public SCCVisitor { public: typedef llvm::SmallVectorImpl SCCType; - friend class SCCVisitor; + friend SCCVisitor; public: diff --git a/lib/SILOptimizer/ARC/ARCRegionState.cpp b/lib/SILOptimizer/ARC/ARCRegionState.cpp index 1d90bf0c31d8..017cf6128912 100644 --- a/lib/SILOptimizer/ARC/ARCRegionState.cpp +++ b/lib/SILOptimizer/ARC/ARCRegionState.cpp @@ -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 diff --git a/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp b/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp index 53e4a829b8a1..887e01583c41 100644 --- a/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp +++ b/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp @@ -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. diff --git a/lib/SILOptimizer/ARC/RefCountState.cpp b/lib/SILOptimizer/ARC/RefCountState.cpp index 3a690889b9c7..f90bfc291fed 100644 --- a/lib/SILOptimizer/ARC/RefCountState.cpp +++ b/lib/SILOptimizer/ARC/RefCountState.cpp @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -279,6 +293,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) { case LatticeState::MightBeDecremented: return true; } + + llvm_unreachable("Unhandled LatticeState in switch."); } bool BottomUpRefCountState::merge(const BottomUpRefCountState &Other) { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -713,6 +743,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) { case LatticeState::MightBeUsed: return true; } + + llvm_unreachable("Unhandled LatticeState in switch."); } bool TopDownRefCountState::merge(const TopDownRefCountState &Other) { @@ -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, @@ -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 diff --git a/lib/SILOptimizer/Analysis/AliasAnalysis.cpp b/lib/SILOptimizer/Analysis/AliasAnalysis.cpp index 2598ccac3e2f..dd24197a032d 100644 --- a/lib/SILOptimizer/Analysis/AliasAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/AliasAnalysis.cpp @@ -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) { diff --git a/lib/SILOptimizer/Analysis/CFG.cpp b/lib/SILOptimizer/Analysis/CFG.cpp index 7fcf1bc7bd2a..fee3103e0475 100644 --- a/lib/SILOptimizer/Analysis/CFG.cpp +++ b/lib/SILOptimizer/Analysis/CFG.cpp @@ -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) { diff --git a/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp b/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp index 8a7b77af588f..2deeac85f59a 100644 --- a/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp @@ -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 @@ -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 { diff --git a/lib/SILOptimizer/IPO/CapturePromotion.cpp b/lib/SILOptimizer/IPO/CapturePromotion.cpp index c6f7327a1822..1c0aec72aecf 100644 --- a/lib/SILOptimizer/IPO/CapturePromotion.cpp +++ b/lib/SILOptimizer/IPO/CapturePromotion.cpp @@ -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) { diff --git a/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp b/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp index 461de39048f6..fcea68dd25fc 100644 --- a/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp +++ b/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp @@ -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 @@ -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. diff --git a/lib/SILOptimizer/Mandatory/ConstantPropagation.cpp b/lib/SILOptimizer/Mandatory/ConstantPropagation.cpp index 62ddf0842350..e779e37f5985 100644 --- a/lib/SILOptimizer/Mandatory/ConstantPropagation.cpp +++ b/lib/SILOptimizer/Mandatory/ConstantPropagation.cpp @@ -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(&*FoldedUsers.begin(), - FoldedUsers.size()); + ArrayRef UserArray = FoldedUsers.getArrayRef(); if (!UserArray.empty()) { InvalidateInstructions = true; } diff --git a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h index f26218f869e4..f62927b73541 100644 --- a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h +++ b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h @@ -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(FirstElement+NumElements); } /// onlyTouchesTrivialElements - Return true if all of the accessed elements diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp index 82038d0cabf8..ca8dd3006cc3 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp @@ -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) { diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp index 43054771e64a..6b34a1aff591 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp @@ -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(SEI->getNumCases()), false)); DefaultValue = SILValue(IL); DefaultBB = SEI->getDefaultBB(); } diff --git a/lib/SILOptimizer/Utils/FunctionSignatureOptUtils.cpp b/lib/SILOptimizer/Utils/FunctionSignatureOptUtils.cpp index e16543fcc1f5..ae2fc37547ec 100644 --- a/lib/SILOptimizer/Utils/FunctionSignatureOptUtils.cpp +++ b/lib/SILOptimizer/Utils/FunctionSignatureOptUtils.cpp @@ -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 diff --git a/lib/SILOptimizer/Utils/Local.cpp b/lib/SILOptimizer/Utils/Local.cpp index cf650760dfcc..87ad69136471 100644 --- a/lib/SILOptimizer/Utils/Local.cpp +++ b/lib/SILOptimizer/Utils/Local.cpp @@ -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 @@ -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, diff --git a/lib/SILOptimizer/Utils/SILInliner.cpp b/lib/SILOptimizer/Utils/SILInliner.cpp index ed8ecd71efbd..50589b3d2264 100644 --- a/lib/SILOptimizer/Utils/SILInliner.cpp +++ b/lib/SILOptimizer/Utils/SILInliner.cpp @@ -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."); }