diff options
author | Dan Gohman <gohman@apple.com> | 2007-07-26 16:06:08 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-07-26 16:06:08 +0000 |
commit | 37f3ee17d2192e52f436f640788b28c0b68db102 (patch) | |
tree | 24593350863a6f0aa740fb353e95fb4fbb4767ac /lib/VMCore | |
parent | c2dfd066c0343e48050a405637b2d04705c47d79 (diff) | |
download | external_llvm-37f3ee17d2192e52f436f640788b28c0b68db102.zip external_llvm-37f3ee17d2192e52f436f640788b28c0b68db102.tar.gz external_llvm-37f3ee17d2192e52f436f640788b28c0b68db102.tar.bz2 |
Move the GET_SIDE_EFFECT_INFO logic from isInstructionTriviallyDead
to Instruction::mayWriteToMemory, fixing a FIXME, and helping
various places that call mayWriteToMemory directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Instruction.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index feff59d..a368753 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<IntrinsicInst>(this)) { + if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(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<LoadInst>(this)->isVolatile(); |