summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-03-03 19:28:52 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-03-03 19:28:52 +0000
commitd031fe9fcfd1e8003c0ee90e57c5e8b4ab65d145 (patch)
tree1671ee5c3f4bc751dce84452704db98a887db856
parentf519be343b3c30af4afde418e390e1e05d3253f8 (diff)
downloadbcm5719-llvm-d031fe9fcfd1e8003c0ee90e57c5e8b4ab65d145.tar.gz
bcm5719-llvm-d031fe9fcfd1e8003c0ee90e57c5e8b4ab65d145.zip
[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-svn: 202742
-rw-r--r--llvm/include/llvm/ADT/SetVector.h5
-rw-r--r--llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp5
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp2
3 files changed, 5 insertions, 7 deletions
diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h
index 5eda37c675f..1e7d237045a 100644
--- a/llvm/include/llvm/ADT/SetVector.h
+++ b/llvm/include/llvm/ADT/SetVector.h
@@ -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;
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 4bc9dd5aeec..a170e42bc26 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -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.
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 3c245e4bd5e..1dc83dad227 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -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);
OpenPOWER on IntegriCloud