make mayWriteToMemory a non-virtual function

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34334 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-02-15 23:15:00 +00:00
parent 535014f8ec
commit bb5493d9fa
3 changed files with 21 additions and 18 deletions

View File

@ -54,7 +54,7 @@ public:
/// mayWriteToMemory - Return true if this instruction may modify memory.
///
virtual bool mayWriteToMemory() const { return false; }
bool mayWriteToMemory() const;
/// clone() - Create a copy of 'this' instruction that is identical in all
/// ways except the following:

View File

@ -189,8 +189,6 @@ public:
virtual FreeInst *clone() const;
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; }
static inline bool classof(const Instruction *I) {
@ -245,8 +243,6 @@ public:
virtual LoadInst *clone() const;
virtual bool mayWriteToMemory() const { return isVolatile(); }
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
static unsigned getPointerOperandIndex() { return 0U; }
@ -310,8 +306,6 @@ public:
virtual StoreInst *clone() const;
virtual bool mayWriteToMemory() const { return true; }
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
static unsigned getPointerOperandIndex() { return 1U; }
@ -722,8 +716,7 @@ public:
~CallInst();
virtual CallInst *clone() const;
bool mayWriteToMemory() const { return true; }
bool isTailCall() const { return SubclassData & 1; }
void setTailCall(bool isTailCall = true) {
SubclassData = (SubclassData & ~1) | unsigned(isTailCall);
@ -845,7 +838,6 @@ public:
}
virtual VAArgInst *clone() const;
bool mayWriteToMemory() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const VAArgInst *) { return true; }
@ -888,8 +880,6 @@ public:
virtual ExtractElementInst *clone() const;
virtual bool mayWriteToMemory() const { return false; }
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
@ -938,8 +928,6 @@ public:
virtual InsertElementInst *clone() const;
virtual bool mayWriteToMemory() const { return false; }
/// getType - Overload to return most specific vector type.
///
inline const VectorType *getType() const {
@ -990,8 +978,6 @@ public:
virtual ShuffleVectorInst *clone() const;
virtual bool mayWriteToMemory() const { return false; }
/// getType - Overload to return most specific vector type.
///
inline const VectorType *getType() const {
@ -1499,8 +1485,6 @@ public:
virtual InvokeInst *clone() const;
bool mayWriteToMemory() const { return true; }
/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
unsigned getCallingConv() const { return SubclassData; }

View File

@ -225,6 +225,25 @@ bool Instruction::isSameOperationAs(Instruction *I) const {
return true;
}
/// mayWriteToMemory - Return true if this instruction may modify memory.
///
bool Instruction::mayWriteToMemory() const {
switch (getOpcode()) {
default: return false;
case Instruction::Free:
case Instruction::Store:
case Instruction::Invoke:
case Instruction::VAArg:
return true;
case Instruction::Call:
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(this)) {
// If the intrinsic doesn't write memory, it is safe.
}
return true;
case Instruction::Load:
return cast<LoadInst>(this)->isVolatile();
}
}
/// isAssociative - Return true if the instruction is associative:
///