[llvm-commits] [llvm] r43605 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/PartialStore.ll
Owen Anderson
resistor at mac.com
Wed Oct 31 22:29:21 PDT 2007
Author: resistor
Date: Thu Nov 1 00:29:16 2007
New Revision: 43605
URL: http://llvm.org/viewvc/llvm-project?rev=43605&view=rev
Log:
Fix test/Transforms/DeadStoreElimination/PartialStore.ll, which had been
silently failing because of an incorrect run line for some time.
Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=43605&r1=43604&r2=43605&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Thu Nov 1 00:29:16 2007
@@ -63,14 +63,18 @@
/// from allocas, it is safe to ignore GEP indices, since
/// either the store will be in the alloca, and thus dead,
/// or beyond the end of the alloca, and thus undefined.
- void TranslatePointerBitCasts(Value*& v) {
+ void TranslatePointerBitCasts(Value*& v, bool zeroGepsOnly = false) {
assert(isa<PointerType>(v->getType()) &&
"Translating a non-pointer type?");
while (true) {
if (BitCastInst* C = dyn_cast<BitCastInst>(v))
v = C->getOperand(0);
else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(v))
- v = G->getOperand(0);
+ if (!zeroGepsOnly || G->hasAllZeroIndices()) {
+ v = G->getOperand(0);
+ } else {
+ break;
+ }
else
break;
}
@@ -95,7 +99,8 @@
bool DSE::runOnBasicBlock(BasicBlock &BB) {
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
-
+ TargetData &TD = getAnalysis<TargetData>();
+
// Record the last-seen store to this pointer
DenseMap<Value*, StoreInst*> lastStore;
// Record instructions possibly made dead by deleting a store
@@ -119,6 +124,7 @@
} else
pointer = cast<FreeInst>(BBI)->getPointerOperand();
+ TranslatePointerBitCasts(pointer, true);
StoreInst*& last = lastStore[pointer];
bool deletedStore = false;
@@ -130,7 +136,9 @@
while (dep != MemoryDependenceAnalysis::None &&
dep != MemoryDependenceAnalysis::NonLocal &&
isa<StoreInst>(dep)) {
- if (dep != last) {
+ if (dep != last ||
+ TD.getTypeSize(last->getOperand(0)->getType()) >
+ TD.getTypeSize(BBI->getOperand(0)->getType())) {
dep = MD.getDependency(BBI, dep);
continue;
}
Modified: llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll?rev=43605&r1=43604&r2=43605&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll (original)
+++ llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll Thu Nov 1 00:29:16 2007
@@ -1,5 +1,5 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | \
-; RUN: not grep {store sbyte}
+; RUN: not grep {store i8}
; Ensure that the dead store is deleted in this case. It is wholely
; overwritten by the second store.
int %test() {
More information about the llvm-commits
mailing list