aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Utils/Local.cpp7
-rw-r--r--lib/VMCore/Instruction.cpp16
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 5e2d237..187ebdc 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -175,13 +175,6 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
if (!I->mayWriteToMemory()) return true;
- if (CallInst *CI = dyn_cast<CallInst>(I))
- if (Function *F = CI->getCalledFunction()) {
- unsigned IntrinsicID = F->getIntrinsicID();
-#define GET_SIDE_EFFECT_INFO
-#include "llvm/Intrinsics.gen"
-#undef GET_SIDE_EFFECT_INFO
- }
return false;
}
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();