Skip to content

Commit ddd9ec6

Browse files
committed
[LICM] Update comments related to escape check (NFC)
The comments here were outdated and a bit confusing without the knowledge that we're only guarding against reads on unwind.
1 parent 0f92533 commit ddd9ec6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,22 +1923,22 @@ bool isNotCapturedBeforeOrInLoop(const Value *V, const Loop *L,
19231923
L->getHeader()->getTerminator(), DT);
19241924
}
19251925

1926-
/// Return true iff we can prove that a caller of this function can not inspect
1927-
/// the contents of the provided object in a well defined program.
1928-
bool isKnownNonEscaping(Value *Object, const Loop *L, DominatorTree *DT) {
1926+
/// Return true if we can prove that a caller cannot inspect the object if an
1927+
/// unwind occurs inside the loop.
1928+
bool isNotVisibleOnUnwind(Value *Object, const Loop *L, DominatorTree *DT) {
19291929
if (isa<AllocaInst>(Object))
19301930
// Since the alloca goes out of scope, we know the caller can't retain a
19311931
// reference to it and be well defined. Thus, we don't need to check for
19321932
// capture.
19331933
return true;
19341934

19351935
// For all other objects we need to know that the caller can't possibly
1936-
// have gotten a reference to the object. There are two components of
1937-
// that:
1938-
// 1) Object can't be escaped by this function. This is what
1939-
// PointerMayBeCaptured checks.
1940-
// 2) Object can't have been captured at definition site. For this, we
1941-
// need to know the return value is noalias.
1936+
// have gotten a reference to the object prior to an unwind in the loop.
1937+
// There are two components of that:
1938+
// 1) Object can't have been captured prior to the definition site.
1939+
// For this, we need to know the return value is noalias.
1940+
// 1) Object can't be captured before or inside the loop. This is what
1941+
// isNotCapturedBeforeOrInLoop() checks.
19421942
return isNoAliasCall(Object) && isNotCapturedBeforeOrInLoop(Object, L, DT);
19431943
}
19441944

@@ -2026,7 +2026,7 @@ bool llvm::promoteLoopAccessesToScalars(
20262026
// this by proving that the caller can't have a reference to the object
20272027
// after return and thus can't possibly load from the object.
20282028
Value *Object = getUnderlyingObject(SomePtr);
2029-
if (!isKnownNonEscaping(Object, CurLoop, DT))
2029+
if (!isNotVisibleOnUnwind(Object, CurLoop, DT))
20302030
return false;
20312031
// Subtlety: Alloca's aren't visible to callers, but *are* potentially
20322032
// visible to other threads if captured and used during their lifetimes.

0 commit comments

Comments
 (0)