Teach BasicAliasAnalysis::getModRefBehavior(const Function *F)
authorDan Gohman <gohman@apple.com>
Mon, 8 Nov 2010 16:08:43 +0000 (16:08 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 8 Nov 2010 16:08:43 +0000 (16:08 +0000)
to analyze intrinsic functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118409 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicAliasAnalysis.cpp

index 669202f8599f244909c8eb97e7292160b8501669..221c8639e0fc748d21fa62bd02581eab92c17703 100644 (file)
@@ -553,14 +553,22 @@ BasicAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
 /// For use when the call site is not known.
 AliasAnalysis::ModRefBehavior
 BasicAliasAnalysis::getModRefBehavior(const Function *F) {
+  // If the function declares it doesn't access memory, we can't do better.
   if (F->doesNotAccessMemory())
-    // Can't do better than this.
     return DoesNotAccessMemory;
+
+  // For intrinsics, we can check the table.
+  if (unsigned iid = F->getIntrinsicID()) {
+#define GET_INTRINSIC_MODREF_BEHAVIOR
+#include "llvm/Intrinsics.gen"
+#undef GET_INTRINSIC_MODREF_BEHAVIOR
+  }
+
+  // If the function declares it only reads memory, go with that.
   if (F->onlyReadsMemory())
     return OnlyReadsMemory;
-  if (unsigned id = F->getIntrinsicID())
-    return getIntrinsicModRefBehavior(id);
 
+  // Otherwise be conservative.
   return AliasAnalysis::getModRefBehavior(F);
 }