aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Instruction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-08 17:16:51 +0000
committerChris Lattner <sabre@nondot.org>2008-05-08 17:16:51 +0000
commitd96288a2ff188bb1fb1b86fb89b1ac82f6310a5c (patch)
treeb09a3091614b804eeaecd5ba70e1ae9953e91b37 /lib/VMCore/Instruction.cpp
parentd7266d484a861c3fcc6763df27fc81a8e3c46fc5 (diff)
add a new Instruction::mayReadFromMemory predicate, make
Instruction::mayWriteToMemory stronger for invokes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instruction.cpp')
-rw-r--r--lib/VMCore/Instruction.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 5344cf7bfe..345fd1dd94 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -219,7 +219,23 @@ bool Instruction::isUsedOutsideOfBlock(const BasicBlock *BB) const {
return false;
}
-
+/// mayReadFromMemory - Return true if this instruction may read memory.
+///
+bool Instruction::mayReadFromMemory() const {
+ switch (getOpcode()) {
+ default: return false;
+ case Instruction::Free:
+ case Instruction::Store:
+ case Instruction::VAArg:
+ return true;
+ case Instruction::Call:
+ return !cast<CallInst>(this)->doesNotAccessMemory();
+ case Instruction::Invoke:
+ return !cast<InvokeInst>(this)->doesNotAccessMemory();
+ case Instruction::Load:
+ return true;
+ }
+}
/// mayWriteToMemory - Return true if this instruction may modify memory.
///
@@ -227,12 +243,13 @@ bool Instruction::mayWriteToMemory() const {
switch (getOpcode()) {
default: return false;
case Instruction::Free:
- case Instruction::Invoke:
case Instruction::Store:
case Instruction::VAArg:
return true;
case Instruction::Call:
return !cast<CallInst>(this)->onlyReadsMemory();
+ case Instruction::Invoke:
+ return !cast<InvokeInst>(this)->onlyReadsMemory();
case Instruction::Load:
return cast<LoadInst>(this)->isVolatile();
}