| 118 | |
| 119 | template <class CallerMapT, class SetT> |
| 120 | void collectAllCallersFromSet(const CallerMapT &CM, llvm::Function *F, const SetT &Input, |
| 121 | SetT &DiscardedOut, SetT &Out) { |
| 122 | if(!F) |
| 123 | return; |
| 124 | |
| 125 | if(Out.contains(F) || DiscardedOut.contains(F) || !Input.contains(F)) { |
| 126 | DiscardedOut.insert(F); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | auto It = CM.find(F); |
| 131 | if(It == CM.end()) { |
| 132 | DiscardedOut.insert(F); |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | Out.insert(F); |
| 137 | |
| 138 | for(auto* Caller : It->getSecond()) { |
| 139 | collectAllCallersFromSet(CM, Caller, Input, DiscardedOut, Out); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | llvm::PreservedAnalyses MallocToUSMPass::run(llvm::Module &M, llvm::ModuleAnalysisManager &AM) { |