@@ -284,6 +284,7 @@ static bool mayBeVisibleThroughUnwinding(Value *V, Instruction *Start,
284
284
285
285
void MemCpyOptPass::eraseInstruction (Instruction *I) {
286
286
MSSAU->removeMemoryAccess (I);
287
+ EEI->removeInstruction (I);
287
288
I->eraseFromParent ();
288
289
}
289
290
@@ -638,7 +639,7 @@ bool MemCpyOptPass::processStoreOfLoad(StoreInst *SI, LoadInst *LI,
638
639
if (!LI->isSimple () || !LI->hasOneUse () || LI->getParent () != SI->getParent ())
639
640
return false ;
640
641
641
- BatchAAResults BAA (*AA);
642
+ BatchAAResults BAA (*AA, EEI );
642
643
auto *T = LI->getType ();
643
644
// Don't introduce calls to memcpy/memmove intrinsics out of thin air if
644
645
// the corresponding libcalls are not available.
@@ -1147,14 +1148,14 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
1147
1148
IRBuilder<> Builder (M);
1148
1149
auto *CopySource = MDep->getSource ();
1149
1150
Instruction *NewCopySource = nullptr ;
1150
- auto CleanupOnRet = llvm::make_scope_exit ([&NewCopySource ] {
1151
+ auto CleanupOnRet = llvm::make_scope_exit ([&] {
1151
1152
if (NewCopySource && NewCopySource->use_empty ())
1152
1153
// Safety: It's safe here because we will only allocate more instructions
1153
1154
// after finishing all BatchAA queries, but we have to be careful if we
1154
1155
// want to do something like this in another place. Then we'd probably
1155
1156
// have to delay instruction removal until all transforms on an
1156
1157
// instruction finished.
1157
- NewCopySource-> eraseFromParent ( );
1158
+ eraseInstruction (NewCopySource );
1158
1159
});
1159
1160
MaybeAlign CopySourceAlign = MDep->getSourceAlign ();
1160
1161
// We just need to calculate the actual size of the copy.
@@ -1751,7 +1752,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) {
1751
1752
return true ;
1752
1753
}
1753
1754
1754
- BatchAAResults BAA (*AA);
1755
+ BatchAAResults BAA (*AA, EEI );
1755
1756
// FIXME: Not using getClobberingMemoryAccess() here due to PR54682.
1756
1757
MemoryAccess *AnyClobber = MA->getDefiningAccess ();
1757
1758
MemoryLocation DestLoc = MemoryLocation::getForDest (M);
@@ -1876,7 +1877,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
1876
1877
if (!CallAccess)
1877
1878
return false ;
1878
1879
MemCpyInst *MDep = nullptr ;
1879
- BatchAAResults BAA (*AA);
1880
+ BatchAAResults BAA (*AA, EEI );
1880
1881
MemoryAccess *Clobber = MSSA->getWalker ()->getClobberingMemoryAccess (
1881
1882
CallAccess->getDefiningAccess (), Loc, BAA);
1882
1883
if (auto *MD = dyn_cast<MemoryDef>(Clobber))
@@ -1949,7 +1950,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
1949
1950
// / 4. The memcpy src is not modified during the call. (ModRef check shows no
1950
1951
// / Mod.)
1951
1952
bool MemCpyOptPass::processImmutArgument (CallBase &CB, unsigned ArgNo) {
1952
- BatchAAResults BAA (*AA);
1953
+ BatchAAResults BAA (*AA, EEI );
1953
1954
Value *ImmutArg = CB.getArgOperand (ArgNo);
1954
1955
1955
1956
// 1. Ensure passed argument is immutable during call.
@@ -2117,6 +2118,8 @@ bool MemCpyOptPass::runImpl(Function &F, TargetLibraryInfo *TLI_,
2117
2118
MSSA = MSSA_;
2118
2119
MemorySSAUpdater MSSAU_ (MSSA_);
2119
2120
MSSAU = &MSSAU_;
2121
+ EarliestEscapeInfo EEI_ (*DT);
2122
+ EEI = &EEI_;
2120
2123
2121
2124
while (true ) {
2122
2125
if (!iterateOnFunction (F))
0 commit comments