mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Delete dead code.
This commit is contained in:
@@ -53,102 +53,6 @@ getGlobalActorInitIsolation(SILFunction *fn) {
|
||||
return getActorIsolation(globalDecl);
|
||||
}
|
||||
|
||||
class DeclRefExprAnalysis {
|
||||
DeclRefExpr *result = nullptr;
|
||||
|
||||
// Be greedy with the small size so we very rarely allocate.
|
||||
SmallVector<Expr *, 8> lookThroughExprs;
|
||||
|
||||
public:
|
||||
bool compute(Expr *expr);
|
||||
|
||||
DeclRefExpr *getResult() const {
|
||||
assert(result && "Not computed?!");
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayRef<Expr *> getLookThroughExprs() const {
|
||||
assert(result && "Not computed?!");
|
||||
return lookThroughExprs;
|
||||
}
|
||||
|
||||
void print(llvm::raw_ostream &os) const {
|
||||
if (!result) {
|
||||
os << "DeclRefExprAnalysis: None.";
|
||||
return;
|
||||
}
|
||||
|
||||
os << "DeclRefExprAnalysis:\n";
|
||||
result->dump(os);
|
||||
os << "\n";
|
||||
if (lookThroughExprs.size()) {
|
||||
os << "LookThroughExprs:\n";
|
||||
for (auto *expr : lookThroughExprs) {
|
||||
expr->dump(os, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
|
||||
|
||||
bool hasNonisolatedUnsafe() const {
|
||||
// See if our initial member_ref_expr is actor instance isolated.
|
||||
for (auto *expr : lookThroughExprs) {
|
||||
// We can skip load expr.
|
||||
if (isa<LoadExpr>(expr))
|
||||
continue;
|
||||
|
||||
if (auto *mri = dyn_cast<MemberRefExpr>(expr)) {
|
||||
if (mri->hasDecl()) {
|
||||
auto isolation = swift::getActorIsolation(mri->getDecl().getDecl());
|
||||
if (isolation.isNonisolatedUnsafe())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bool DeclRefExprAnalysis::compute(Expr *expr) {
|
||||
struct LocalWalker final : ASTWalker {
|
||||
DeclRefExprAnalysis &parentAnalysis;
|
||||
|
||||
LocalWalker(DeclRefExprAnalysis &parentAnalysis)
|
||||
: parentAnalysis(parentAnalysis) {}
|
||||
|
||||
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
|
||||
assert(!parentAnalysis.result && "Shouldn't have a result yet");
|
||||
|
||||
if (auto *dre = dyn_cast<DeclRefExpr>(expr)) {
|
||||
parentAnalysis.result = dre;
|
||||
return Action::Stop();
|
||||
}
|
||||
|
||||
if (isa<CoerceExpr, MemberRefExpr, ImplicitConversionExpr, IdentityExpr>(
|
||||
expr)) {
|
||||
parentAnalysis.lookThroughExprs.push_back(expr);
|
||||
return Action::Continue(expr);
|
||||
}
|
||||
|
||||
return Action::Stop();
|
||||
}
|
||||
};
|
||||
|
||||
LocalWalker walker(*this);
|
||||
|
||||
if (auto *ae = dyn_cast<AssignExpr>(expr)) {
|
||||
ae->getSrc()->walk(walker);
|
||||
} else {
|
||||
expr->walk(walker);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static SILIsolationInfo
|
||||
inferIsolationInfoForTempAllocStack(AllocStackInst *asi) {
|
||||
// We want to search for an alloc_stack that is not from a VarDecl and that is
|
||||
|
||||
Reference in New Issue
Block a user