Introduce isDecl and getDeclType

fix enum logic issue

fix tests

guard against null types
This commit is contained in:
Azoy
2021-04-18 01:27:46 -04:00
parent f75f5fe78d
commit 9ed732f0ab
62 changed files with 391 additions and 569 deletions

View File

@@ -783,12 +783,6 @@ public:
}
};
static bool hasArrayType(SILValue Value, SILModule &M) {
return Value->getType().getNominalOrBoundGenericNominal() ==
M.getASTContext().getArrayDecl();
}
/// A dominating cond_fail on the same value ensures that this value is false.
static bool isValueKnownFalseAt(SILValue Val, SILInstruction *At,
DominanceInfo *DT) {
@@ -1339,7 +1333,7 @@ bool ABCOpt::hoistChecksInLoop(DominanceInfoNode *DTNode, ABCAnalysis &ABC,
// Check if the loop iterates from 0 to the count of this array.
if (F.isZeroToCount(ArrayVal) &&
// This works only for Arrays but not e.g. for ArraySlice.
hasArrayType(ArrayVal, Header->getModule())) {
ArrayVal->getType().getASTType()->isArray()) {
// We can remove the check. This is even possible if the block does not
// dominate the loop exit block.
Changed = true;