aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-15 23:15:00 +0000
committerChris Lattner <sabre@nondot.org>2007-02-15 23:15:00 +0000
commitbb5493d9fa8845f002613ac013087b347a052357 (patch)
tree78b5992873f92c6157882ad8e0eb8715afb041ba
parent535014f8eceb62d509afe3363966c409bd8ba983 (diff)
make mayWriteToMemory a non-virtual function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34334 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Instruction.h2
-rw-r--r--include/llvm/Instructions.h18
-rw-r--r--lib/VMCore/Instruction.cpp19
3 files changed, 21 insertions, 18 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 7f7bcc881c..239e878a6a 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -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:
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 9fc76019aa..259b5aa165 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -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; }
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 39a895510a..e02af07937 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -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:
///