diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-15 23:15:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-15 23:15:00 +0000 |
commit | c992e18f8d315dd09a002d32bb614bf71888fdff (patch) | |
tree | 7bd96f65ecea9ad9a70c24793f1f1815c58b159e /llvm/lib/VMCore/Instruction.cpp | |
parent | 99c6cf60f136b3f24fc407866094001cd069fc77 (diff) | |
download | bcm5719-llvm-c992e18f8d315dd09a002d32bb614bf71888fdff.tar.gz bcm5719-llvm-c992e18f8d315dd09a002d32bb614bf71888fdff.zip |
make mayWriteToMemory a non-virtual function
llvm-svn: 34334
Diffstat (limited to 'llvm/lib/VMCore/Instruction.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instruction.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index 39a895510ae..e02af07937a 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/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: /// |