summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-10-19 22:54:46 +0000
committerDan Gohman <gohman@apple.com>2010-10-19 22:54:46 +0000
commit3da848bbda62b25c12335998aaa44ab361f0bf15 (patch)
treedc1f3f7581fede379da986ef29041c892f3b545b /lib/Transforms/Scalar
parent5ee568ac2704d7302017d42ad162d4b53d076cbc (diff)
downloadllvm-3da848bbda62b25c12335998aaa44ab361f0bf15.tar.gz
llvm-3da848bbda62b25c12335998aaa44ab361f0bf15.tar.bz2
llvm-3da848bbda62b25c12335998aaa44ab361f0bf15.tar.xz
Reapply r116831 and r116839, converting AliasAnalysis to use
uint64_t, plus fixes for places I missed before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp28
-rw-r--r--lib/Transforms/Scalar/LICM.cpp4
-rw-r--r--lib/Transforms/Scalar/MemCpyOptimizer.cpp2
-rw-r--r--lib/Transforms/Scalar/Sink.cpp2
4 files changed, 19 insertions, 17 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 26cb3a6a29..d81d302eba 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -61,7 +61,7 @@ namespace {
bool handleFreeWithNonTrivialDependency(const CallInst *F,
MemDepResult Dep);
bool handleEndBlock(BasicBlock &BB);
- bool RemoveUndeadPointers(Value *Ptr, unsigned killPointerSize,
+ bool RemoveUndeadPointers(Value *Ptr, uint64_t killPointerSize,
BasicBlock::iterator &BBI,
SmallPtrSet<Value*, 64> &deadPointers);
void DeleteDeadInstruction(Instruction *I,
@@ -79,7 +79,7 @@ namespace {
AU.addPreserved<MemoryDependenceAnalysis>();
}
- unsigned getPointerSize(Value *V) const;
+ uint64_t getPointerSize(Value *V) const;
};
}
@@ -142,11 +142,11 @@ static Value *getPointerOperand(Instruction *I) {
}
/// getStoreSize - Return the length in bytes of the write by the clobbering
-/// instruction. If variable or unknown, returns -1.
-static unsigned getStoreSize(Instruction *I, const TargetData *TD) {
+/// instruction. If variable or unknown, returns AliasAnalysis::UnknownSize.
+static uint64_t getStoreSize(Instruction *I, const TargetData *TD) {
assert(doesClobberMemory(I));
if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
- if (!TD) return -1u;
+ if (!TD) return AliasAnalysis::UnknownSize;
return TD->getTypeStoreSize(SI->getOperand(0)->getType());
}
@@ -158,7 +158,7 @@ static unsigned getStoreSize(Instruction *I, const TargetData *TD) {
switch (II->getIntrinsicID()) {
default: assert(false && "Unexpected intrinsic!");
case Intrinsic::init_trampoline:
- return -1u;
+ return AliasAnalysis::UnknownSize;
case Intrinsic::lifetime_end:
Len = II->getArgOperand(0);
break;
@@ -167,7 +167,7 @@ static unsigned getStoreSize(Instruction *I, const TargetData *TD) {
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(Len))
if (!LenCI->isAllOnesValue())
return LenCI->getZExtValue();
- return -1u;
+ return AliasAnalysis::UnknownSize;
}
/// isStoreAtLeastAsWideAs - Return true if the size of the store in I1 is
@@ -182,10 +182,12 @@ static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2,
// Exactly the same type, must have exactly the same size.
if (I1Ty == I2Ty) return true;
- int I1Size = getStoreSize(I1, TD);
- int I2Size = getStoreSize(I2, TD);
+ uint64_t I1Size = getStoreSize(I1, TD);
+ uint64_t I2Size = getStoreSize(I2, TD);
- return I1Size != -1 && I2Size != -1 && I1Size >= I2Size;
+ return I1Size != AliasAnalysis::UnknownSize &&
+ I2Size != AliasAnalysis::UnknownSize &&
+ I1Size >= I2Size;
}
bool DSE::runOnBasicBlock(BasicBlock &BB) {
@@ -373,7 +375,7 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
}
Value *killPointer = 0;
- unsigned killPointerSize = AliasAnalysis::UnknownSize;
+ uint64_t killPointerSize = AliasAnalysis::UnknownSize;
// If we encounter a use of the pointer, it is no longer considered dead
if (LoadInst *L = dyn_cast<LoadInst>(BBI)) {
@@ -472,7 +474,7 @@ bool DSE::handleEndBlock(BasicBlock &BB) {
/// RemoveUndeadPointers - check for uses of a pointer that make it
/// undead when scanning for dead stores to alloca's.
-bool DSE::RemoveUndeadPointers(Value *killPointer, unsigned killPointerSize,
+bool DSE::RemoveUndeadPointers(Value *killPointer, uint64_t killPointerSize,
BasicBlock::iterator &BBI,
SmallPtrSet<Value*, 64> &deadPointers) {
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
@@ -565,7 +567,7 @@ void DSE::DeleteDeadInstruction(Instruction *I,
} while (!NowDeadInsts.empty());
}
-unsigned DSE::getPointerSize(Value *V) const {
+uint64_t DSE::getPointerSize(Value *V) const {
if (TD) {
if (AllocaInst *A = dyn_cast<AllocaInst>(V)) {
// Get size information for the alloca
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index 666f402e3c..7e1021725c 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -190,7 +190,7 @@ namespace {
/// pointerInvalidatedByLoop - Return true if the body of this loop may
/// store into the memory location pointed to by V.
///
- bool pointerInvalidatedByLoop(Value *V, unsigned Size,
+ bool pointerInvalidatedByLoop(Value *V, uint64_t Size,
const MDNode *TBAAInfo) {
// Check to see if any of the basic blocks in CurLoop invalidate *V.
return CurAST->getAliasSetForPointer(V, Size, TBAAInfo).isMod();
@@ -402,7 +402,7 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
return true;
// Don't hoist loads which have may-aliased stores in loop.
- unsigned Size = 0;
+ uint64_t Size = 0;
if (LI->getType()->isSized())
Size = AA->getTypeStoreSize(LI->getType());
return !pointerInvalidatedByLoop(LI->getOperand(0), Size,
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index d4a9171e85..f4876eac43 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -772,7 +772,7 @@ bool MemCpyOpt::processMemMove(MemMoveInst *M) {
// If the memmove is a constant size, use it for the alias query, this allows
// us to optimize things like: memmove(P, P+64, 64);
- unsigned MemMoveSize = AliasAnalysis::UnknownSize;
+ uint64_t MemMoveSize = AliasAnalysis::UnknownSize;
if (ConstantInt *Len = dyn_cast<ConstantInt>(M->getLength()))
MemMoveSize = Len->getZExtValue();
diff --git a/lib/Transforms/Scalar/Sink.cpp b/lib/Transforms/Scalar/Sink.cpp
index 7306ee5e2e..1aca908267 100644
--- a/lib/Transforms/Scalar/Sink.cpp
+++ b/lib/Transforms/Scalar/Sink.cpp
@@ -157,7 +157,7 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
if (L->isVolatile()) return false;
Value *Ptr = L->getPointerOperand();
- unsigned Size = AA->getTypeStoreSize(L->getType());
+ uint64_t Size = AA->getTypeStoreSize(L->getType());
for (SmallPtrSet<Instruction *, 8>::iterator I = Stores.begin(),
E = Stores.end(); I != E; ++I)
if (AA->getModRefInfo(*I, Ptr, Size) & AliasAnalysis::Mod)