Skip to content

Commit 63db004

Browse files
hughbejrose-apple
authored andcommitted
Fix warnings and error building swift/SILOptimizer on Windows with MSVC (#5956)
1 parent dfa9536 commit 63db004

File tree

17 files changed

+76
-7
lines changed

17 files changed

+76
-7
lines changed

include/swift/SILOptimizer/Analysis/EscapeAnalysis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
299299
case EscapeState::Global:
300300
return true;
301301
}
302+
303+
llvm_unreachable("Unhandled EscapeState in switch.");
302304
}
303305

304306
/// Returns the content node if of this node if it exists in the graph.

include/swift/SILOptimizer/Analysis/IVAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace swift {
2626
class IVInfo : public SCCVisitor<IVInfo> {
2727
public:
2828
typedef llvm::SmallVectorImpl<ValueBase *> SCCType;
29-
friend class SCCVisitor;
29+
friend SCCVisitor;
3030

3131
public:
3232

lib/SILOptimizer/ARC/ARCRegionState.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static bool isARCSignificantTerminator(TermInst *TI) {
179179
case TermKind::CheckedCastAddrBranchInst:
180180
return true;
181181
}
182+
183+
llvm_unreachable("Unhandled TermKind in switch.");
182184
}
183185

184186
// Visit each one of our predecessor regions and see if any are blocks that can

lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ static bool isARCSignificantTerminator(TermInst *TI) {
220220
case TermKind::CheckedCastAddrBranchInst:
221221
return true;
222222
}
223+
224+
llvm_unreachable("Unhandled TermKind in switch.");
223225
}
224226

225227
/// Analyze a single BB for refcount inc/dec instructions.

lib/SILOptimizer/ARC/RefCountState.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ bool BottomUpRefCountState::isRefCountStateModified() const {
142142
case LatticeState::MightBeUsed:
143143
return false;
144144
}
145+
146+
llvm_unreachable("Unhandled TermKind in switch.");
145147
}
146148

147149
/// Returns true if given the current lattice state, do we care if the value
@@ -155,6 +157,8 @@ bool BottomUpRefCountState::valueCanBeDecrementedGivenLatticeState() const {
155157
case LatticeState::Decremented:
156158
return false;
157159
}
160+
161+
llvm_unreachable("Unhandled LatticeState in switch.");
158162
}
159163

160164
/// If advance the state's sequence appropriately for a decrement. If we do
@@ -169,6 +173,8 @@ bool BottomUpRefCountState::handleDecrement() {
169173
case LatticeState::Decremented:
170174
return false;
171175
}
176+
177+
llvm_unreachable("Unhandled LatticeState in switch.");
172178
}
173179

174180
/// Returns true if given the current lattice state, do we care if the value we
@@ -182,6 +188,8 @@ bool BottomUpRefCountState::valueCanBeUsedGivenLatticeState() const {
182188
case LatticeState::MightBeUsed:
183189
return false;
184190
}
191+
192+
llvm_unreachable("Unhandled LatticeState in switch.");
185193
}
186194

187195
/// Given the current lattice state, if we have seen a use, advance the
@@ -202,6 +210,8 @@ bool BottomUpRefCountState::handleUser(
202210
case LatticeState::None:
203211
return false;
204212
}
213+
214+
llvm_unreachable("Unhandled LatticeState in switch.");
205215
}
206216

207217
/// Returns true if given the current lattice state, do we care if the value
@@ -216,6 +226,8 @@ valueCanBeGuaranteedUsedGivenLatticeState() const {
216226
case LatticeState::MightBeUsed:
217227
return true;
218228
}
229+
230+
llvm_unreachable("Unhandled LatticeState in switch.");
219231
}
220232

221233
/// Given the current lattice state, if we have seen a use, advance the
@@ -242,6 +254,8 @@ bool BottomUpRefCountState::handleGuaranteedUser(
242254
case LatticeState::None:
243255
return false;
244256
}
257+
258+
llvm_unreachable("Unhandled LatticeState in switch.");
245259
}
246260

247261
// Returns true if the passed in ref count inst matches the ref count inst
@@ -279,6 +293,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) {
279293
case LatticeState::MightBeDecremented:
280294
return true;
281295
}
296+
297+
llvm_unreachable("Unhandled LatticeState in switch.");
282298
}
283299

284300
bool BottomUpRefCountState::merge(const BottomUpRefCountState &Other) {
@@ -577,6 +593,8 @@ bool TopDownRefCountState::isRefCountStateModified() const {
577593
case LatticeState::MightBeUsed:
578594
return false;
579595
}
596+
597+
llvm_unreachable("Unhandled LatticeState in switch.");
580598
}
581599

582600
/// Returns true if given the current lattice state, do we care if the value
@@ -590,6 +608,8 @@ bool TopDownRefCountState::valueCanBeDecrementedGivenLatticeState() const {
590608
case LatticeState::MightBeUsed:
591609
return false;
592610
}
611+
612+
llvm_unreachable("Unhandled LatticeState in switch.");
593613
}
594614

595615
/// If advance the state's sequence appropriately for a decrement. If we do
@@ -606,6 +626,8 @@ bool TopDownRefCountState::handleDecrement(
606626
case LatticeState::MightBeUsed:
607627
return false;
608628
}
629+
630+
llvm_unreachable("Unhandled LatticeState in switch.");
609631
}
610632

611633
/// Returns true if given the current lattice state, do we care if the value
@@ -619,6 +641,8 @@ bool TopDownRefCountState::valueCanBeUsedGivenLatticeState() const {
619641
case LatticeState::MightBeUsed:
620642
return false;
621643
}
644+
645+
llvm_unreachable("Unhandled LatticeState in switch.");
622646
}
623647

624648
/// Given the current lattice state, if we have seen a use, advance the
@@ -639,6 +663,8 @@ bool TopDownRefCountState::handleUser(SILInstruction *PotentialUser,
639663
case LatticeState::MightBeUsed:
640664
return false;
641665
}
666+
667+
llvm_unreachable("Unhandled LatticeState in switch.");
642668
}
643669

644670
/// Returns true if given the current lattice state, do we care if the value
@@ -654,6 +680,8 @@ valueCanBeGuaranteedUsedGivenLatticeState() const {
654680
case LatticeState::MightBeDecremented:
655681
return true;
656682
}
683+
684+
llvm_unreachable("Unhandled LatticeState in switch.");
657685
}
658686

659687
/// Given the current lattice state, if we have seen a use, advance the
@@ -680,6 +708,8 @@ bool TopDownRefCountState::handleGuaranteedUser(
680708
case LatticeState::None:
681709
return false;
682710
}
711+
712+
llvm_unreachable("Unhandled LatticeState in switch.");
683713
}
684714

685715
// Returns true if the passed in ref count inst matches the ref count inst
@@ -713,6 +743,8 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) {
713743
case LatticeState::MightBeUsed:
714744
return true;
715745
}
746+
747+
llvm_unreachable("Unhandled LatticeState in switch.");
716748
}
717749

718750
bool TopDownRefCountState::merge(const TopDownRefCountState &Other) {
@@ -908,6 +940,8 @@ raw_ostream &operator<<(raw_ostream &OS,
908940
case LatticeState::MightBeDecremented:
909941
return OS << "MightBeDecremented";
910942
}
943+
944+
llvm_unreachable("Unhandled LatticeState in switch.");
911945
}
912946

913947
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
@@ -923,6 +957,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
923957
case LatticeState::MightBeDecremented:
924958
return OS << "MightBeDecremented";
925959
}
960+
961+
llvm_unreachable("Unhandled LatticeState in switch.");
926962
}
927963

928964
} // end namespace llvm

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &OS, AliasResult R) {
9898
case AliasResult::PartialAlias: return OS << "PartialAlias";
9999
case AliasResult::MustAlias: return OS << "MustAlias";
100100
}
101+
102+
llvm_unreachable("Unhandled AliasResult in switch.");
101103
}
102104

103105
SILValue getAccessedMemory(SILInstruction *User) {

lib/SILOptimizer/Analysis/CFG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static bool isSafeNonExitTerminator(TermInst *TI) {
3535
case TermKind::TryApplyInst:
3636
return false;
3737
}
38+
39+
llvm_unreachable("Unhandled TermKind in switch.");
3840
}
3941

4042
static bool isTrapNoReturnFunction(ApplyInst *AI) {

lib/SILOptimizer/Analysis/EscapeAnalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ namespace llvm {
789789
case CGForDotView::PointsTo: return "";
790790
case CGForDotView::Deferred: return "color=\"gray\"";
791791
}
792+
793+
llvm_unreachable("Unhandled CGForDotView in switch.");
792794
}
793795
};
794796
} // end llvm namespace
@@ -823,6 +825,8 @@ const char *EscapeAnalysis::CGNode::getTypeStr() const {
823825
case NodeType::Argument: return "Arg";
824826
case NodeType::Return: return "Ret";
825827
}
828+
829+
llvm_unreachable("Unhandled NodeType in switch.");
826830
}
827831

828832
void EscapeAnalysis::ConnectionGraph::dump() const {

lib/SILOptimizer/IPO/CapturePromotion.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,16 @@ class ReachingBlockSet {
124124

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

130132
void set(unsigned ID) {
133+
unsigned int modulus = ID % BITWORD_SIZE;
134+
long shifted = 1L << modulus;
131135
assert(ID / BITWORD_SIZE < NumBitWords && "block ID out-of-bounds");
132-
Bits[ID / BITWORD_SIZE] |= 1L << (ID % BITWORD_SIZE);
136+
Bits[ID / BITWORD_SIZE] |= shifted;
133137
}
134138

135139
ReachingBlockSet &operator|=(const ReachingBlockSet &RHS) {

lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ static bool isNonMutatingArraySemanticCall(SILInstruction *Inst) {
491491
case ArrayCallKind::kArrayUninitialized:
492492
return false;
493493
}
494+
495+
llvm_unreachable("Unhandled ArrayCallKind in switch.");
494496
}
495497

496498
/// \return true if the given retain instruction is followed by a release on the
@@ -825,6 +827,8 @@ static bool mayChangeArrayValueToNonUniqueState(ArraySemanticsCall &Call) {
825827
case ArrayCallKind::kArrayUninitialized:
826828
return true;
827829
}
830+
831+
llvm_unreachable("Unhandled ArrayCallKind in switch.");
828832
}
829833

830834
/// Check that the array value stored in \p ArrayStruct is released by \Inst.

0 commit comments

Comments
 (0)