Skip to content

Commit 13cc88f

Browse files
committed
Revert "[arc] Put back in the RCIdentity cache."
This reverts commit 6c728da. This is a speculative revert to try and fix the ASAN build.
1 parent c1cc39a commit 13cc88f

File tree

2 files changed

+4
-54
lines changed

2 files changed

+4
-54
lines changed

include/swift/SILOptimizer/Analysis/RCIdentityAnalysis.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class DominanceAnalysis;
3232
/// This class is a simple wrapper around an identity cache.
3333
class RCIdentityFunctionInfo {
3434
llvm::DenseSet<SILArgument *> VisitedArgs;
35-
llvm::DenseMap<SILValue, SILValue> Cache;
3635
DominanceAnalysis *DA;
3736

3837
/// This number is arbitrary and conservative. At some point if compile time
@@ -51,16 +50,6 @@ class RCIdentityFunctionInfo {
5150
/// unchecked_trivial_bit_cast.
5251
void getRCUsers(SILValue V, llvm::SmallVectorImpl<SILInstruction *> &Users);
5352

54-
void handleDeleteNotification(SILInstruction *I) {
55-
// Check the cache. If we don't find it, there is nothing to do.
56-
auto Iter = Cache.find(SILValue(I));
57-
if (Iter == Cache.end())
58-
return;
59-
60-
// Then erase Iter from the cache.
61-
Cache.erase(Iter);
62-
}
63-
6453
private:
6554
SILValue getRCIdentityRootInner(SILValue V, unsigned RecursionDepth);
6655
SILValue stripRCIdentityPreservingOps(SILValue V, unsigned RecursionDepth);
@@ -95,23 +84,6 @@ class RCIdentityAnalysis : public FunctionAnalysisBase<RCIdentityFunctionInfo> {
9584
return true;
9685
}
9786

98-
virtual void handleDeleteNotification(ValueBase *V) override {
99-
auto *I = dyn_cast<SILInstruction>(V);
100-
// We are only interesting in SILInstructions.
101-
if (!I || !I->getParentBB())
102-
return;
103-
104-
// If the parent function of this instruction was just turned into an
105-
// external declaration, bail. This happens during SILFunction destruction,
106-
// when
107-
SILFunction *F = I->getFunction();
108-
if (F->isExternalDeclaration()) {
109-
return;
110-
}
111-
get(F)->handleDeleteNotification(I);
112-
}
113-
114-
virtual bool needsNotifications() override { return true; }
11587
};
11688

11789
} // end swift namespace

lib/SILOptimizer/Analysis/RCIdentityAnalysis.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ static bool isRCIdentityPreservingCast(ValueKind Kind) {
5454
// RC Identity Root Instruction Casting
5555
//===----------------------------------------------------------------------===//
5656

57-
static SILValue stripRCIdentityPreservingCasts(SILValue V) {
58-
while (isRCIdentityPreservingCast(V->getKind()))
59-
V = cast<SILInstruction>(V)->getOperand(0);
60-
return V;
61-
}
62-
6357
static SILValue stripRCIdentityPreservingInsts(SILValue V) {
6458
// First strip off RC identity preserving casts.
6559
if (isRCIdentityPreservingCast(V->getKind()))
@@ -451,30 +445,14 @@ SILValue RCIdentityFunctionInfo::getRCIdentityRootInner(SILValue V,
451445
}
452446

453447
SILValue RCIdentityFunctionInfo::getRCIdentityRoot(SILValue V) {
454-
// We save some memory here by stripping off casts from any V. This is good to
455-
// do since stripping off casts is the cheap part of
456-
// stripRCIdentityPreservingInsts and reduces the number of possible values we
457-
// can track.
458-
//
459-
// The expensive parts of stripRCIdentityPreservingInsts function are the
460-
// unique non trivial elt calls. It should be investigated if they fit well
461-
// here as well.
462-
SILValue NoCastV = stripRCIdentityPreservingCasts(V);
463-
auto Iter = Cache.find(NoCastV);
464-
if (Iter != Cache.end())
465-
return Iter->second;
466-
467-
SILValue Root = getRCIdentityRootInner(NoCastV, 0);
448+
SILValue Root = getRCIdentityRootInner(V, 0);
468449
VisitedArgs.clear();
469450

470-
// If we fail to find a root, return NoCastV.
471-
//
472-
// We know that stripping off RC identical preserving casts is always safe, so
473-
// since NoCastV is "better" information, we can return it without issue.
451+
// If we fail to find a root, return V.
474452
if (!Root)
475-
return NoCastV;
453+
return V;
476454

477-
return Cache[NoCastV] = Root;
455+
return Root;
478456
}
479457

480458
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)