llvm.org GIT mirror llvm / 0550e93
[C++11] Remove the completely unnecessary requirement on SetVector's remove_if that its predicate is adaptable. We don't actually need this, we can write a generic adapter for any predicate. This lets us remove some very wrong std::function usages. We should never be using std::function for predicates to algorithms. This incurs an *indirect* call overhead for every evaluation of the predicate, and makes it very hard to inline through. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202742 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
3 changed file(s) with 5 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
194194 set_type &set_;
195195
196196 public:
197 typedef typename UnaryPredicate::argument_type argument_type;
198
199197 TestAndEraseFromSet(UnaryPredicate P, set_type &set_) : P(P), set_(set_) {}
200198
201 bool operator()(argument_type Arg) {
199 template
200 bool operator()(const ArgumentT &Arg) {
202201 if (P(Arg)) {
203202 set_.erase(Arg);
204203 return true;
802802
803803 // If the call might load from any of our allocas, then any store above
804804 // the call is live.
805 std::function Pred = [&](Value *I) {
805 DeadStackObjects.remove_if([&](Value *I) {
806806 // See if the call site touches the value.
807807 AliasAnalysis::ModRefResult A =
808808 AA->getModRefInfo(CS, I, getPointerSize(I, *AA));
809809
810810 return A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref;
811 };
812 DeadStackObjects.remove_if(Pred);
811 });
813812
814813 // If all of the allocas were clobbered by the call then we're not going
815814 // to find anything else to process.
36393639 // Remove the deleted allocas from various lists so that we don't try to
36403640 // continue processing them.
36413641 if (!DeletedAllocas.empty()) {
3642 std::function IsInSet = [&](AllocaInst *AI) {
3642 auto IsInSet = [&](AllocaInst *AI) {
36433643 return DeletedAllocas.count(AI);
36443644 };
36453645 Worklist.remove_if(IsInSet);