Refactor some ArraySemanticsCall code. NFC.

This commit is contained in:
Erik Eckstein
2016-02-16 16:57:56 -08:00
parent 565fb1d78b
commit 666e20381f
4 changed files with 25 additions and 47 deletions

View File

@@ -188,19 +188,6 @@ bool ArrayAllocation::analyseArrayValueUses() {
return recursivelyCollectUses(ArrayValue);
}
static bool doesNotChangeArray(ArraySemanticsCall &C) {
switch (C.getKind()) {
default: return false;
case ArrayCallKind::kArrayPropsIsNativeTypeChecked:
case ArrayCallKind::kCheckSubscript:
case ArrayCallKind::kCheckIndex:
case ArrayCallKind::kGetCount:
case ArrayCallKind::kGetCapacity:
case ArrayCallKind::kGetElement:
return true;
}
}
/// Recursively look at all uses of this definition. Abort if the array value
/// could escape or be changed. Collect all uses that are calls to array.count.
bool ArrayAllocation::recursivelyCollectUses(ValueBase *Def) {
@@ -219,7 +206,7 @@ bool ArrayAllocation::recursivelyCollectUses(ValueBase *Def) {
// Check array semantic calls.
ArraySemanticsCall ArrayOp(User);
if (ArrayOp && doesNotChangeArray(ArrayOp)) {
if (ArrayOp && ArrayOp.doesNotChangeArray()) {
if (ArrayOp.getKind() == ArrayCallKind::kGetElement)
GetElementCalls.insert(ArrayOp);
continue;