-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Minor cleanup in ARCSequenceOpts #33578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d87edfa
865d54c
688349f
fb84e13
78dbefa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ llvm::cl::opt<bool> EnableLoopARC("enable-loop-arc", llvm::cl::init(false)); | |
// This routine takes in the ARCMatchingSet \p MatchSet and adds the increments | ||
// and decrements to the delete list. | ||
void ARCPairingContext::optimizeMatchingSet( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to even rename this one to something more descriptive since we only delete instructions now. You could even make this a method on MatchSet. IDK, what are your thoughts. |
||
ARCMatchingSet &MatchSet, llvm::SmallVectorImpl<SILInstruction *> &NewInsts, | ||
ARCMatchingSet &MatchSet, | ||
llvm::SmallVectorImpl<SILInstruction *> &DeadInsts) { | ||
LLVM_DEBUG(llvm::dbgs() << "**** Optimizing Matching Set ****\n"); | ||
// Add the old increments to the delete list. | ||
|
@@ -69,7 +69,6 @@ void ARCPairingContext::optimizeMatchingSet( | |
} | ||
|
||
bool ARCPairingContext::performMatching( | ||
llvm::SmallVectorImpl<SILInstruction *> &NewInsts, | ||
llvm::SmallVectorImpl<SILInstruction *> &DeadInsts) { | ||
bool MatchedPair = false; | ||
|
||
|
@@ -97,7 +96,7 @@ bool ARCPairingContext::performMatching( | |
for (auto *I : Set.Decrements) | ||
DecToIncStateMap.erase(I); | ||
|
||
optimizeMatchingSet(Set, NewInsts, DeadInsts); | ||
optimizeMatchingSet(Set, DeadInsts); | ||
} | ||
} | ||
|
||
|
@@ -131,7 +130,6 @@ void LoopARCPairingContext::runOnFunction(SILFunction *F) { | |
bool LoopARCPairingContext::processRegion(const LoopRegion *Region, | ||
bool FreezePostDomReleases, | ||
bool RecomputePostDomReleases) { | ||
llvm::SmallVector<SILInstruction *, 8> NewInsts; | ||
llvm::SmallVector<SILInstruction *, 8> DeadInsts; | ||
|
||
// We have already summarized all subloops of this loop. Now summarize our | ||
|
@@ -145,16 +143,7 @@ bool LoopARCPairingContext::processRegion(const LoopRegion *Region, | |
do { | ||
NestingDetected = Evaluator.runOnLoop(Region, FreezePostDomReleases, | ||
RecomputePostDomReleases); | ||
MatchedPair = Context.performMatching(NewInsts, DeadInsts); | ||
|
||
if (!NewInsts.empty()) { | ||
LLVM_DEBUG(llvm::dbgs() << "Adding new interesting insts!\n"); | ||
do { | ||
auto *I = NewInsts.pop_back_val(); | ||
LLVM_DEBUG(llvm::dbgs() << " " << *I); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a note to myself. The reason why this code was here was b/c we originally always performed code motion and were always rewriting all rr when making changes. The end result is that we needed to add the new instructions that we inserted to be adding to the interesting instructions inst. Since we are only removing RR now. This is not needed. |
||
Evaluator.addInterestingInst(I); | ||
} while (!NewInsts.empty()); | ||
} | ||
MatchedPair = Context.performMatching(DeadInsts); | ||
|
||
if (!DeadInsts.empty()) { | ||
LLVM_DEBUG(llvm::dbgs() << "Removing dead interesting insts!\n"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,6 @@ bool ARCSequenceDataflowEvaluator::processBBTopDown(ARCBBState &BBState) { | |
void ARCSequenceDataflowEvaluator::mergePredecessors( | ||
ARCBBStateInfoHandle &DataHandle) { | ||
bool HasAtLeastOnePred = false; | ||
llvm::SmallVector<SILBasicBlock *, 4> BBThatNeedInsertPts; | ||
|
||
SILBasicBlock *BB = DataHandle.getBB(); | ||
ARCBBState &BBState = DataHandle.getState(); | ||
|
@@ -223,10 +222,8 @@ bool ARCSequenceDataflowEvaluator::processBBBottomUp( | |
SetFactory); | ||
|
||
auto II = BB.rbegin(); | ||
if (isa<TermInst>(*II)) { | ||
if (!isARCSignificantTerminator(&cast<TermInst>(*II))) { | ||
II++; | ||
} | ||
if (!isARCSignificantTerminator(&cast<TermInst>(*II))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe put a small comment here that we know that we have a TermInst since rbegin is the last instruction in the block and we are in well-formed canonical SIL? |
||
II++; | ||
} | ||
|
||
// For each instruction I in BB visited in reverse... | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,40 +200,14 @@ bool LoopARCSequenceDataflowEvaluator::processLoopBottomUp( | |
bool NestingDetected = false; | ||
|
||
// For each BB in our post order... | ||
auto Start = R->subregion_begin(), End = R->subregion_end(); | ||
if (Start == End) | ||
return false; | ||
|
||
--End; | ||
while (Start != End) { | ||
unsigned SubregionIndex = *End; | ||
for (unsigned SubregionIndex : R->getReverseSubregions()) { | ||
auto *Subregion = LRFI->getRegion(SubregionIndex); | ||
auto &SubregionData = getARCState(Subregion); | ||
|
||
// This will always succeed since we have an entry for each BB in our post | ||
// order. | ||
LLVM_DEBUG(llvm::dbgs() << "Processing Subregion#: " << SubregionIndex | ||
<< "\n"); | ||
|
||
LLVM_DEBUG(llvm::dbgs() << "Merging Successors!\n"); | ||
mergeSuccessors(Subregion, SubregionData); | ||
|
||
// Then perform the region optimization. | ||
NestingDetected |= SubregionData.processBottomUp( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nevermind, I see the other instance of |
||
AA, RCFI, EAFI, LRFI, FreezeOwnedArgEpilogueReleases, IncToDecStateMap, | ||
RegionStateInfo, SetFactory); | ||
--End; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @meg-gupta do you know from the history why the last iteration was originally peeled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't tell much from history. Maybe just an oversight that it wasn't updated with getReverseSubregions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember why I think. I think there was a miscompile from clang with getReverseSubregions() when I wrote this. So I worked around it. Thanks for fixing! |
||
|
||
{ | ||
unsigned SubregionIndex = *End; | ||
auto *Subregion = LRFI->getRegion(SubregionIndex); | ||
auto &SubregionData = getARCState(Subregion); | ||
|
||
// This will always succeed since we have an entry for each BB in our post | ||
// order. | ||
LLVM_DEBUG(llvm::dbgs() << "Processing Subregion#: " << SubregionIndex | ||
<< "\n"); | ||
LLVM_DEBUG(llvm::dbgs() | ||
<< "Processing Subregion#: " << SubregionIndex << "\n"); | ||
|
||
LLVM_DEBUG(llvm::dbgs() << "Merging Successors!\n"); | ||
mergeSuccessors(Subregion, SubregionData); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,9 +285,6 @@ handleRefCountInstMatch(SILInstruction *RefCountInst) { | |
return false; | ||
case LatticeState::Decremented: | ||
case LatticeState::MightBeUsed: | ||
// Unset InsertPt so we remove retain release pairs instead of | ||
// performing code motion. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this change. Was there originally code here that was removed, but the comment wasn't removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there were a lot of stale comments left out about 'InsertPt'. This code was refactored out and a lot of functionality moved to ARCCodeMotion. |
||
LLVM_FALLTHROUGH; | ||
case LatticeState::MightBeDecremented: | ||
return true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice rename! Much better name! And thanks for the great comment improvement!