Remove warnings when using -Wshorten-64-to-32.
[oota-llvm.git] / lib / VMCore / Instruction.cpp
index 5344cf7bfe58e101a1da105b31f0e0f7f07506d4..2316b486898222414b05853233f9ab44e2d12535 100644 (file)
@@ -219,7 +219,23 @@ bool Instruction::isUsedOutsideOfBlock(const BasicBlock *BB) const {
   return false;    
 }
 
-
+/// mayReadFromMemory - Return true if this instruction may read memory.
+///
+bool Instruction::mayReadFromMemory() const {
+  switch (getOpcode()) {
+  default: return false;
+  case Instruction::Free:
+  case Instruction::VAArg:
+  case Instruction::Load:
+    return true;
+  case Instruction::Call:
+    return !cast<CallInst>(this)->doesNotAccessMemory();
+  case Instruction::Invoke:
+    return !cast<InvokeInst>(this)->doesNotAccessMemory();
+  case Instruction::Store:
+    return cast<StoreInst>(this)->isVolatile();
+  }
+}
 
 /// mayWriteToMemory - Return true if this instruction may modify memory.
 ///
@@ -227,12 +243,13 @@ bool Instruction::mayWriteToMemory() const {
   switch (getOpcode()) {
   default: return false;
   case Instruction::Free:
-  case Instruction::Invoke:
   case Instruction::Store:
   case Instruction::VAArg:
     return true;
   case Instruction::Call:
     return !cast<CallInst>(this)->onlyReadsMemory();
+  case Instruction::Invoke:
+    return !cast<InvokeInst>(this)->onlyReadsMemory();
   case Instruction::Load:
     return cast<LoadInst>(this)->isVolatile();
   }