Rename Instruction::hasSideEffects() -> mayWriteToMemory()
authorChris Lattner <sabre@nondot.org>
Mon, 24 Feb 2003 20:48:32 +0000 (20:48 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 24 Feb 2003 20:48:32 +0000 (20:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5620 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instruction.h
include/llvm/iMemory.h
include/llvm/iOther.h
include/llvm/iTerminators.h
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/Reassociate.cpp
lib/Transforms/Utils/Local.cpp

index ca01e30fe54776a5ba98b5beeade4acfcf122d73..5f61b2d410879f993dadd1efe9301d0b60c3c2ce 100644 (file)
@@ -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 
index e42f5b993b85c924a66abf00169ae3ae2e76c81f..09c94a2c77db62203120acfa34f89a2d66a5b43a 100644 (file)
@@ -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); }
index 026134f2763bc8a927670e4cc76c5d6dce52428b..5ad3d0a66d0c23790288e6da7acbb44b42b753e4 100644 (file)
@@ -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<Function>(Operands[0].get());
index 85c2c8b4efdf986537f14db64e6613473349a6a5..0101f85d4bf5ea00633f79bf59faba44da52dd9c 100644 (file)
@@ -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...
index 24ccee60344bd76b9663b9ebbd1e1639d413d780..e7bc1357ffe641ef125c67908072449d082d3b13 100644 (file)
@@ -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)) {
index 4212e6ae69f83e322d4cc54ad2a7c1fa9734fb6f..df0a64188f3e751def73c3922d8d0f3cb30775a2 100644 (file)
@@ -74,7 +74,7 @@ unsigned Reassociate::getRank(Value *V) {
     if (I->getOpcode() == Instruction::PHINode ||
         I->getOpcode() == Instruction::Alloca ||
         I->getOpcode() == Instruction::Malloc || isa<TerminatorInst>(I) ||
-        I->hasSideEffects())
+        I->mayWriteToMemory())  // Cannot move inst if it writes to memory!
       return RankMap[I->getParent()];
 
     unsigned &CachedRank = InstRankMap[I];
index 10028bacecb5215b9254b8d8e04827779135e609..8f67e111a780d34425ef7d5dfed8eff3e0e2136b 100644 (file)
@@ -91,7 +91,7 @@ bool ConstantFoldTerminator(BasicBlock *BB) {
 //
 
 bool isInstructionTriviallyDead(Instruction *I) {
-  return I->use_empty() && !I->hasSideEffects() && !isa<TerminatorInst>(I);
+  return I->use_empty() && !I->mayWriteToMemory() && !isa<TerminatorInst>(I);
 }
 
 // dceInstruction - Inspect the instruction at *BBI and figure out if it's