Skip to content

Commit b3bcece

Browse files
authored
Merge pull request #13661 from davezarzycki/nfc_avoid_getCanonicalType_reg_spills
2 parents b11d544 + 47328a5 commit b3bcece

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

include/swift/AST/Types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,17 @@ class alignas(1 << TypeAlignInBits) TypeBase {
400400
bool hasCanonicalTypeComputed() const { return !CanonicalType.isNull(); }
401401

402402
private:
403-
void computeCanonicalType();
403+
CanType computeCanonicalType();
404404

405405
public:
406406
/// getCanonicalType - Return the canonical version of this type, which has
407407
/// sugar from all levels stripped off.
408408
CanType getCanonicalType() {
409409
if (isCanonical())
410410
return CanType(this);
411-
if (!hasCanonicalTypeComputed())
412-
computeCanonicalType();
413-
return CanType(CanonicalType.get<TypeBase*>());
411+
if (hasCanonicalTypeComputed())
412+
return CanType(CanonicalType.get<TypeBase*>());
413+
return computeCanonicalType();
414414
}
415415

416416
/// getCanonicalType - Stronger canonicalization which folds away equivalent

lib/AST/Type.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ getCanonicalInputType(AnyFunctionType *funcType,
10451045
return inputType;
10461046
}
10471047

1048-
void TypeBase::computeCanonicalType() {
1048+
CanType TypeBase::computeCanonicalType() {
10491049
assert(!hasCanonicalTypeComputed() && "called unnecessarily");
10501050

10511051
TypeBase *Result = nullptr;
@@ -1223,6 +1223,7 @@ void TypeBase::computeCanonicalType() {
12231223
// Cache the canonical type for future queries.
12241224
assert(Result && "Case not implemented!");
12251225
CanonicalType = Result;
1226+
return CanType(Result);
12261227
}
12271228

12281229
CanType TypeBase::getCanonicalType(GenericSignature *sig) {

0 commit comments

Comments
 (0)