aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Instruction.cpp
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 /lib/VMCore/Instruction.cpp
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
Diffstat (limited to 'lib/VMCore/Instruction.cpp')
-rw-r--r--lib/VMCore/Instruction.cpp19
1 files changed, 19 insertions, 0 deletions
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:
///