[llvm] r202742 - [C++11] Remove the completely unnecessary requirement on SetVector's

Nick Lewycky nicholas at mxc.ca
Tue Mar 4 22:24:38 PST 2014


Chandler Carruth wrote:
> Author: chandlerc
> Date: Mon Mar  3 13:28:52 2014
> New Revision: 202742
>
> URL: http://llvm.org/viewvc/llvm-project?rev=202742&view=rev
> Log:
> [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.

Pardon me sir, are you suggesting that llvm's inliner isn't up to the task?

Nick

>
> Modified:
>      llvm/trunk/include/llvm/ADT/SetVector.h
>      llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
>      llvm/trunk/lib/Transforms/Scalar/SROA.cpp
>
> Modified: llvm/trunk/include/llvm/ADT/SetVector.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SetVector.h?rev=202742&r1=202741&r2=202742&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/SetVector.h (original)
> +++ llvm/trunk/include/llvm/ADT/SetVector.h Mon Mar  3 13:28:52 2014
> @@ -195,11 +195,10 @@ private:
>       set_type&set_;
>
>     public:
> -    typedef typename UnaryPredicate::argument_type argument_type;
> -
>       TestAndEraseFromSet(UnaryPredicate P, set_type&set_) : P(P), set_(set_) {}
>
> -    bool operator()(argument_type Arg) {
> +    template<typename ArgumentT>
> +    bool operator()(const ArgumentT&Arg) {
>         if (P(Arg)) {
>           set_.erase(Arg);
>           return true;
>
> Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=202742&r1=202741&r2=202742&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Mon Mar  3 13:28:52 2014
> @@ -803,14 +803,13 @@ bool DSE::handleEndBlock(BasicBlock&BB)
>
>         // If the call might load from any of our allocas, then any store above
>         // the call is live.
> -      std::function<bool(Value *)>  Pred = [&](Value *I) {
> +      DeadStackObjects.remove_if([&](Value *I) {
>           // See if the call site touches the value.
>           AliasAnalysis::ModRefResult A =
>               AA->getModRefInfo(CS, I, getPointerSize(I, *AA));
>
>           return A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref;
> -      };
> -      DeadStackObjects.remove_if(Pred);
> +      });
>
>         // If all of the allocas were clobbered by the call then we're not going
>         // to find anything else to process.
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=202742&r1=202741&r2=202742&view=diff
> ==============================================================================
> --- 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);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list