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) {
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; }
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; }
~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);
}
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; }
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!");
virtual InsertElementInst *clone() const;
- virtual bool mayWriteToMemory() const { return false; }
-
/// getType - Overload to return most specific vector type.
///
inline const VectorType *getType() const {
virtual ShuffleVectorInst *clone() const;
- virtual bool mayWriteToMemory() const { return false; }
-
/// getType - Overload to return most specific vector type.
///
inline const VectorType *getType() const {
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; }
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:
///