X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FInstruction.cpp;h=48c73a08400c076316c5247ac002c6ca8fd396fe;hb=fadb3f773e5ab171315761d151c1416921d25614;hp=39a895510ae27b4c2810127a54fca6c2d0c499e7;hpb=f00042a9990d90885a8f236ed0f6bf07902d1374;p=oota-llvm.git diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 39a895510ae..48c73a08400 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -13,6 +13,7 @@ #include "llvm/Type.h" #include "llvm/Instructions.h" +#include "llvm/IntrinsicInst.h" #include "llvm/Function.h" #include "llvm/Support/LeakDetector.h" using namespace llvm; @@ -225,6 +226,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(this)) { + // If the intrinsic doesn't write memory, it is safe. + } + return true; + case Instruction::Load: + return cast(this)->isVolatile(); + } +} /// isAssociative - Return true if the instruction is associative: ///