X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FInstruction.cpp;h=a3687530de9b69a69e251fda3da08f145f39f4ad;hb=37f3ee17d2192e52f436f640788b28c0b68db102;hp=feff59dff9f12483e9a8285b83d843260cbdd29f;hpb=c2dfd066c0343e48050a405637b2d04705c47d79;p=oota-llvm.git diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index feff59dff9f..a3687530de9 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -197,6 +197,15 @@ bool Instruction::isSameOperationAs(Instruction *I) const { return true; } +// IntrinsicOnlyReadsMemory - Return true if the specified intrinsic doesn't +// have any side-effects or if it only reads memory. +static bool IntrinsicOnlyReadsMemory(unsigned IntrinsicID) { +#define GET_SIDE_EFFECT_INFO +#include "llvm/Intrinsics.gen" +#undef GET_SIDE_EFFECT_INFO + return false; +} + /// mayWriteToMemory - Return true if this instruction may modify memory. /// bool Instruction::mayWriteToMemory() const { @@ -208,11 +217,10 @@ bool Instruction::mayWriteToMemory() const { case Instruction::VAArg: return true; case Instruction::Call: - //if (const IntrinsicInst *II = dyn_cast(this)) { + if (const IntrinsicInst *II = dyn_cast(this)) { // If the intrinsic doesn't write memory, it is safe. - // FIXME: this is obviously supposed to determine which intrinsics - // don't write to memory, but hasn't been implemented yet. - //} + return !IntrinsicOnlyReadsMemory(II->getIntrinsicID()); + } return true; case Instruction::Load: return cast(this)->isVolatile();