[llvm-commits] [llvm] r40533 - in /llvm/trunk/lib: Transforms/Utils/Local.cpp VMCore/Instruction.cpp

Dan Gohman djg at cray.com
Thu Jul 26 09:06:08 PDT 2007


Author: djg
Date: Thu Jul 26 11:06:08 2007
New Revision: 40533

URL: http://llvm.org/viewvc/llvm-project?rev=40533&view=rev
Log:
Move the GET_SIDE_EFFECT_INFO logic from isInstructionTriviallyDead
to Instruction::mayWriteToMemory, fixing a FIXME, and helping
various places that call mayWriteToMemory directly.

Modified:
    llvm/trunk/lib/Transforms/Utils/Local.cpp
    llvm/trunk/lib/VMCore/Instruction.cpp

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=40533&r1=40532&r2=40533&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Thu Jul 26 11:06:08 2007
@@ -175,13 +175,6 @@
 
   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;
 }
 

Modified: llvm/trunk/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=40533&r1=40532&r2=40533&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instruction.cpp (original)
+++ llvm/trunk/lib/VMCore/Instruction.cpp Thu Jul 26 11:06:08 2007
@@ -197,6 +197,15 @@
   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 @@
   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();





More information about the llvm-commits mailing list