ICInfo::ICInfo(void* start_addr, void* slowpath_rtn_addr, void* continue_addr, StackInfo stack_info, int num_slots, int slot_size, llvm::CallingConv::ID calling_conv, LiveOutSet _live_outs, assembler::GenericRegister return_register, TypeRecorder* type_recorder) : next_slot_to_try(0), stack_info(stack_info), num_slots(num_slots), slot_size(slot_size), calling_conv(calling_conv), live_outs(std::move(_live_outs)), return_register(return_register), type_recorder(type_recorder), retry_in(0), retry_backoff(1), times_rewritten(0), start_addr(start_addr), slowpath_rtn_addr(slowpath_rtn_addr), continue_addr(continue_addr) { for (int i = 0; i < num_slots; i++) { slots.emplace_back(this, i); } #if MOVING_GC assert(ics_list.count(this) == 0); #endif }
bool ConsumedResultToEpilogueRetainMatcher::isTransitiveSuccessorsRetainFree( const llvm::DenseSet<SILBasicBlock *> &BBs) { // For every block with retain, we need to check the transitive // closure of its successors are retain-free. for (auto &I : EpilogueRetainInsts) { for (auto &Succ : I->getParent()->getSuccessors()) { if (BBs.count(Succ)) continue; return false; } } // FIXME: We are iterating over a DenseSet. That can lead to non-determinism // and is in general pretty inefficient since we are iterating over a hash // table. for (auto CBB : BBs) { for (auto &Succ : CBB->getSuccessors()) { if (BBs.count(Succ)) continue; return false; } } return true; }
/// Check whether all operands are loop invariant. static bool hasLoopInvariantOperands(SILInstruction *I, SILLoop *L, llvm::DenseSet<SILInstruction *> &Inv) { auto Opds = I->getAllOperands(); return std::all_of(Opds.begin(), Opds.end(), [=](Operand &Op) { ValueBase *Def = Op.get(); // Operand is outside the loop or marked invariant. if (auto *Inst = Def->getDefiningInstruction()) return !L->contains(Inst->getParent()) || Inv.count(Inst); if (auto *Arg = dyn_cast<SILArgument>(Def)) return !L->contains(Arg->getParent()); return false; }); }
void Fix(CompoundStmt* CS) { if (!CS->size()) return; typedef llvm::SmallVector<Stmt*, 32> Statements; Statements Stmts; Stmts.append(CS->body_begin(), CS->body_end()); for (Statements::iterator I = Stmts.begin(); I != Stmts.end(); ++I) { if (!TraverseStmt(*I) && !m_HandledDecls.count(m_FoundDRE->getDecl())) { Sema::DeclGroupPtrTy VDPtrTy = m_Sema->ConvertDeclToDeclGroup(m_FoundDRE->getDecl()); StmtResult DS = m_Sema->ActOnDeclStmt(VDPtrTy, m_FoundDRE->getLocStart(), m_FoundDRE->getLocEnd()); assert(!DS.isInvalid() && "Invalid DeclStmt."); I = Stmts.insert(I, DS.take()); m_HandledDecls.insert(m_FoundDRE->getDecl()); } } CS->setStmts(m_Sema->getASTContext(), Stmts.data(), Stmts.size()); }
ICInfo::~ICInfo() { #if MOVING_GC assert(ics_list.count(this) == 0); #endif }
void deregisterGCTrackedICInfo(ICInfo* ic) { #if MOVING_GC assert(ics_list.count(ic) == 1); ics_list.erase(ic); #endif }
void registerGCTrackedICInfo(ICInfo* ic) { #if MOVING_GC assert(ics_list.count(ic) == 0); ics_list.insert(ic); #endif }
bool isInterceptedFunction(uintptr_t Address) const { return InterceptorAddresses.count(Address); }
/// \brief Check if a Decl is referenced by non-system code. /// bool isReferenced(::clang::Decl const *D) const { return DeclsReferenced.count(D); }