summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/DeadStoreElimination.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-29 01:43:36 +0000
committerChris Lattner <sabre@nondot.org>2008-11-29 01:43:36 +0000
commit39f372e23e49cecb8db2eb7120eb331173e50c74 (patch)
treedef18a4ae1596487c205831717d1b5fc98e2296d /lib/Transforms/Scalar/DeadStoreElimination.cpp
parentd63e618212ae716f775c4a03658377d4d8eba5ff (diff)
downloadllvm-39f372e23e49cecb8db2eb7120eb331173e50c74.tar.gz
llvm-39f372e23e49cecb8db2eb7120eb331173e50c74.tar.bz2
llvm-39f372e23e49cecb8db2eb7120eb331173e50c74.tar.xz
Reimplement the internal abstraction used by MemDep in terms
of a pointer/int pair instead of a manually bitmangled pointer. This forces clients to think a little more about checking the appropriate pieces and will be useful for internal implementation improvements later. I'm not particularly happy with this. After going through this I don't think that the clients of memdep should be exposed to the internal type at all. I'll fix this in a subsequent commit. This has no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/DeadStoreElimination.cpp')
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index e6a05b7e90..8217a44c6f 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -46,9 +46,11 @@ namespace {
Changed |= runOnBasicBlock(*I);
return Changed;
}
+
+ typedef MemoryDependenceAnalysis::DepResultTy DepResultTy;
bool runOnBasicBlock(BasicBlock &BB);
- bool handleFreeWithNonTrivialDependency(FreeInst *F, Instruction *Dep);
+ bool handleFreeWithNonTrivialDependency(FreeInst *F, DepResultTy Dep);
bool handleEndBlock(BasicBlock &BB);
bool RemoveUndeadPointers(Value* pointer, uint64_t killPointerSize,
BasicBlock::iterator& BBI,
@@ -108,17 +110,16 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// ... to a pointer that has been stored to before...
if (last) {
- Instruction* dep = MD.getDependency(Inst);
+ DepResultTy dep = MD.getDependency(Inst);
bool deletedStore = false;
// ... and no other memory dependencies are between them....
- while (dep != MemoryDependenceAnalysis::None &&
- dep != MemoryDependenceAnalysis::NonLocal &&
- isa<StoreInst>(dep)) {
- if (dep != last ||
+ while (dep.getInt() == MemoryDependenceAnalysis::Normal &&
+ isa<StoreInst>(dep.getPointer())) {
+ if (dep.getPointer() != last ||
TD.getTypeStoreSize(last->getOperand(0)->getType()) >
TD.getTypeStoreSize(Inst->getOperand(0)->getType())) {
- dep = MD.getDependency(Inst, dep);
+ dep = MD.getDependency(Inst, dep.getPointer());
continue;
}
@@ -151,14 +152,14 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// loaded from, then the store can be removed;
if (LoadInst* L = dyn_cast<LoadInst>(S->getOperand(0))) {
// FIXME: Don't do dep query if Parents don't match and other stuff!
- Instruction* dep = MD.getDependency(S);
+ DepResultTy dep = MD.getDependency(S);
DominatorTree& DT = getAnalysis<DominatorTree>();
if (!S->isVolatile() && S->getParent() == L->getParent() &&
S->getPointerOperand() == L->getPointerOperand() &&
- (dep == MemoryDependenceAnalysis::None ||
- dep == MemoryDependenceAnalysis::NonLocal ||
- DT.dominates(dep, L))) {
+ (dep.getInt() == MemoryDependenceAnalysis::None ||
+ dep.getInt() == MemoryDependenceAnalysis::NonLocal ||
+ DT.dominates(dep.getPointer(), L))) {
DeleteDeadInstruction(S);
if (!isa<TerminatorInst>(BB.begin()))
@@ -184,15 +185,15 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
/// handleFreeWithNonTrivialDependency - Handle frees of entire structures whose
/// dependency is a store to a field of that structure.
-bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dep) {
+bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, DepResultTy dep) {
TargetData &TD = getAnalysis<TargetData>();
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
- if (dep == MemoryDependenceAnalysis::None ||
- dep == MemoryDependenceAnalysis::NonLocal)
+ if (dep.getInt() == MemoryDependenceAnalysis::None ||
+ dep.getInt() == MemoryDependenceAnalysis::NonLocal)
return false;
- StoreInst* dependency = dyn_cast<StoreInst>(dep);
+ StoreInst* dependency = dyn_cast<StoreInst>(dep.getPointer());
if (!dependency)
return false;
else if (dependency->isVolatile())