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
This commit is contained in:
Chris Lattner 2008-05-08 17:16:51 +00:00
parent d7266d484a
commit d96288a2ff
2 changed files with 23 additions and 2 deletions

View File

@ -50,6 +50,10 @@ public:
///
bool mayWriteToMemory() const;
/// mayReadFromMemory - Return true if this instruction may read memory.
///
bool mayReadFromMemory() const;
/// clone() - Create a copy of 'this' instruction that is identical in all
/// ways except the following:
/// * The instruction has no parent

View File

@ -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();
}