void EpilogueARCContext::initializeDataflow() { for (auto &B : *F) { // Find the exit blocks. if (isInterestedFunctionExitingBlock(&B)) { ExitBlocks.insert(&B); } // Allocate the storage. EpilogueARCBlockStates[&B] = new (BPA.Allocate()) EpilogueARCBlockState(); } // Split the SILargument into local arguments to each specific basic block. llvm::SmallVector<SILValue, 4> ToProcess; llvm::DenseSet<SILValue> Processed; ToProcess.push_back(Arg); while (!ToProcess.empty()) { SILValue CArg = ToProcess.pop_back_val(); if (!CArg) continue; if (Processed.find(CArg) != Processed.end()) continue; Processed.insert(CArg); SILArgument *A = dyn_cast<SILArgument>(CArg); if (A && !A->isFunctionArg()) { // Find predecessor and break the SILArgument to predecessors. for (auto X : A->getParent()->getPreds()) { // Try to find the predecessor edge-value. SILValue IA = A->getIncomingValue(X); EpilogueARCBlockStates[X]->LocalArg = IA; // Maybe the edge value is another SILArgument. ToProcess.push_back(IA); } } } }
Effects *FunctionEffects::getEffectsOn(SILValue Addr) { SILValue BaseAddr = skipValueProjections(skipAddrProjections(Addr)); switch (BaseAddr->getKind()) { case swift::ValueKind::SILArgument: { // Can we associate the address to a function parameter? SILArgument *Arg = cast<SILArgument>(BaseAddr); if (Arg->isFunctionArg()) { return &ParamEffects[Arg->getIndex()]; } break; } case ValueKind::AllocStackInst: case ValueKind::AllocRefInst: case ValueKind::AllocRefDynamicInst: case ValueKind::AllocBoxInst: // Effects on locally allocated storage. return &LocalEffects; default: break; } // Everything else. return &GlobalEffects; }