[llvm] ddd9ec6 - [LICM] Update comments related to escape check (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 05:45:55 PST 2022
Author: Nikita Popov
Date: 2022-01-06T14:45:48+01:00
New Revision: ddd9ec667a2e3ec241f11dbb8368600dcf432eb4
URL: https://github.com/llvm/llvm-project/commit/ddd9ec667a2e3ec241f11dbb8368600dcf432eb4
DIFF: https://github.com/llvm/llvm-project/commit/ddd9ec667a2e3ec241f11dbb8368600dcf432eb4.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Scalar/LICM.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 80ed671b0a52..ebb2520a0516 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1923,9 +1923,9 @@ bool isNotCapturedBeforeOrInLoop(const Value *V, const Loop *L,
L->getHeader()->getTerminator(), DT);
}
-/// Return true iff we can prove that a caller of this function can not inspect
-/// the contents of the provided object in a well defined program.
-bool isKnownNonEscaping(Value *Object, const Loop *L, DominatorTree *DT) {
+/// Return true if we can prove that a caller cannot inspect the object if an
+/// unwind occurs inside the loop.
+bool isNotVisibleOnUnwind(Value *Object, const Loop *L, DominatorTree *DT) {
if (isa<AllocaInst>(Object))
// Since the alloca goes out of scope, we know the caller can't retain a
// reference to it and be well defined. Thus, we don't need to check for
@@ -1933,12 +1933,12 @@ bool isKnownNonEscaping(Value *Object, const Loop *L, DominatorTree *DT) {
return true;
// For all other objects we need to know that the caller can't possibly
- // have gotten a reference to the object. There are two components of
- // that:
- // 1) Object can't be escaped by this function. This is what
- // PointerMayBeCaptured checks.
- // 2) Object can't have been captured at definition site. For this, we
- // need to know the return value is noalias.
+ // have gotten a reference to the object prior to an unwind in the loop.
+ // There are two components of that:
+ // 1) Object can't have been captured prior to the definition site.
+ // For this, we need to know the return value is noalias.
+ // 1) Object can't be captured before or inside the loop. This is what
+ // isNotCapturedBeforeOrInLoop() checks.
return isNoAliasCall(Object) && isNotCapturedBeforeOrInLoop(Object, L, DT);
}
@@ -2026,7 +2026,7 @@ bool llvm::promoteLoopAccessesToScalars(
// this by proving that the caller can't have a reference to the object
// after return and thus can't possibly load from the object.
Value *Object = getUnderlyingObject(SomePtr);
- if (!isKnownNonEscaping(Object, CurLoop, DT))
+ if (!isNotVisibleOnUnwind(Object, CurLoop, DT))
return false;
// Subtlety: Alloca's aren't visible to callers, but *are* potentially
// visible to other threads if captured and used during their lifetimes.
More information about the llvm-commits
mailing list