[llvm-commits] [llvm] r50858 - in /llvm/trunk: include/llvm/Instruction.h lib/VMCore/Instruction.cpp
Chris Lattner
sabre at nondot.org
Thu May 8 10:16:52 PDT 2008
Author: lattner
Date: Thu May 8 12:16:51 2008
New Revision: 50858
URL: http://llvm.org/viewvc/llvm-project?rev=50858&view=rev
Log:
add a new Instruction::mayReadFromMemory predicate, make
Instruction::mayWriteToMemory stronger for invokes.
Modified:
llvm/trunk/include/llvm/Instruction.h
llvm/trunk/lib/VMCore/Instruction.cpp
Modified: llvm/trunk/include/llvm/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=50858&r1=50857&r2=50858&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instruction.h (original)
+++ llvm/trunk/include/llvm/Instruction.h Thu May 8 12:16:51 2008
@@ -50,6 +50,10 @@
///
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
Modified: llvm/trunk/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=50858&r1=50857&r2=50858&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instruction.cpp (original)
+++ llvm/trunk/lib/VMCore/Instruction.cpp Thu May 8 12:16:51 2008
@@ -219,7 +219,23 @@
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 @@
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();
}
More information about the llvm-commits
mailing list