1414#ifndef LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
1515#define LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
1616
17+ #include " llvm/Analysis/MemoryLocation.h"
1718#include " llvm/IR/BasicBlock.h"
1819#include " llvm/IR/PassManager.h"
1920
@@ -64,21 +65,28 @@ class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
6465private:
6566 // Helper functions
6667 bool processStore (StoreInst *SI, BasicBlock::iterator &BBI);
68+ bool processLoad (LoadInst *LI, BasicBlock::iterator &BBI,
69+ SmallVectorImpl<Instruction *> &NewInsts);
6770 bool processStoreOfLoad (StoreInst *SI, LoadInst *LI, const DataLayout &DL,
6871 BasicBlock::iterator &BBI);
6972 bool processMemSet (MemSetInst *SI, BasicBlock::iterator &BBI);
70- bool processMemCpy (MemCpyInst *M, BasicBlock::iterator &BBI);
73+ bool processMemCpy (MemCpyInst *M, BasicBlock::iterator &BBI,
74+ SmallVectorImpl<Instruction *> &NewInsts);
7175 bool processMemMove (MemMoveInst *M, BasicBlock::iterator &BBI);
7276 bool performCallSlotOptzn (Instruction *cpyLoad, Instruction *cpyStore,
7377 Value *cpyDst, Value *cpySrc, TypeSize cpyLen,
7478 Align cpyAlign, BatchAAResults &BAA,
7579 std::function<CallInst *()> GetC);
7680 bool processMemCpyMemCpyDependence (MemCpyInst *M, MemCpyInst *MDep,
77- BatchAAResults &BAA);
81+ BatchAAResults &BAA,
82+ SmallVectorImpl<Instruction *> &NewInsts);
7883 bool processMemSetMemCpyDependence (MemCpyInst *MemCpy, MemSetInst *MemSet,
7984 BatchAAResults &BAA);
8085 bool performMemCpyToMemSetOptzn (MemCpyInst *MemCpy, MemSetInst *MemSet,
8186 BatchAAResults &BAA);
87+ bool findNewSrc (MemCpyInst *MDep, Instruction *UseInstr, BatchAAResults &BAA,
88+ Value *&NewSrc, MaybeAlign &NewAlign,
89+ SmallVectorImpl<Instruction *> &NewInsts);
8290 bool processByValArgument (CallBase &CB, unsigned ArgNo);
8391 bool processImmutArgument (CallBase &CB, unsigned ArgNo);
8492 Instruction *tryMergingIntoMemset (Instruction *I, Value *StartPtr,
@@ -90,7 +98,7 @@ class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
9098 bool isMemMoveMemSetDependency (MemMoveInst *M);
9199
92100 void eraseInstruction (Instruction *I);
93- bool iterateOnFunction (Function &F);
101+ bool iterateOnFunction (Function &F, SmallVectorImpl<Instruction *> &NewInsts );
94102};
95103
96104} // end namespace llvm
0 commit comments