Skip to content

Commit 45df041

Browse files
authored
Merge pull request #28526 from gottesmm/pr-adc7dd569017e879cf605515924e93300c72e6d6
2 parents b544355 + 4c6d2f0 commit 45df041

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -334,50 +334,73 @@ class SILFunctionArgument : public SILArgument {
334334
//===----------------------------------------------------------------------===//
335335

336336
inline bool SILArgument::isPhiArgument() const {
337-
if (auto *phiArg = dyn_cast<SILPhiArgument>(this))
338-
return phiArg->isPhiArgument();
339-
340-
return false;
337+
switch (getKind()) {
338+
case SILArgumentKind::SILPhiArgument:
339+
return cast<SILPhiArgument>(this)->isPhiArgument();
340+
case SILArgumentKind::SILFunctionArgument:
341+
return false;
342+
}
343+
llvm_unreachable("Covered switch is not covered?!");
341344
}
342345

343346
inline SILValue
344347
SILArgument::getIncomingPhiValue(SILBasicBlock *predBlock) const {
345-
if (isa<SILFunctionArgument>(this))
348+
switch (getKind()) {
349+
case SILArgumentKind::SILPhiArgument:
350+
return cast<SILPhiArgument>(this)->getIncomingPhiValue(predBlock);
351+
case SILArgumentKind::SILFunctionArgument:
346352
return SILValue();
347-
return cast<SILPhiArgument>(this)->getIncomingPhiValue(predBlock);
353+
}
354+
llvm_unreachable("Covered switch is not covered?!");
348355
}
349356

350357
inline bool SILArgument::getIncomingPhiValues(
351358
SmallVectorImpl<SILValue> &returnedPhiValues) const {
352-
if (isa<SILFunctionArgument>(this))
359+
switch (getKind()) {
360+
case SILArgumentKind::SILPhiArgument:
361+
return cast<SILPhiArgument>(this)->getIncomingPhiValues(returnedPhiValues);
362+
case SILArgumentKind::SILFunctionArgument:
353363
return false;
354-
return cast<SILPhiArgument>(this)->getIncomingPhiValues(returnedPhiValues);
364+
}
365+
llvm_unreachable("Covered switch is not covered?!");
355366
}
356367

357368
inline bool SILArgument::getIncomingPhiValues(
358369
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
359370
&returnedPredAndPhiValuePairs) const {
360-
if (isa<SILFunctionArgument>(this))
371+
switch (getKind()) {
372+
case SILArgumentKind::SILPhiArgument:
373+
return cast<SILPhiArgument>(this)->getIncomingPhiValues(
374+
returnedPredAndPhiValuePairs);
375+
case SILArgumentKind::SILFunctionArgument:
361376
return false;
362-
return cast<SILPhiArgument>(this)->getIncomingPhiValues(
363-
returnedPredAndPhiValuePairs);
377+
}
378+
llvm_unreachable("Covered switch is not covered?!");
364379
}
365380

366381
inline bool SILArgument::getSingleTerminatorOperands(
367382
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const {
368-
if (isa<SILFunctionArgument>(this))
383+
switch (getKind()) {
384+
case SILArgumentKind::SILPhiArgument:
385+
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
386+
returnedSingleTermOperands);
387+
case SILArgumentKind::SILFunctionArgument:
369388
return false;
370-
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
371-
returnedSingleTermOperands);
389+
}
390+
llvm_unreachable("Covered switch is not covered?!");
372391
}
373392

374393
inline bool SILArgument::getSingleTerminatorOperands(
375394
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
376395
&returnedSingleTermOperands) const {
377-
if (isa<SILFunctionArgument>(this))
396+
switch (getKind()) {
397+
case SILArgumentKind::SILPhiArgument:
398+
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
399+
returnedSingleTermOperands);
400+
case SILArgumentKind::SILFunctionArgument:
378401
return false;
379-
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
380-
returnedSingleTermOperands);
402+
}
403+
llvm_unreachable("Covered switch is not covered?!");
381404
}
382405

383406
} // end swift namespace

0 commit comments

Comments
 (0)