Skip to content

Commit 79f29e1

Browse files
committed
add some comments in AliasAnalysis and EscapeAnalysis
1 parent f0645d1 commit 79f29e1

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

include/swift/SILOptimizer/Analysis/EscapeAnalysis.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ class EscapeAnalysis : public BottomUpIPAnalysis {
742742

743743
/// Returns true if the pointers \p V1 and \p V2 can possibly point to the
744744
/// same memory.
745+
/// If at aleast one of the pointers refers to a local object and and the
746+
/// connection-graph-nodes of both pointers do not point to the same content
747+
/// node, the pointers do not alias.
745748
bool canPointToSameMemory(SILValue V1, SILValue V2);
746749

747750
virtual void invalidate(InvalidationKind K) override;

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,21 @@ AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
594594
if (O1 != O2 && aliasUnequalObjects(O1, O2))
595595
return AliasResult::NoAlias;
596596

597-
// Ask escape analysis. This catches cases where we compare e.g. a
598-
// non-escaping pointer with another pointer.
597+
// Ok, either O1, O2 are the same or we could not prove anything based off of
598+
// their inequality.
599+
// Next: ask escape analysis. This catches cases where we compare e.g. a
600+
// non-escaping pointer with another (maybe escaping) pointer. Escape analysis
601+
// uses the connection graph to check if the pointers may point to the same
602+
// content.
603+
// Note that escape analysis must work with the original pointers and not the
604+
// underlying objects because it treats projecetions differently.
599605
if (!EA->canPointToSameMemory(V1, V2)) {
600606
DEBUG(llvm::dbgs() << " Found not-aliased objects based on"
601607
"escape analysis\n");
602608
return AliasResult::NoAlias;
603609
}
604610

605-
// Ok, either O1, O2 are the same or we could not prove anything based off of
606-
// their inequality. Now we climb up use-def chains and attempt to do tricks
607-
// based off of GEPs.
611+
// Now we climb up use-def chains and attempt to do tricks based off of GEPs.
608612

609613
// First if one instruction is a gep and the other is not, canonicalize our
610614
// inputs so that V1 always is the instruction containing the GEP.

0 commit comments

Comments
 (0)