mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-27 15:29:51 +00:00
Make TargetData optional in MemCpyOptimizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79306 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
52151168bc
commit
8942f9bb9f
@ -309,10 +309,8 @@ namespace {
|
|||||||
AU.addRequired<DominatorTree>();
|
AU.addRequired<DominatorTree>();
|
||||||
AU.addRequired<MemoryDependenceAnalysis>();
|
AU.addRequired<MemoryDependenceAnalysis>();
|
||||||
AU.addRequired<AliasAnalysis>();
|
AU.addRequired<AliasAnalysis>();
|
||||||
AU.addRequired<TargetData>();
|
|
||||||
AU.addPreserved<AliasAnalysis>();
|
AU.addPreserved<AliasAnalysis>();
|
||||||
AU.addPreserved<MemoryDependenceAnalysis>();
|
AU.addPreserved<MemoryDependenceAnalysis>();
|
||||||
AU.addPreserved<TargetData>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper fuctions
|
// Helper fuctions
|
||||||
@ -350,7 +348,8 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
|||||||
if (!ByteVal)
|
if (!ByteVal)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TargetData &TD = getAnalysis<TargetData>();
|
TargetData *TD = getAnalysisIfAvailable<TargetData>();
|
||||||
|
if (!TD) return false;
|
||||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||||
Module *M = SI->getParent()->getParent()->getParent();
|
Module *M = SI->getParent()->getParent()->getParent();
|
||||||
|
|
||||||
@ -358,7 +357,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
|||||||
// all subsequent stores of the same value to offset from the same pointer.
|
// all subsequent stores of the same value to offset from the same pointer.
|
||||||
// Join these together into ranges, so we can decide whether contiguous blocks
|
// Join these together into ranges, so we can decide whether contiguous blocks
|
||||||
// are stored.
|
// are stored.
|
||||||
MemsetRanges Ranges(TD);
|
MemsetRanges Ranges(*TD);
|
||||||
|
|
||||||
Value *StartPtr = SI->getPointerOperand();
|
Value *StartPtr = SI->getPointerOperand();
|
||||||
|
|
||||||
@ -392,7 +391,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
|||||||
|
|
||||||
// Check to see if this store is to a constant offset from the start ptr.
|
// Check to see if this store is to a constant offset from the start ptr.
|
||||||
int64_t Offset;
|
int64_t Offset;
|
||||||
if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(), Offset, TD))
|
if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(), Offset, *TD))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Ranges.addStore(Offset, NextStore);
|
Ranges.addStore(Offset, NextStore);
|
||||||
@ -421,7 +420,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
|||||||
if (Range.TheStores.size() == 1) continue;
|
if (Range.TheStores.size() == 1) continue;
|
||||||
|
|
||||||
// If it is profitable to lower this range to memset, do so now.
|
// If it is profitable to lower this range to memset, do so now.
|
||||||
if (!Range.isProfitableToUseMemset(TD))
|
if (!Range.isProfitableToUseMemset(*TD))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Otherwise, we do want to transform this! Create a new memset. We put
|
// Otherwise, we do want to transform this! Create a new memset. We put
|
||||||
@ -511,13 +510,14 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check that all of src is copied to dest.
|
// Check that all of src is copied to dest.
|
||||||
TargetData& TD = getAnalysis<TargetData>();
|
TargetData* TD = getAnalysisIfAvailable<TargetData>();
|
||||||
|
if (!TD) return false;
|
||||||
|
|
||||||
ConstantInt* srcArraySize = dyn_cast<ConstantInt>(srcAlloca->getArraySize());
|
ConstantInt* srcArraySize = dyn_cast<ConstantInt>(srcAlloca->getArraySize());
|
||||||
if (!srcArraySize)
|
if (!srcArraySize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint64_t srcSize = TD.getTypeAllocSize(srcAlloca->getAllocatedType()) *
|
uint64_t srcSize = TD->getTypeAllocSize(srcAlloca->getAllocatedType()) *
|
||||||
srcArraySize->getZExtValue();
|
srcArraySize->getZExtValue();
|
||||||
|
|
||||||
if (cpyLength->getZExtValue() < srcSize)
|
if (cpyLength->getZExtValue() < srcSize)
|
||||||
@ -532,7 +532,7 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
|||||||
if (!destArraySize)
|
if (!destArraySize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint64_t destSize = TD.getTypeAllocSize(A->getAllocatedType()) *
|
uint64_t destSize = TD->getTypeAllocSize(A->getAllocatedType()) *
|
||||||
destArraySize->getZExtValue();
|
destArraySize->getZExtValue();
|
||||||
|
|
||||||
if (destSize < srcSize)
|
if (destSize < srcSize)
|
||||||
@ -544,7 +544,7 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Type* StructTy = cast<PointerType>(A->getType())->getElementType();
|
const Type* StructTy = cast<PointerType>(A->getType())->getElementType();
|
||||||
uint64_t destSize = TD.getTypeAllocSize(StructTy);
|
uint64_t destSize = TD->getTypeAllocSize(StructTy);
|
||||||
|
|
||||||
if (destSize < srcSize)
|
if (destSize < srcSize)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user