Skip to content

Commit 34238e5

Browse files
committed
[AliasAnalysis] Remove duplicate code in TBAA.
We have two places in TBAA that uses the class hierarchy to disambiguate types. This commit removes one of the checks (the one that looked more ad-hock) and keeps the check in line 540 that uses Type.isSuperclassOf.
1 parent a07da67 commit 34238e5

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

lib/SILAnalysis/AliasAnalysis.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -442,38 +442,6 @@ static bool typedAccessTBAABuiltinTypesMayAlias(SILType LTy, SILType RTy,
442442
return false;
443443
}
444444

445-
/// Return true if the type \p Parent is a parent of \p Child in the
446-
/// class hierarchy.
447-
static bool isParentClass(SILType Parent, SILType Child) {
448-
SILType T = SILType();
449-
450-
// Walk the class hiearchy to see whether Parent and Child have a
451-
// parent-child relationship.
452-
T = Child;
453-
do {
454-
// There is a parent-child relationship.
455-
if (T == Parent)
456-
return true;
457-
458-
T = T.getSuperclass(nullptr);
459-
} while(T);
460-
461-
return false;
462-
}
463-
464-
/// Returns true if the reference types \p LTy and \pRTy may alias.
465-
static bool referenceTypeTBAAMayAlias(SILType LTy, SILType RTy) {
466-
467-
// Walk the type hiearchy to see whether LTy and RTy have a parent-child
468-
// relationship.
469-
if (isParentClass(LTy, RTy) ||
470-
isParentClass(RTy, LTy)) {
471-
return true;
472-
}
473-
474-
return false;
475-
}
476-
477445
/// \brief return True if the types \p LTy and \p RTy may alias.
478446
///
479447
/// Currently this only implements typed access based TBAA. See the TBAA section
@@ -488,13 +456,6 @@ static bool typedAccessTBAAMayAlias(SILType LTy, SILType RTy, SILModule &Mod) {
488456
if (LTy == RTy)
489457
return true;
490458

491-
// If 2 reference types have no parent-child relationship, then they can
492-
// not alias.
493-
if (!LTy.isAddress() && !RTy.isAddress()) {
494-
if (LTy.isHeapObjectReferenceType() && RTy.isHeapObjectReferenceType())
495-
return referenceTypeTBAAMayAlias(LTy, RTy);
496-
}
497-
498459
// Typed access based TBAA only occurs on pointers. If we reach this point and
499460
// do not have a pointer, be conservative and return that the two types may
500461
// alias. *NOTE* This ensures we return may alias for local_storage.

0 commit comments

Comments
 (0)