mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ARCSequenceOpts: Add LoopSummary verifier (#33810)
ARCSequenceOpts with loop support works on regions inside out. While processing an outer region, it uses summary from the inner loop region to compute RefCountState transitions used for CodeMotionSafe optimization. We do not compute the loop summary by iterating over it twice or iterating until a fixed point is reached. Instead loop summary is just a list of refcount effecting instructions. And BottomUpRefCountState::updateForDifferentLoopInst and TopDownRefCountState::updateForDifferentLoopInst are used to compute the RefCountState transition when processing the inner loop region. These functions are very conservative and the flow sensitive nature of the summarized instructions do no matter. This PR adds a verifying assert to confirm this.
This commit is contained in:
@@ -493,6 +493,8 @@ void BottomUpRefCountState::checkAndResetKnownSafety(
|
||||
clearKnownSafe();
|
||||
}
|
||||
|
||||
// This function is conservative enough that the flow sensitive nature of
|
||||
// loop summarized instructions does not matter.
|
||||
void BottomUpRefCountState::updateForDifferentLoopInst(SILInstruction *I,
|
||||
AliasAnalysis *AA) {
|
||||
// If we are not tracking anything, bail.
|
||||
@@ -500,6 +502,8 @@ void BottomUpRefCountState::updateForDifferentLoopInst(SILInstruction *I,
|
||||
return;
|
||||
|
||||
if (valueCanBeGuaranteedUsedGivenLatticeState()) {
|
||||
// Any instruction that may need guaranteed use or may decrement the
|
||||
// refcount will turn off CodeMotionSafety
|
||||
if (mayGuaranteedUseValue(I, getRCRoot(), AA) ||
|
||||
mayDecrementRefCount(I, getRCRoot(), AA)) {
|
||||
LLVM_DEBUG(llvm::dbgs() << " Found potential guaranteed use:\n "
|
||||
@@ -917,12 +921,16 @@ void TopDownRefCountState::checkAndResetKnownSafety(
|
||||
clearKnownSafe();
|
||||
}
|
||||
|
||||
// This function is conservative enough that the flow sensitive nature of
|
||||
// loop summarized instructions does not matter.
|
||||
void TopDownRefCountState::updateForDifferentLoopInst(SILInstruction *I,
|
||||
AliasAnalysis *AA) {
|
||||
// If we are not tracking anything, bail.
|
||||
if (!isTrackingRefCount())
|
||||
return;
|
||||
|
||||
// Any instruction that may need guaranteed use or may decrement the
|
||||
// refcount will turn off CodeMotionSafety
|
||||
if (valueCanBeGuaranteedUsedGivenLatticeState()) {
|
||||
if (mayGuaranteedUseValue(I, getRCRoot(), AA) ||
|
||||
mayDecrementRefCount(I, getRCRoot(), AA)) {
|
||||
|
||||
Reference in New Issue
Block a user