@@ -467,12 +467,8 @@ class AllocaSlices::partition_iterator
467
467
// Remove the uses which have ended in the prior partition. This
468
468
// cannot change the max split slice end because we just checked that
469
469
// the prior partition ended prior to that max.
470
- P.SplitTails .erase (llvm::remove_if (P.SplitTails ,
471
- [&](Slice *S) {
472
- return S->endOffset () <=
473
- P.EndOffset ;
474
- }),
475
- P.SplitTails .end ());
470
+ llvm::erase_if (P.SplitTails ,
471
+ [&](Slice *S) { return S->endOffset () <= P.EndOffset ; });
476
472
assert (llvm::any_of (P.SplitTails ,
477
473
[&](Slice *S) {
478
474
return S->endOffset () == MaxSplitSliceEndOffset;
@@ -1076,9 +1072,7 @@ AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI)
1076
1072
return ;
1077
1073
}
1078
1074
1079
- Slices.erase (
1080
- llvm::remove_if (Slices, [](const Slice &S) { return S.isDead (); }),
1081
- Slices.end ());
1075
+ llvm::erase_if (Slices, [](const Slice &S) { return S.isDead (); });
1082
1076
1083
1077
// Sort the uses. This arranges for the offsets to be in ascending order,
1084
1078
// and the sizes to be in descending order.
@@ -1932,12 +1926,9 @@ static VectorType *isVectorPromotionViable(Partition &P, const DataLayout &DL) {
1932
1926
// do that until all the backends are known to produce good code for all
1933
1927
// integer vector types.
1934
1928
if (!HaveCommonEltTy) {
1935
- CandidateTys.erase (
1936
- llvm::remove_if (CandidateTys,
1937
- [](VectorType *VTy) {
1938
- return !VTy->getElementType ()->isIntegerTy ();
1939
- }),
1940
- CandidateTys.end ());
1929
+ llvm::erase_if (CandidateTys, [](VectorType *VTy) {
1930
+ return !VTy->getElementType ()->isIntegerTy ();
1931
+ });
1941
1932
1942
1933
// If there were no integer vector types, give up.
1943
1934
if (CandidateTys.empty ())
@@ -3902,63 +3893,53 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
3902
3893
// such loads and stores, we can only pre-split them if their splits exactly
3903
3894
// match relative to their starting offset. We have to verify this prior to
3904
3895
// any rewriting.
3905
- Stores.erase (
3906
- llvm::remove_if (Stores,
3907
- [&UnsplittableLoads, &SplitOffsetsMap](StoreInst *SI) {
3908
- // Lookup the load we are storing in our map of split
3909
- // offsets.
3910
- auto *LI = cast<LoadInst>(SI->getValueOperand ());
3911
- // If it was completely unsplittable, then we're done,
3912
- // and this store can't be pre-split.
3913
- if (UnsplittableLoads.count (LI))
3914
- return true ;
3915
-
3916
- auto LoadOffsetsI = SplitOffsetsMap.find (LI);
3917
- if (LoadOffsetsI == SplitOffsetsMap.end ())
3918
- return false ; // Unrelated loads are definitely safe.
3919
- auto &LoadOffsets = LoadOffsetsI->second ;
3920
-
3921
- // Now lookup the store's offsets.
3922
- auto &StoreOffsets = SplitOffsetsMap[SI];
3923
-
3924
- // If the relative offsets of each split in the load and
3925
- // store match exactly, then we can split them and we
3926
- // don't need to remove them here.
3927
- if (LoadOffsets.Splits == StoreOffsets.Splits )
3928
- return false ;
3929
-
3930
- LLVM_DEBUG (
3931
- dbgs ()
3932
- << " Mismatched splits for load and store:\n "
3933
- << " " << *LI << " \n "
3934
- << " " << *SI << " \n " );
3935
-
3936
- // We've found a store and load that we need to split
3937
- // with mismatched relative splits. Just give up on them
3938
- // and remove both instructions from our list of
3939
- // candidates.
3940
- UnsplittableLoads.insert (LI);
3941
- return true ;
3942
- }),
3943
- Stores.end ());
3896
+ llvm::erase_if (Stores, [&UnsplittableLoads, &SplitOffsetsMap](StoreInst *SI) {
3897
+ // Lookup the load we are storing in our map of split
3898
+ // offsets.
3899
+ auto *LI = cast<LoadInst>(SI->getValueOperand ());
3900
+ // If it was completely unsplittable, then we're done,
3901
+ // and this store can't be pre-split.
3902
+ if (UnsplittableLoads.count (LI))
3903
+ return true ;
3904
+
3905
+ auto LoadOffsetsI = SplitOffsetsMap.find (LI);
3906
+ if (LoadOffsetsI == SplitOffsetsMap.end ())
3907
+ return false ; // Unrelated loads are definitely safe.
3908
+ auto &LoadOffsets = LoadOffsetsI->second ;
3909
+
3910
+ // Now lookup the store's offsets.
3911
+ auto &StoreOffsets = SplitOffsetsMap[SI];
3912
+
3913
+ // If the relative offsets of each split in the load and
3914
+ // store match exactly, then we can split them and we
3915
+ // don't need to remove them here.
3916
+ if (LoadOffsets.Splits == StoreOffsets.Splits )
3917
+ return false ;
3918
+
3919
+ LLVM_DEBUG (dbgs () << " Mismatched splits for load and store:\n "
3920
+ << " " << *LI << " \n "
3921
+ << " " << *SI << " \n " );
3922
+
3923
+ // We've found a store and load that we need to split
3924
+ // with mismatched relative splits. Just give up on them
3925
+ // and remove both instructions from our list of
3926
+ // candidates.
3927
+ UnsplittableLoads.insert (LI);
3928
+ return true ;
3929
+ });
3944
3930
// Now we have to go *back* through all the stores, because a later store may
3945
3931
// have caused an earlier store's load to become unsplittable and if it is
3946
3932
// unsplittable for the later store, then we can't rely on it being split in
3947
3933
// the earlier store either.
3948
- Stores.erase (llvm::remove_if (Stores,
3949
- [&UnsplittableLoads](StoreInst *SI) {
3950
- auto *LI =
3951
- cast<LoadInst>(SI->getValueOperand ());
3952
- return UnsplittableLoads.count (LI);
3953
- }),
3954
- Stores.end ());
3934
+ llvm::erase_if (Stores, [&UnsplittableLoads](StoreInst *SI) {
3935
+ auto *LI = cast<LoadInst>(SI->getValueOperand ());
3936
+ return UnsplittableLoads.count (LI);
3937
+ });
3955
3938
// Once we've established all the loads that can't be split for some reason,
3956
3939
// filter any that made it into our list out.
3957
- Loads.erase (llvm::remove_if (Loads,
3958
- [&UnsplittableLoads](LoadInst *LI) {
3959
- return UnsplittableLoads.count (LI);
3960
- }),
3961
- Loads.end ());
3940
+ llvm::erase_if (Loads, [&UnsplittableLoads](LoadInst *LI) {
3941
+ return UnsplittableLoads.count (LI);
3942
+ });
3962
3943
3963
3944
// If no loads or stores are left, there is no pre-splitting to be done for
3964
3945
// this alloca.
@@ -4232,8 +4213,7 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4232
4213
}
4233
4214
4234
4215
// Remove the killed slices that have ben pre-split.
4235
- AS.erase (llvm::remove_if (AS, [](const Slice &S) { return S.isDead (); }),
4236
- AS.end ());
4216
+ llvm::erase_if (AS, [](const Slice &S) { return S.isDead (); });
4237
4217
4238
4218
// Insert our new slices. This will sort and merge them into the sorted
4239
4219
// sequence.
@@ -4247,11 +4227,9 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4247
4227
4248
4228
// Finally, don't try to promote any allocas that new require re-splitting.
4249
4229
// They have already been added to the worklist above.
4250
- PromotableAllocas.erase (
4251
- llvm::remove_if (
4252
- PromotableAllocas,
4253
- [&](AllocaInst *AI) { return ResplitPromotableAllocas.count (AI); }),
4254
- PromotableAllocas.end ());
4230
+ llvm::erase_if (PromotableAllocas, [&](AllocaInst *AI) {
4231
+ return ResplitPromotableAllocas.count (AI);
4232
+ });
4255
4233
4256
4234
return true ;
4257
4235
}
@@ -4768,8 +4746,7 @@ PreservedAnalyses SROA::runImpl(Function &F, DominatorTree &RunDT,
4768
4746
auto IsInSet = [&](AllocaInst *AI) { return DeletedAllocas.count (AI); };
4769
4747
Worklist.remove_if (IsInSet);
4770
4748
PostPromotionWorklist.remove_if (IsInSet);
4771
- PromotableAllocas.erase (llvm::remove_if (PromotableAllocas, IsInSet),
4772
- PromotableAllocas.end ());
4749
+ llvm::erase_if (PromotableAllocas, IsInSet);
4773
4750
DeletedAllocas.clear ();
4774
4751
}
4775
4752
}
0 commit comments