llvm.org GIT mirror llvm / db77b82
Revert "Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size." Getting a weird buildbot failure that I need to investigate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215870 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
49 changed file(s) with 114 addition(s) and 114 deletion(s). Raw diff Collapse all Expand all
173173 /// dump - This method is used for debugging.
174174 void dump() const;
175175 protected:
176 bool AddUsersImpl(Instruction *I, SmallPtrSetImpl> &SimpleLoopNests);
176 bool AddUsersImpl(Instruction *I, SmallPtrSet> &SimpleLoopNests);
177177 };
178178
179179 Pass *createIVUsersPass();
162162 /// which have machine instructions that belong to lexical scope identified by
163163 /// DebugLoc.
164164 void getMachineBasicBlocks(DebugLoc DL,
165 SmallPtrSetImpl> &MBBs);
165 SmallPtrSet> &MBBs);
166166
167167 /// dominates - Return true if DebugLoc's lexical scope dominates at least one
168168 /// machine instruction's lexical scope in a given machine basic block.
593593 /// changes.
594594 /// NOTE: This is still very expensive. Use carefully.
595595 bool hasPredecessorHelper(const SDNode *N,
596 SmallPtrSetImpl> &Visited,
596 SmallPtrSet> &Visited,
597597 SmallVectorImpl &Worklist) const;
598598
599599 /// getNumOperands - Return the number of values used by this operation.
248248 bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
249249
250250 /// isSized - Return true if this is a sized type.
251 bool isSized(SmallPtrSetImpl> *Visited = nullptr) const;
251 bool isSized(SmallPtrSet> *Visited = nullptr) const;
252252
253253 /// hasName - Return true if this is a named struct that has a non-empty name.
254254 bool hasName() const { return SymbolTableEntry != nullptr; }
264264 /// get the actual size for a particular target, it is reasonable to use the
265265 /// DataLayout subsystem to do this.
266266 ///
267 bool isSized(SmallPtrSetImpl> *Visited = nullptr) const {
267 bool isSized(SmallPtrSet> *Visited = nullptr) const {
268268 // If it's a primitive, it is always sized.
269269 if (getTypeID() == IntegerTyID || isFloatingPointTy() ||
270270 getTypeID() == PointerTyID ||
418418 /// isSizedDerivedType - Derived types like structures and arrays are sized
419419 /// iff all of the members of the type are sized as well. Since asking for
420420 /// their size is relatively uncommon, move this operation out of line.
421 bool isSizedDerivedType(SmallPtrSetImpl> *Visited = nullptr) const;
421 bool isSizedDerivedType(SmallPtrSet> *Visited = nullptr) const;
422422 };
423423
424424 // Printing of types.
123123 void applyScopeRestrictions();
124124 void applyRestriction(GlobalValue &GV, const ArrayRef &Libcalls,
125125 std::vector &MustPreserveList,
126 SmallPtrSetImpl> &AsmUsed,
126 SmallPtrSet> &AsmUsed,
127127 Mangler &Mangler);
128128 bool determineTarget(std::string &errMsg);
129129
1919 class Function;
2020 class GlobalValue;
2121 class GlobalVariable;
22 template > class SmallPtrSetImpl;
22 template , unsigned SmallSize> class SmallPtrSet;
2323
2424 /// Append F to the list of global ctors of module M with the given Priority.
2525 /// This wraps the function in the appropriate structure and stores it along
3333 /// \brief Given "llvm.used" or "llvm.compiler.used" as a global name, collect
3434 /// the initializer elements of that global in Set and return the global itself.
3535 GlobalVariable *collectUsedGlobalVariables(Module &M,
36 SmallPtrSetImpl> &Set,
36 SmallPtrSet> &Set,
3737 bool CompilerUsed);
3838 } // End llvm namespace
3939
966966 static Constant *
967967 ConstantFoldConstantExpressionImpl(const ConstantExpr *CE, const DataLayout *TD,
968968 const TargetLibraryInfo *TLI,
969 SmallPtrSetImpl> &FoldedOps) {
969 SmallPtrSet> &FoldedOps) {
970970 SmallVector Ops;
971971 for (User::const_op_iterator i = CE->op_begin(), e = CE->op_end(); i != e;
972972 ++i) {
8383 /// form.
8484 static bool isSimplifiedLoopNest(BasicBlock *BB, const DominatorTree *DT,
8585 const LoopInfo *LI,
86 SmallPtrSetImpl> &SimpleLoopNests) {
86 SmallPtrSet> &SimpleLoopNests) {
8787 Loop *NearestLoop = nullptr;
8888 for (DomTreeNode *Rung = DT->getNode(BB);
8989 Rung; Rung = Rung->getIDom()) {
111111 /// reducible SCEV, recursively add its users to the IVUsesByStride set and
112112 /// return true. Otherwise, return false.
113113 bool IVUsers::AddUsersImpl(Instruction *I,
114 SmallPtrSetImpl> &SimpleLoopNests) {
114 SmallPtrSet> &SimpleLoopNests) {
115115 // Add this IV user to the Processed set before returning false to ensure that
116116 // all IV users are members of the set. See IVUsers::isIVUserOrOperand.
117117 if (!Processed.insert(I))
9595
9696 Value *findValue(Value *V, bool OffsetOk) const;
9797 Value *findValueImpl(Value *V, bool OffsetOk,
98 SmallPtrSetImpl> &Visited) const;
98 SmallPtrSet> &Visited) const;
9999
100100 public:
101101 Module *Mod;
621621
622622 /// findValueImpl - Implementation helper for findValue.
623623 Value *Lint::findValueImpl(Value *V, bool OffsetOk,
624 SmallPtrSetImpl> &Visited) const {
624 SmallPtrSet> &Visited) const {
625625 // Detect self-referential values.
626626 if (!Visited.insert(V))
627627 return UndefValue::get(V->getType());
18321832
18331833 /// GetStringLengthH - If we can compute the length of the string pointed to by
18341834 /// the specified pointer, return 'len+1'. If we can't, return 0.
1835 static uint64_t GetStringLengthH(Value *V, SmallPtrSetImpl> &PHIs) {
1835 static uint64_t GetStringLengthH(Value *V, SmallPtrSet> &PHIs) {
18361836 // Look through noop bitcast instructions.
18371837 V = V->stripPointerCasts();
18381838
11481148
11491149 // Collect variable information from side table maintained by MMI.
11501150 void DwarfDebug::collectVariableInfoFromMMITable(
1151 SmallPtrSetImpl> &Processed) {
1151 SmallPtrSet> &Processed) {
11521152 for (const auto &VI : MMI->getVariableDbgInfo()) {
11531153 if (!VI.Var)
11541154 continue;
13071307
13081308 // Find variables for each lexical scope.
13091309 void
1310 DwarfDebug::collectVariableInfo(SmallPtrSetImpl> &Processed) {
1310 DwarfDebug::collectVariableInfo(SmallPtrSet> &Processed) {
13111311 LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
13121312 DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
13131313
532532 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
533533
534534 /// \brief Populate LexicalScope entries with variables' info.
535 void collectVariableInfo(SmallPtrSetImpl> &ProcessedVars);
535 void collectVariableInfo(SmallPtrSet> &ProcessedVars);
536536
537537 /// \brief Build the location list for all DBG_VALUEs in the
538538 /// function that describe the same variable.
541541
542542 /// \brief Collect variable information from the side table maintained
543543 /// by MMI.
544 void collectVariableInfoFromMMITable(SmallPtrSetImpl> &P);
544 void collectVariableInfoFromMMITable(SmallPtrSet> &P);
545545
546546 /// \brief Ensure that a label will be emitted before MI.
547547 void requestLabelBeforeInsn(const MachineInstr *MI) {
22962296 /// Add the ultimately found memory instructions to MemoryUses.
22972297 static bool FindAllMemoryUses(Instruction *I,
22982298 SmallVectorImpl > &MemoryUses,
2299 SmallPtrSetImpl> &ConsideredInsts,
2299 SmallPtrSet> &ConsideredInsts,
23002300 const TargetLowering &TLI) {
23012301 // If we already considered this instruction, we're done.
23022302 if (!ConsideredInsts.insert(I))
284284 /// have machine instructions that belong to lexical scope identified by
285285 /// DebugLoc.
286286 void LexicalScopes::getMachineBasicBlocks(
287 DebugLoc DL, SmallPtrSetImpl> &MBBs) {
287 DebugLoc DL, SmallPtrSet> &MBBs) {
288288 MBBs.clear();
289289 LexicalScope *Scope = getOrCreateLexicalScope(DL);
290290 if (!Scope)
14381438 /// Add erased instructions to ErasedInstrs.
14391439 /// Add foreign virtual registers to ShrinkRegs if their live range ended at
14401440 /// the erased instrs.
1441 void eraseInstrs(SmallPtrSetImpl> &ErasedInstrs,
1441 void eraseInstrs(SmallPtrSet> &ErasedInstrs,
14421442 SmallVectorImpl &ShrinkRegs);
14431443
14441444 /// Get the value assignments suitable for passing to LiveInterval::join.
19511951 }
19521952 }
19531953
1954 void JoinVals::eraseInstrs(SmallPtrSetImpl> &ErasedInstrs,
1954 void JoinVals::eraseInstrs(SmallPtrSet> &ErasedInstrs,
19551955 SmallVectorImpl &ShrinkRegs) {
19561956 for (unsigned i = 0, e = LI.getNumValNums(); i != e; ++i) {
19571957 // Get the def location before markUnused() below invalidates it.
574574 static unsigned
575575 iterateChainSucc(AliasAnalysis *AA, const MachineFrameInfo *MFI,
576576 SUnit *SUa, SUnit *SUb, SUnit *ExitSU, unsigned *Depth,
577 SmallPtrSetImpl> &Visited) {
577 SmallPtrSet> &Visited) {
578578 if (!SUa || !SUb || SUb == ExitSU)
579579 return *Depth;
580580
63976397
63986398 bool
63996399 SDNode::hasPredecessorHelper(const SDNode *N,
6400 SmallPtrSetImpl> &Visited,
6400 SmallPtrSet> &Visited,
64016401 SmallVectorImpl &Worklist) const {
64026402 if (Visited.empty()) {
64036403 Worklist.push_back(this);
67756775
67766776 #ifndef NDEBUG
67776777 static void checkForCyclesHelper(const SDNode *N,
6778 SmallPtrSetImpl &Visited,
6779 SmallPtrSetImpl &Checked,
6778 SmallPtrSet &Visited,
6779 SmallPtrSet &Checked,
67806780 const llvm::SelectionDAG *DAG) {
67816781 // If this node has already been checked, don't check it again.
67826782 if (Checked.count(N))
17301730 /// This function recursively traverses up the operand chain, ignoring
17311731 /// certain nodes.
17321732 static bool findNonImmUse(SDNode *Use, SDNode* Def, SDNode *ImmedUse,
1733 SDNode *Root, SmallPtrSetImpl> &Visited,
1733 SDNode *Root, SmallPtrSet> &Visited,
17341734 bool IgnoreChains) {
17351735 // The NodeID's are given uniques ID's where a node ID is guaranteed to be
17361736 // greater than all of its (recursive) operands. If we scan to a point where
138138 /// MarkBlocksLiveIn - Insert BB and all of its predescessors into LiveBBs until
139139 /// we reach blocks we've already seen.
140140 static void MarkBlocksLiveIn(BasicBlock *BB,
141 SmallPtrSetImpl> &LiveBBs) {
141 SmallPtrSet> &LiveBBs) {
142142 if (!LiveBBs.insert(BB))
143143 return; // already been here.
144144
282282 }
283283
284284 static bool canTrapImpl(const Constant *C,
285 SmallPtrSetImpl> &NonTrappingOps) {
285 SmallPtrSet> &NonTrappingOps) {
286286 assert(C->getType()->isFirstClassType() && "Cannot evaluate aggregate vals!");
287287 // The only thing that could possibly trap are constant exprs.
288288 const ConstantExpr *CE = dyn_cast(C);
154154 /// isSizedDerivedType - Derived types like structures and arrays are sized
155155 /// iff all of the members of the type are sized as well. Since asking for
156156 /// their size is relatively uncommon, move this operation out of line.
157 bool Type::isSizedDerivedType(SmallPtrSetImpl> *Visited) const {
157 bool Type::isSizedDerivedType(SmallPtrSet> *Visited) const {
158158 if (const ArrayType *ATy = dyn_cast(this))
159159 return ATy->getElementType()->isSized(Visited);
160160
553553 return Ret;
554554 }
555555
556 bool StructType::isSized(SmallPtrSetImpl> *Visited) const {
556 bool StructType::isSized(SmallPtrSet> *Visited) const {
557557 if ((getSubclassData() & SCDB_IsSized) != 0)
558558 return true;
559559 if (isOpaque())
302302 }
303303
304304 #ifndef NDEBUG
305 static bool contains(SmallPtrSetImpl> &Cache, ConstantExpr *Expr,
305 static bool contains(SmallPtrSet> &Cache, ConstantExpr *Expr,
306306 Constant *C) {
307307 if (!Cache.insert(Expr))
308308 return false;
475475 /// isDereferenceablePointer - Test if this value is always a pointer to
476476 /// allocated and suitably aligned memory for a simple load or store.
477477 static bool isDereferenceablePointer(const Value *V, const DataLayout *DL,
478 SmallPtrSetImpl> &Visited) {
478 SmallPtrSet> &Visited) {
479479 // Note that it is not safe to speculate into a malloc'd region because
480480 // malloc may return null.
481481
256256 void visitGlobalVariable(const GlobalVariable &GV);
257257 void visitGlobalAlias(const GlobalAlias &GA);
258258 void visitAliaseeSubExpr(const GlobalAlias &A, const Constant &C);
259 void visitAliaseeSubExpr(SmallPtrSetImpl> &Visited,
259 void visitAliaseeSubExpr(SmallPtrSet> &Visited,
260260 const GlobalAlias &A, const Constant &C);
261261 void visitNamedMDNode(const NamedMDNode &NMD);
262262 void visitMDNode(MDNode &MD, Function *F);
501501 visitAliaseeSubExpr(Visited, GA, C);
502502 }
503503
504 void Verifier::visitAliaseeSubExpr(SmallPtrSetImpl> &Visited,
504 void Verifier::visitAliaseeSubExpr(SmallPtrSet> &Visited,
505505 const GlobalAlias &GA, const Constant &C) {
506506 if (const auto *GV = dyn_cast(&C)) {
507507 Assert1(!GV->isDeclaration(), "Alias must point to a definition", &GA);
313313 applyRestriction(GlobalValue &GV,
314314 const ArrayRef &Libcalls,
315315 std::vector &MustPreserveList,
316 SmallPtrSetImpl> &AsmUsed,
316 SmallPtrSet> &AsmUsed,
317317 Mangler &Mangler) {
318318 // There are no restrictions to apply to declarations.
319319 if (GV.isDeclaration())
342342 }
343343
344344 static void findUsedValues(GlobalVariable *LLVMUsed,
345 SmallPtrSetImpl> &UsedValues) {
345 SmallPtrSet> &UsedValues) {
346346 if (!LLVMUsed) return;
347347
348348 ConstantArray *Inits = cast(LLVMUsed->getInitializer());
17131713 static bool IsSafeAndProfitableToMove(bool isLd, unsigned Base,
17141714 MachineBasicBlock::iterator I,
17151715 MachineBasicBlock::iterator E,
1716 SmallPtrSetImpl> &MemOps,
1716 SmallPtrSet> &MemOps,
17171717 SmallSet &MemRegs,
17181718 const TargetRegisterInfo *TRI) {
17191719 // Are there stores / loads / calls between them?
8080 CallGraphNode *PromoteArguments(CallGraphNode *CGN);
8181 bool isSafeToPromoteArgument(Argument *Arg, bool isByVal) const;
8282 CallGraphNode *DoPromotion(Function *F,
83 SmallPtrSetImpl &ArgsToPromote,
84 SmallPtrSetImpl &ByValArgsToTransform);
83 SmallPtrSet &ArgsToPromote,
84 SmallPtrSet &ByValArgsToTransform);
8585
8686 using llvm::Pass::doInitialization;
8787 bool doInitialization(CallGraph &CG) override;
494494 /// arguments, and returns the new function. At this point, we know that it's
495495 /// safe to do so.
496496 CallGraphNode *ArgPromotion::DoPromotion(Function *F,
497 SmallPtrSetImpl &ArgsToPromote,
498 SmallPtrSetImpl &ByValArgsToTransform) {
497 SmallPtrSet &ArgsToPromote,
498 SmallPtrSet &ByValArgsToTransform) {
499499
500500 // Start by computing a new prototype for the function, which is the same as
501501 // the old function, but has modified arguments.
6565
6666 /// Find values that are marked as llvm.used.
6767 static void FindUsedValues(GlobalVariable *LLVMUsed,
68 SmallPtrSetImpl> &UsedValues) {
68 SmallPtrSet> &UsedValues) {
6969 if (!LLVMUsed) return;
7070 ConstantArray *Inits = cast(LLVMUsed->getInitializer());
7171
611611 /// value will trap if the value is dynamically null. PHIs keeps track of any
612612 /// phi nodes we've seen to avoid reprocessing them.
613613 static bool AllUsesOfValueWillTrapIfNull(const Value *V,
614 SmallPtrSetImpl> &PHIs) {
614 SmallPtrSet> &PHIs) {
615615 for (const User *U : V->users())
616616 if (isa(U)) {
617617 // Will trap.
956956 /// it is to the specified global.
957957 static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(const Instruction *V,
958958 const GlobalVariable *GV,
959 SmallPtrSetImpl> &PHIs) {
959 SmallPtrSet> &PHIs) {
960960 for (const User *U : V->users()) {
961961 const Instruction *Inst = cast(U);
962962
10461046 /// of a load) are simple enough to perform heap SRA on. This permits GEP's
10471047 /// that index through the array and struct field, icmps of null, and PHIs.
10481048 static bool LoadUsesSimpleEnoughForHeapSRA(const Value *V,
1049 SmallPtrSetImpl &LoadUsingPHIs,
1050 SmallPtrSetImpl &LoadUsingPHIsPerLoad) {
1049 SmallPtrSet &LoadUsingPHIs,
1050 SmallPtrSet &LoadUsingPHIsPerLoad) {
10511051 // We permit two users of the load: setcc comparing against the null
10521052 // pointer, and a getelementptr of a specific form.
10531053 for (const User *U : V->users()) {
19741974
19751975 static inline bool
19761976 isSimpleEnoughValueToCommit(Constant *C,
1977 SmallPtrSetImpl> &SimpleConstants,
1977 SmallPtrSet> &SimpleConstants,
19781978 const DataLayout *DL);
19791979
19801980
19871987 /// in SimpleConstants to avoid having to rescan the same constants all the
19881988 /// time.
19891989 static bool isSimpleEnoughValueToCommitHelper(Constant *C,
1990 SmallPtrSetImpl> &SimpleConstants,
1990 SmallPtrSet> &SimpleConstants,
19911991 const DataLayout *DL) {
19921992 // Simple global addresses are supported, do not allow dllimport or
19931993 // thread-local globals.
20452045
20462046 static inline bool
20472047 isSimpleEnoughValueToCommit(Constant *C,
2048 SmallPtrSetImpl> &SimpleConstants,
2048 SmallPtrSet> &SimpleConstants,
20492049 const DataLayout *DL) {
20502050 // If we already checked this constant, we win.
20512051 if (!SimpleConstants.insert(C)) return true;
22162216 return MutatedMemory;
22172217 }
22182218
2219 const SmallPtrSetImpl> &getInvariants() const {
2219 const SmallPtrSet> &getInvariants() const {
22202220 return Invariants;
22212221 }
22222222
27242724 }
27252725
27262726 static void setUsedInitializer(GlobalVariable &V,
2727 SmallPtrSetImpl> Init) {
2727 SmallPtrSet> Init) {
27282728 if (Init.empty()) {
27292729 V.eraseFromParent();
27302730 return;
190190
191191 /// Find values that are marked as llvm.used.
192192 static void findUsedValues(GlobalVariable *LLVMUsed,
193 SmallPtrSetImpl> &UsedValues) {
193 SmallPtrSet> &UsedValues) {
194194 if (!LLVMUsed) return;
195195 UsedValues.insert(LLVMUsed);
196196
505505 /// DeadPHICycle - Return true if this PHI node is only used by a PHI node cycle
506506 /// that is dead.
507507 static bool DeadPHICycle(PHINode *PN,
508 SmallPtrSetImpl> &PotentiallyDeadPHIs) {
508 SmallPtrSet> &PotentiallyDeadPHIs) {
509509 if (PN->use_empty()) return true;
510510 if (!PN->hasOneUse()) return false;
511511
527527 /// NonPhiInVal. This happens with mutually cyclic phi nodes like:
528528 /// z = some value; x = phi (y, z); y = phi (x, z)
529529 static bool PHIsEqualValue(PHINode *PN, Value *NonPhiInVal,
530 SmallPtrSetImpl> &ValueEqualPHIs) {
530 SmallPtrSet> &ValueEqualPHIs) {
531531 // See if we already saw this PHI node.
532532 if (!ValueEqualPHIs.insert(PN))
533533 return true;
25472547 /// whose condition is a known constant, we only visit the reachable successors.
25482548 ///
25492549 static bool AddReachableCodeToWorklist(BasicBlock *BB,
2550 SmallPtrSetImpl> &Visited,
2550 SmallPtrSet> &Visited,
25512551 InstCombiner &IC,
25522552 const DataLayout *DL,
25532553 const TargetLibraryInfo *TLI) {
205205 llvm::objcarc::FindDependencies(DependenceKind Flavor,
206206 const Value *Arg,
207207 BasicBlock *StartBB, Instruction *StartInst,
208 SmallPtrSetImpl &DependingInsts,
209 SmallPtrSetImpl &Visited,
208 SmallPtrSet &DependingInsts,
209 SmallPtrSet &Visited,
210210 ProvenanceAnalysis &PA) {
211211 BasicBlock::iterator StartPos = StartInst;
212212
5252 void FindDependencies(DependenceKind Flavor,
5353 const Value *Arg,
5454 BasicBlock *StartBB, Instruction *StartInst,
55 SmallPtrSetImpl &DependingInstructions,
56 SmallPtrSetImpl &Visited,
55 SmallPtrSet &DependingInstructions,
56 SmallPtrSet &Visited,
5757 ProvenanceAnalysis &PA);
5858
5959 bool
7171
7272 bool ContractAutorelease(Function &F, Instruction *Autorelease,
7373 InstructionClass Class,
74 SmallPtrSetImpl>
74 SmallPtrSet>
7575 &DependingInstructions,
76 SmallPtrSetImpl>
76 SmallPtrSet>
7777 &Visited);
7878
7979 void ContractRelease(Instruction *Release,
149149 bool
150150 ObjCARCContract::ContractAutorelease(Function &F, Instruction *Autorelease,
151151 InstructionClass Class,
152 SmallPtrSetImpl>
152 SmallPtrSet>
153153 &DependingInstructions,
154 SmallPtrSetImpl>
154 SmallPtrSet>
155155 &Visited) {
156156 const Value *Arg = GetObjCArg(Autorelease);
157157
28492849 /// shared pointer argument. Note that Retain need not be in BB.
28502850 static bool
28512851 HasSafePathToPredecessorCall(const Value *Arg, Instruction *Retain,
2852 SmallPtrSetImpl &DepInsts,
2853 SmallPtrSetImpl &Visited,
2852 SmallPtrSet &DepInsts,
2853 SmallPtrSet &Visited,
28542854 ProvenanceAnalysis &PA) {
28552855 FindDependencies(CanChangeRetainCount, Arg, Retain->getParent(), Retain,
28562856 DepInsts, Visited, PA);
28782878 static CallInst *
28792879 FindPredecessorRetainWithSafePath(const Value *Arg, BasicBlock *BB,
28802880 Instruction *Autorelease,
2881 SmallPtrSetImpl &DepInsts,
2882 SmallPtrSetImpl &Visited,
2881 SmallPtrSet &DepInsts,
2882 SmallPtrSet &Visited,
28832883 ProvenanceAnalysis &PA) {
28842884 FindDependencies(CanChangeRetainCount, Arg,
28852885 BB, Autorelease, DepInsts, Visited, PA);
29052905 static CallInst *
29062906 FindPredecessorAutoreleaseWithSafePath(const Value *Arg, BasicBlock *BB,
29072907 ReturnInst *Ret,
2908 SmallPtrSetImpl &DepInsts,
2909 SmallPtrSetImpl &V,
2908 SmallPtrSet &DepInsts,
2909 SmallPtrSet &V,
29102910 ProvenanceAnalysis &PA) {
29112911 FindDependencies(NeedsPositiveRetainCount, Arg,
29122912 BB, Ret, DepInsts, V, PA);
11991199 /// BackedgeTakenInfo. If these expressions have not been reduced, then
12001200 /// expanding them may incur additional cost (albeit in the loop preheader).
12011201 static bool isHighCostExpansion(const SCEV *S, BranchInst *BI,
1202 SmallPtrSetImpl> &Processed,
1202 SmallPtrSet> &Processed,
12031203 ScalarEvolution *SE) {
12041204 if (!Processed.insert(S))
12051205 return false;
13721372 /// Recursive helper for hasConcreteDef(). Unfortunately, this currently boils
13731373 /// down to checking that all operands are constant and listing instructions
13741374 /// that may hide undef.
1375 static bool hasConcreteDefImpl(Value *V, SmallPtrSetImpl> &Visited,
1375 static bool hasConcreteDefImpl(Value *V, SmallPtrSet> &Visited,
13761376 unsigned Depth) {
13771377 if (isa(V))
13781378 return !isa(V);
684684 namespace {
685685 class LoopPromoter : public LoadAndStorePromoter {
686686 Value *SomePtr; // Designated pointer to store to.
687 SmallPtrSetImpl> &PointerMustAliases;
687 SmallPtrSet> &PointerMustAliases;
688688 SmallVectorImpl &LoopExitBlocks;
689689 SmallVectorImpl &LoopInsertPts;
690690 PredIteratorCache &PredCache;
712712
713713 public:
714714 LoopPromoter(Value *SP, const SmallVectorImpl &Insts,
715 SSAUpdater &S, SmallPtrSetImpl> &PMA,
715 SSAUpdater &S, SmallPtrSet> &PMA,
716716 SmallVectorImpl &LEB,
717717 SmallVectorImpl &LIP, PredIteratorCache &PIC,
718718 AliasSetTracker &ast, LoopInfo &li, DebugLoc dl, int alignment,
743743 /// TODO: Allow UDivExpr if we can find an existing IV increment that is an
744744 /// obvious multiple of the UDivExpr.
745745 static bool isHighCostExpansion(const SCEV *S,
746 SmallPtrSetImpl> &Processed,
746 SmallPtrSet> &Processed,
747747 ScalarEvolution &SE) {
748748 // Zero/One operand expressions
749749 switch (S->getSCEVType()) {
891891
892892 void RateFormula(const TargetTransformInfo &TTI,
893893 const Formula &F,
894 SmallPtrSetImpl> &Regs,
894 SmallPtrSet> &Regs,
895895 const DenseSet &VisitedRegs,
896896 const Loop *L,
897897 const SmallVectorImpl &Offsets,
898898 ScalarEvolution &SE, DominatorTree &DT,
899899 const LSRUse &LU,
900 SmallPtrSetImpl> *LoserRegs = nullptr);
900 SmallPtrSet> *LoserRegs = nullptr);
901901
902902 void print(raw_ostream &OS) const;
903903 void dump() const;
904904
905905 private:
906906 void RateRegister(const SCEV *Reg,
907 SmallPtrSetImpl> &Regs,
907 SmallPtrSet> &Regs,
908908 const Loop *L,
909909 ScalarEvolution &SE, DominatorTree &DT);
910910 void RatePrimaryRegister(const SCEV *Reg,
911 SmallPtrSetImpl> &Regs,
911 SmallPtrSet> &Regs,
912912 const Loop *L,
913913 ScalarEvolution &SE, DominatorTree &DT,
914 SmallPtrSetImpl> *LoserRegs);
914 SmallPtrSet> *LoserRegs);
915915 };
916916
917917 }
918918
919919 /// RateRegister - Tally up interesting quantities from the given register.
920920 void Cost::RateRegister(const SCEV *Reg,
921 SmallPtrSetImpl> &Regs,
921 SmallPtrSet> &Regs,
922922 const Loop *L,
923923 ScalarEvolution &SE, DominatorTree &DT) {
924924 if (const SCEVAddRecExpr *AR = dyn_cast(Reg)) {
966966 /// before, rate it. Optional LoserRegs provides a way to declare any formula
967967 /// that refers to one of those regs an instant loser.
968968 void Cost::RatePrimaryRegister(const SCEV *Reg,
969 SmallPtrSetImpl> &Regs,
969 SmallPtrSet> &Regs,
970970 const Loop *L,
971971 ScalarEvolution &SE, DominatorTree &DT,
972 SmallPtrSetImpl> *LoserRegs) {
972 SmallPtrSet> *LoserRegs) {
973973 if (LoserRegs && LoserRegs->count(Reg)) {
974974 Lose();
975975 return;
983983
984984 void Cost::RateFormula(const TargetTransformInfo &TTI,
985985 const Formula &F,
986 SmallPtrSetImpl> &Regs,
986 SmallPtrSet> &Regs,
987987 const DenseSet &VisitedRegs,
988988 const Loop *L,
989989 const SmallVectorImpl &Offsets,
990990 ScalarEvolution &SE, DominatorTree &DT,
991991 const LSRUse &LU,
992 SmallPtrSetImpl> *LoserRegs) {
992 SmallPtrSet> *LoserRegs) {
993993 assert(F.isCanonical() && "Cost is accurate only for canonical formula");
994994 // Tally up the registers.
995995 if (const SCEV *ScaledReg = F.ScaledReg) {
25562556 ///
25572557 /// TODO: Consider IVInc free if it's already used in another chains.
25582558 static bool
2559 isProfitableChain(IVChain &Chain, SmallPtrSetImpl> &Users,
2559 isProfitableChain(IVChain &Chain, SmallPtrSet> &Users,
25602560 ScalarEvolution &SE, const TargetTransformInfo &TTI) {
25612561 if (StressIVChain)
25622562 return true;
989989 bool splitAlloca(AllocaInst &AI, AllocaSlices &S);
990990 bool runOnAlloca(AllocaInst &AI);
991991 void clobberUse(Use &U);
992 void deleteDeadInstructions(SmallPtrSetImpl> &DeletedAllocas);
992 void deleteDeadInstructions(SmallPtrSet> &DeletedAllocas);
993993 bool promoteAllocas(Function &F);
994994 };
995995 }
34983498 ///
34993499 /// We also record the alloca instructions deleted here so that they aren't
35003500 /// subsequently handed to mem2reg to promote.
3501 void SROA::deleteDeadInstructions(SmallPtrSetImpl> &DeletedAllocas) {
3501 void SROA::deleteDeadInstructions(SmallPtrSet> &DeletedAllocas) {
35023502 while (!DeadInsts.empty()) {
35033503 Instruction *I = DeadInsts.pop_back_val();
35043504 DEBUG(dbgs() << "Deleting dead instruction: " << *I << "\n");
35233523
35243524 static void enqueueUsersInWorklist(Instruction &I,
35253525 SmallVectorImpl &Worklist,
3526 SmallPtrSetImpl> &Visited) {
3526 SmallPtrSet> &Visited) {
35273527 for (User *U : I.users())
35283528 if (Visited.insert(cast(U)))
35293529 Worklist.push_back(cast(U));
5555 }
5656 private:
5757 bool ProcessBlock(BasicBlock &BB);
58 bool SinkInstruction(Instruction *I, SmallPtrSetImpl> &Stores);
58 bool SinkInstruction(Instruction *I, SmallPtrSet> &Stores);
5959 bool AllUsesDominatedByBlock(Instruction *Inst, BasicBlock *BB) const;
6060 bool IsAcceptableTarget(Instruction *Inst, BasicBlock *SuccToSinkTo) const;
6161 };
156156 }
157157
158158 static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
159 SmallPtrSetImpl> &Stores) {
159 SmallPtrSet> &Stores) {
160160
161161 if (Inst->mayWriteToMemory()) {
162162 Stores.insert(Inst);
219219 /// SinkInstruction - Determine whether it is safe to sink the specified machine
220220 /// instruction out of its current block into a successor.
221221 bool Sinking::SinkInstruction(Instruction *Inst,
222 SmallPtrSetImpl> &Stores) {
222 SmallPtrSet> &Stores) {
223223
224224 // Don't sink static alloca instructions. CodeGen assumes allocas outside the
225225 // entry block are dynamically sized stack objects.
4444 }
4545
4646 static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
47 SmallPtrSetImpl> &PhiUsers) {
47 SmallPtrSet> &PhiUsers) {
4848 for (const Use &U : V->uses()) {
4949 const User *UR = U.getUser();
5050 if (const ConstantExpr *CE = dyn_cast(UR)) {
9797 /// split the landing pad block after the landingpad instruction and jump
9898 /// to there.
9999 void forwardResume(ResumeInst *RI,
100 SmallPtrSetImpl> &InlinedLPads);
100 SmallPtrSet> &InlinedLPads);
101101
102102 /// addIncomingPHIValuesFor - Add incoming-PHI values to the unwind
103103 /// destination block for the given basic block, using the values for the
156156 /// branch. When there is more than one predecessor, we need to split the
157157 /// landing pad block after the landingpad instruction and jump to there.
158158 void InvokeInliningInfo::forwardResume(ResumeInst *RI,
159 SmallPtrSetImpl> &InlinedLPads) {
159 SmallPtrSet> &InlinedLPads) {
160160 BasicBlock *Dest = getInnerResumeDest();
161161 BasicBlock *Src = RI->getParent();
162162
11771177 }
11781178
11791179 static bool markAliveBlocks(BasicBlock *BB,
1180 SmallPtrSetImpl> &Reachable) {
1180 SmallPtrSet> &Reachable) {
11811181
11821182 SmallVector Worklist;
11831183 Worklist.push_back(BB);
7777 }
7878
7979 GlobalVariable *
80 llvm::collectUsedGlobalVariables(Module &M, SmallPtrSetImpl> &Set,
80 llvm::collectUsedGlobalVariables(Module &M, SmallPtrSet> &Set,
8181 bool CompilerUsed) {
8282 const char *Name = CompilerUsed ? "llvm.compiler.used" : "llvm.used";
8383 GlobalVariable *GV = M.getGlobalVariable(Name);
301301 void DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
302302 AllocaInfo &Info);
303303 void ComputeLiveInBlocks(AllocaInst *AI, AllocaInfo &Info,
304 const SmallPtrSetImpl &DefBlocks,
305 SmallPtrSetImpl &LiveInBlocks);
304 const SmallPtrSet &DefBlocks,
305 SmallPtrSet &LiveInBlocks);
306306 void RenamePass(BasicBlock *BB, BasicBlock *Pred,
307307 RenamePassData::ValVector &IncVals,
308308 std::vector &Worklist);
765765 /// inserted phi nodes would be dead).
766766 void PromoteMem2Reg::ComputeLiveInBlocks(
767767 AllocaInst *AI, AllocaInfo &Info,
768 const SmallPtrSetImpl &DefBlocks,
769 SmallPtrSetImpl &LiveInBlocks) {
768 const SmallPtrSet &DefBlocks,
769 SmallPtrSet &LiveInBlocks) {
770770
771771 // To determine liveness, we must iterate through the predecessors of blocks
772772 // where the def is live. Blocks are added to the worklist if we need to
256256 /// V plus its non-dominating operands. If that cost is greater than
257257 /// CostRemaining, false is returned and CostRemaining is undefined.
258258 static bool DominatesMergePoint(Value *V, BasicBlock *BB,
259 SmallPtrSetImpl> *AggressiveInsts,
259 SmallPtrSet> *AggressiveInsts,
260260 unsigned &CostRemaining,
261261 const DataLayout *DL) {
262262 Instruction *I = dyn_cast(V);
782782 /// Return true if all of the instructions in the block can be speculatively
783783 /// executed. \p SafePtrs is a list of addresses that are known to be legal
784784 /// and we know that we can read from them without segfault.
785 bool blockCanBePredicated(BasicBlock *BB, SmallPtrSetImpl &SafePtrs);
785 bool blockCanBePredicated(BasicBlock *BB, SmallPtrSet& SafePtrs);
786786
787787 /// Returns True, if 'Phi' is the kind of reduction variable for type
788788 /// 'Kind'. If this is a reduction variable, it adds it to ReductionList.
35403540 /// \brief Check that the instruction has outside loop users and is not an
35413541 /// identified reduction variable.
35423542 static bool hasOutsideLoopUser(const Loop *TheLoop, Instruction *Inst,
3543 SmallPtrSetImpl> &Reductions) {
3543 SmallPtrSet> &Reductions) {
35443544 // Reduction instructions are allowed to have exit users. All other
35453545 // instructions must not have external users.
35463546 if (!Reductions.count(Inst))
48834883 }
48844884
48854885 static bool hasMultipleUsesOf(Instruction *I,
4886 SmallPtrSetImpl> &Insts) {
4886 SmallPtrSet> &Insts) {
48874887 unsigned NumUses = 0;
48884888 for(User::op_iterator Use = I->op_begin(), E = I->op_end(); Use != E; ++Use) {
48894889 if (Insts.count(dyn_cast(*Use)))
48954895 return false;
48964896 }
48974897
4898 static bool areAllUsesIn(Instruction *I, SmallPtrSetImpl> &Set) {
4898 static bool areAllUsesIn(Instruction *I, SmallPtrSet> &Set) {
48994899 for(User::op_iterator Use = I->op_begin(), E = I->op_end(); Use != E; ++Use)
49004900 if (!Set.count(dyn_cast(*Use)))
49014901 return false;
52285228 }
52295229
52305230 bool LoopVectorizationLegality::blockCanBePredicated(BasicBlock *BB,
5231 SmallPtrSetImpl &SafePtrs) {
5231 SmallPtrSet& SafePtrs) {
52325232 for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) {
52335233 // We might be able to hoist the load.
52345234 if (it->mayReadFromMemory()) {
447447 void formTwoOperandAlias(StringRef Constraint);
448448
449449 void initialize(const AsmMatcherInfo &Info,
450 SmallPtrSetImpl> &SingletonRegisters,
450 SmallPtrSet> &SingletonRegisters,
451451 int AsmVariantNo, std::string &RegisterPrefix);
452452
453453 /// validate - Return true if this matchable is a valid thing to match against
643643
644644 /// buildRegisterClasses - Build the ClassInfo* instances for register
645645 /// classes.
646 void buildRegisterClasses(SmallPtrSetImpl> &SingletonRegisters);
646 void buildRegisterClasses(SmallPtrSet> &SingletonRegisters);
647647
648648 /// buildOperandClasses - Build the ClassInfo* instances for user defined
649649 /// operand classes.
765765 }
766766
767767 void MatchableInfo::initialize(const AsmMatcherInfo &Info,
768 SmallPtrSetImpl> &SingletonRegisters,
768 SmallPtrSet> &SingletonRegisters,
769769 int AsmVariantNo, std::string &RegisterPrefix) {
770770 AsmVariantID = AsmVariantNo;
771771 AsmString =
10741074 };
10751075
10761076 void AsmMatcherInfo::
1077 buildRegisterClasses(SmallPtrSetImpl> &SingletonRegisters) {
1077 buildRegisterClasses(SmallPtrSet> &SingletonRegisters) {
10781078 const std::vector &Registers =
10791079 Target.getRegBank().getRegisters();
10801080 ArrayRef RegClassList =
10921092 (*it)->getOrder().begin(), (*it)->getOrder().end()));
10931093
10941094 // Add any required singleton sets.
1095 for (SmallPtrSetImpl>::iterator it = SingletonRegisters.begin(),
1095 for (SmallPtrSet>::iterator it = SingletonRegisters.begin(),
10961096 ie = SingletonRegisters.end(); it != ie; ++it) {
10971097 Record *Rec = *it;
10981098 RegisterSets.insert(RegisterSet(&Rec, &Rec + 1));
11901190 RegisterClasses[it->first] = RegisterSetClasses[it->second];
11911191
11921192 // Name the register classes which correspond to singleton registers.
1193 for (SmallPtrSetImpl>::iterator it = SingletonRegisters.begin(),
1193 for (SmallPtrSet>::iterator it = SingletonRegisters.begin(),
11941194 ie = SingletonRegisters.end(); it != ie; ++it) {
11951195 Record *Rec = *it;
11961196 ClassInfo *CI = RegisterClasses[Rec];