diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-08 17:16:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-08 17:16:51 +0000 |
commit | 8462711ce88fb6c946989fde7f5e8a55d695e45b (patch) | |
tree | eb08e6229d10b0492ddc61d933daff153b43f801 /llvm/lib/VMCore/Instruction.cpp | |
parent | 4758caa926889093d59201ffb8cdcc278a9c8482 (diff) | |
download | bcm5719-llvm-8462711ce88fb6c946989fde7f5e8a55d695e45b.tar.gz bcm5719-llvm-8462711ce88fb6c946989fde7f5e8a55d695e45b.zip |
add a new Instruction::mayReadFromMemory predicate, make
Instruction::mayWriteToMemory stronger for invokes.
llvm-svn: 50858
Diffstat (limited to 'llvm/lib/VMCore/Instruction.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instruction.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index 5344cf7bfe5..345fd1dd94e 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/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(); } |