From 4869f3700e07d41bcc34f0b292161727db550716 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 24 Feb 2003 20:48:32 +0000 Subject: [PATCH] Rename Instruction::hasSideEffects() -> mayWriteToMemory() llvm-svn: 5620 --- llvm/include/llvm/Instruction.h | 4 +++- llvm/include/llvm/iMemory.h | 4 ++-- llvm/include/llvm/iOther.h | 2 +- llvm/include/llvm/iTerminators.h | 2 +- llvm/lib/Transforms/Scalar/ADCE.cpp | 2 +- llvm/lib/Transforms/Scalar/Reassociate.cpp | 2 +- llvm/lib/Transforms/Utils/Local.cpp | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/llvm/include/llvm/Instruction.h b/llvm/include/llvm/Instruction.h index ca01e30fe547..5f61b2d41087 100644 --- a/llvm/include/llvm/Instruction.h +++ b/llvm/include/llvm/Instruction.h @@ -55,7 +55,9 @@ public: Instruction *getPrev() { return Prev; } const Instruction *getPrev() const { return Prev; } - virtual bool hasSideEffects() const { return false; } // Memory & Call insts + /// mayWriteToMemory - Return true if this instruction may modify memory. + /// + virtual bool mayWriteToMemory() const { return false; } // --------------------------------------------------------------------------- /// Subclass classification... getOpcode() returns a member of diff --git a/llvm/include/llvm/iMemory.h b/llvm/include/llvm/iMemory.h index e42f5b993b85..09c94a2c77db 100644 --- a/llvm/include/llvm/iMemory.h +++ b/llvm/include/llvm/iMemory.h @@ -120,7 +120,7 @@ struct FreeInst : public Instruction { virtual Instruction *clone() const { return new FreeInst(Operands[0]); } - virtual bool hasSideEffects() const { return true; } + virtual bool mayWriteToMemory() const { return true; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const FreeInst *) { return true; } @@ -177,7 +177,7 @@ public: StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new StoreInst(*this); } - virtual bool hasSideEffects() const { return true; } + virtual bool mayWriteToMemory() const { return true; } Value *getPointerOperand() { return getOperand(1); } const Value *getPointerOperand() const { return getOperand(1); } diff --git a/llvm/include/llvm/iOther.h b/llvm/include/llvm/iOther.h index 026134f2763b..5ad3d0a66d0c 100644 --- a/llvm/include/llvm/iOther.h +++ b/llvm/include/llvm/iOther.h @@ -60,7 +60,7 @@ public: Instruction* InsertBefore = 0); virtual Instruction *clone() const { return new CallInst(*this); } - bool hasSideEffects() const { return true; } + bool mayWriteToMemory() const { return true; } const Function *getCalledFunction() const { return dyn_cast(Operands[0].get()); diff --git a/llvm/include/llvm/iTerminators.h b/llvm/include/llvm/iTerminators.h index 85c2c8b4efdf..0101f85d4bf5 100644 --- a/llvm/include/llvm/iTerminators.h +++ b/llvm/include/llvm/iTerminators.h @@ -196,7 +196,7 @@ public: virtual Instruction *clone() const { return new InvokeInst(*this); } - bool hasSideEffects() const { return true; } + bool mayWriteToMemory() const { return true; } // getCalledFunction - Return the function called, or null if this is an // indirect function invocation... diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 24ccee60344b..e7bc1357ffe6 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -154,7 +154,7 @@ bool ADCE::doADCE() { BBI != BBE; ++BBI) { BasicBlock *BB = *BBI; for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) { - if (II->hasSideEffects() || II->getOpcode() == Instruction::Ret) { + if (II->mayWriteToMemory() || II->getOpcode() == Instruction::Ret) { markInstructionLive(II); ++II; // Increment the inst iterator if the inst wasn't deleted } else if (isInstructionTriviallyDead(II)) { diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 4212e6ae69f8..df0a64188f3e 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -74,7 +74,7 @@ unsigned Reassociate::getRank(Value *V) { if (I->getOpcode() == Instruction::PHINode || I->getOpcode() == Instruction::Alloca || I->getOpcode() == Instruction::Malloc || isa(I) || - I->hasSideEffects()) + I->mayWriteToMemory()) // Cannot move inst if it writes to memory! return RankMap[I->getParent()]; unsigned &CachedRank = InstRankMap[I]; diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 10028bacecb5..8f67e111a780 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -91,7 +91,7 @@ bool ConstantFoldTerminator(BasicBlock *BB) { // bool isInstructionTriviallyDead(Instruction *I) { - return I->use_empty() && !I->hasSideEffects() && !isa(I); + return I->use_empty() && !I->mayWriteToMemory() && !isa(I); } // dceInstruction - Inspect the instruction at *BBI and figure out if it's