[llvm] r202742 - [C++11] Remove the completely unnecessary requirement on SetVector's
Justin Bogner
mail at justinbogner.com
Tue Mar 4 09:08:04 PST 2014
Chandler Carruth <chandlerc at gmail.com> writes:
> [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.
...
> --- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Mon Mar 3 13:28:52 2014
> @@ -3640,7 +3640,7 @@ bool SROA::runOnFunction(Function &F) {
> // Remove the deleted allocas from various lists so that we don't try to
> // continue processing them.
> if (!DeletedAllocas.empty()) {
> - std::function<bool(AllocaInst *)> IsInSet = [&](AllocaInst *AI) {
> + auto IsInSet = [&](AllocaInst *AI) {
> return DeletedAllocas.count(AI);
> };
> Worklist.remove_if(IsInSet);
Why not
Worklist.remove_if([&](AllocaInst *AI) {
return DeletedAllocas.count(AI);
});
?
More information about the llvm-commits
mailing list