mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[g-arc-opts] Allow removing of increment, decrement pairs after seeing partial merges, ensuring that we still will not move them.
This enables us to handle significantly crazier control flow without needing to worry about control dependency issues relating to different groups of insertion points potentially not being control dependent which can cause incorrect behavior in the optimizer. Swift SVN r18861
This commit is contained in:
@@ -219,10 +219,9 @@ bool TopDownRefCountState::merge(const TopDownRefCountState &Other) {
|
||||
// conservatively drop the sequence, to avoid doing partial RR
|
||||
// elimination. If the branch predicates for the two merge differ, mixing
|
||||
// them is unsafe since they are not control dependent.
|
||||
if (LatState == TopDownRefCountState::LatticeState::None || Partial ||
|
||||
Other.Partial) {
|
||||
if (LatState == TopDownRefCountState::LatticeState::None) {
|
||||
RefCountState<TopDownRefCountState>::clear();
|
||||
DEBUG(llvm::dbgs() << " Found LatticeState::None or Partial. "
|
||||
DEBUG(llvm::dbgs() << " Found LatticeState::None. "
|
||||
"Clearing State!\n");
|
||||
return false;
|
||||
}
|
||||
@@ -238,16 +237,10 @@ bool TopDownRefCountState::merge(const TopDownRefCountState &Other) {
|
||||
|
||||
Increments.insert(Other.Increments.begin(), Other.Increments.end());
|
||||
|
||||
Partial = InsertPts.size() != Other.InsertPts.size();
|
||||
Partial |= InsertPts.size() != Other.InsertPts.size();
|
||||
for (auto *SI : Other.InsertPts)
|
||||
Partial |= InsertPts.insert(SI);
|
||||
|
||||
if (Partial) {
|
||||
DEBUG(llvm::dbgs() << " Found partial, clearing state!\n");
|
||||
RefCountState<TopDownRefCountState>::clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,9 +257,8 @@ bool BottomUpRefCountState::merge(const BottomUpRefCountState &Other) {
|
||||
// conservatively drop the sequence, to avoid doing partial RR
|
||||
// elimination. If the branch predicates for the two merge differ, mixing
|
||||
// them is unsafe since they are not control dependent.
|
||||
if (LatState == BottomUpRefCountState::LatticeState::None || Partial ||
|
||||
Other.Partial) {
|
||||
DEBUG(llvm::dbgs() << " Found LatticeState::None or Partial. "
|
||||
if (LatState == BottomUpRefCountState::LatticeState::None) {
|
||||
DEBUG(llvm::dbgs() << " Found LatticeState::None. "
|
||||
"Clearing State!\n");
|
||||
RefCountState<BottomUpRefCountState>::clear();
|
||||
return false;
|
||||
@@ -274,16 +266,10 @@ bool BottomUpRefCountState::merge(const BottomUpRefCountState &Other) {
|
||||
|
||||
Decrements.insert(Other.Decrements.begin(), Other.Decrements.end());
|
||||
|
||||
Partial = InsertPts.size() != Other.InsertPts.size();
|
||||
Partial |= InsertPts.size() != Other.InsertPts.size();
|
||||
for (auto *SI : Other.InsertPts)
|
||||
Partial |= InsertPts.insert(SI);
|
||||
|
||||
if (Partial) {
|
||||
DEBUG(llvm::dbgs() << " Found partial, clearing state!\n");
|
||||
RefCountState<BottomUpRefCountState>::clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user