[llvm-commits] [llvm] r120378 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Chris Lattner
sabre at nondot.org
Mon Nov 29 17:37:52 PST 2010
Author: lattner
Date: Mon Nov 29 19:37:52 2010
New Revision: 120378
URL: http://llvm.org/viewvc/llvm-project?rev=120378&view=rev
Log:
rename doesClobberMemory -> hasMemoryWrite to be more specific, and
remove an actively-wrong comment.
Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=120378&r1=120377&r2=120378&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Mon Nov 29 19:37:52 2010
@@ -91,9 +91,9 @@
FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); }
-/// doesClobberMemory - Does this instruction clobber (write without reading)
-/// some memory?
-static bool doesClobberMemory(Instruction *I) {
+/// hasMemoryWrite - Does this instruction write some memory? This only returns
+/// true for things that we can analyze with other helpers below.
+static bool hasMemoryWrite(Instruction *I) {
if (isa<StoreInst>(I))
return true;
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
@@ -114,7 +114,7 @@
/// isElidable - If the value of this instruction and the memory it writes to is
/// unused, may we delete this instrtction?
static bool isElidable(Instruction *I) {
- assert(doesClobberMemory(I));
+ assert(hasMemoryWrite(I));
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
return II->getIntrinsicID() != Intrinsic::lifetime_end;
if (StoreInst *SI = dyn_cast<StoreInst>(I))
@@ -124,7 +124,7 @@
/// getPointerOperand - Return the pointer that is being written to.
static Value *getPointerOperand(Instruction *I) {
- assert(doesClobberMemory(I));
+ assert(hasMemoryWrite(I));
if (StoreInst *SI = dyn_cast<StoreInst>(I))
return SI->getPointerOperand();
if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(I))
@@ -143,7 +143,7 @@
/// getStoreSize - Return the length in bytes of the write by the clobbering
/// instruction. If variable or unknown, returns AliasAnalysis::UnknownSize.
static uint64_t getStoreSize(Instruction *I, const TargetData *TD) {
- assert(doesClobberMemory(I));
+ assert(hasMemoryWrite(I));
if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
if (!TD) return AliasAnalysis::UnknownSize;
return TD->getTypeStoreSize(SI->getOperand(0)->getType());
@@ -206,8 +206,8 @@
continue;
}
- // If we find a store, get its memory dependence.
- if (!doesClobberMemory(Inst))
+ // If we find something that writes memory, get its memory dependence.
+ if (!hasMemoryWrite(Inst))
continue;
MemDepResult InstDep = MD.getDependency(Inst);
@@ -264,7 +264,7 @@
// If this is a store-store dependence, then the previous store is dead so
// long as this store is at least as big as it.
- if (InstDep.isDef() && doesClobberMemory(InstDep.getInst())) {
+ if (InstDep.isDef() && hasMemoryWrite(InstDep.getInst())) {
Instruction *DepStore = InstDep.getInst();
if (isStoreAtLeastAsWideAs(Inst, DepStore, TD) && isElidable(DepStore)) {
// Delete the store and now-dead instructions that feed it.
@@ -301,7 +301,7 @@
if (Dep.isNonLocal()) return false;
Instruction *Dependency = Dep.getInst();
- if (!doesClobberMemory(Dependency) || !isElidable(Dependency))
+ if (!hasMemoryWrite(Dependency) || !isElidable(Dependency))
return false;
Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject();
@@ -358,7 +358,7 @@
--BBI;
// If we find a store whose pointer is dead.
- if (doesClobberMemory(BBI)) {
+ if (hasMemoryWrite(BBI)) {
if (isElidable(BBI)) {
// See through pointer-to-pointer bitcasts
Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject();
More information about the llvm-commits
mailing list