mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
[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
This commit is contained in:
parent
6f8c0c0613
commit
0550e93e89
@ -195,11 +195,10 @@ private:
|
|||||||
set_type &set_;
|
set_type &set_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename UnaryPredicate::argument_type argument_type;
|
|
||||||
|
|
||||||
TestAndEraseFromSet(UnaryPredicate P, set_type &set_) : P(P), set_(set_) {}
|
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)) {
|
if (P(Arg)) {
|
||||||
set_.erase(Arg);
|
set_.erase(Arg);
|
||||||
return true;
|
return true;
|
||||||
|
@ -803,14 +803,13 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
|
|||||||
|
|
||||||
// If the call might load from any of our allocas, then any store above
|
// If the call might load from any of our allocas, then any store above
|
||||||
// the call is live.
|
// the call is live.
|
||||||
std::function<bool(Value *)> Pred = [&](Value *I) {
|
DeadStackObjects.remove_if([&](Value *I) {
|
||||||
// See if the call site touches the value.
|
// See if the call site touches the value.
|
||||||
AliasAnalysis::ModRefResult A =
|
AliasAnalysis::ModRefResult A =
|
||||||
AA->getModRefInfo(CS, I, getPointerSize(I, *AA));
|
AA->getModRefInfo(CS, I, getPointerSize(I, *AA));
|
||||||
|
|
||||||
return A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref;
|
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
|
// If all of the allocas were clobbered by the call then we're not going
|
||||||
// to find anything else to process.
|
// to find anything else to process.
|
||||||
|
@ -3640,7 +3640,7 @@ bool SROA::runOnFunction(Function &F) {
|
|||||||
// Remove the deleted allocas from various lists so that we don't try to
|
// Remove the deleted allocas from various lists so that we don't try to
|
||||||
// continue processing them.
|
// continue processing them.
|
||||||
if (!DeletedAllocas.empty()) {
|
if (!DeletedAllocas.empty()) {
|
||||||
std::function<bool(AllocaInst *)> IsInSet = [&](AllocaInst *AI) {
|
auto IsInSet = [&](AllocaInst *AI) {
|
||||||
return DeletedAllocas.count(AI);
|
return DeletedAllocas.count(AI);
|
||||||
};
|
};
|
||||||
Worklist.remove_if(IsInSet);
|
Worklist.remove_if(IsInSet);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user