aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-11-08 17:10:22 +0000
committerDan Gohman <gohman@apple.com>2010-11-08 17:10:22 +0000
commita8598bec287108d0359880d33955759dc90cd5a1 (patch)
treef81dc41c4b2d2cad4c4dc623f975bd2d0fb8307f /lib/Analysis
parent6cecceb2f6900fa1197acce4c086a5c58dc21392 (diff)
downloadexternal_llvm-a8598bec287108d0359880d33955759dc90cd5a1.zip
external_llvm-a8598bec287108d0359880d33955759dc90cd5a1.tar.gz
external_llvm-a8598bec287108d0359880d33955759dc90cd5a1.tar.bz2
Implement getModRefBehavior for TypeBasedAliasAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118416 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/TypeBasedAliasAnalysis.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Analysis/TypeBasedAliasAnalysis.cpp b/lib/Analysis/TypeBasedAliasAnalysis.cpp
index 044a93f..16ff64e 100644
--- a/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -139,6 +139,8 @@ namespace {
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual AliasResult alias(const Location &LocA, const Location &LocB);
virtual bool pointsToConstantMemory(const Location &Loc, bool OrLocal);
+ virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
+ virtual ModRefBehavior getModRefBehavior(const Function *F);
virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
const Location &Loc);
virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
@@ -241,6 +243,27 @@ bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc,
return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal);
}
+AliasAnalysis::ModRefBehavior
+TypeBasedAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
+ if (!EnableTBAA)
+ return AliasAnalysis::getModRefBehavior(CS);
+
+ ModRefBehavior Min = UnknownModRefBehavior;
+
+ // If this is an "immutable" type, we can assume the call doesn't write
+ // to memory.
+ if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
+ if (TBAANode(M).TypeIsImmutable())
+ Min = OnlyReadsMemory;
+
+ return std::min(AliasAnalysis::getModRefBehavior(CS), Min);
+}
+
+AliasAnalysis::ModRefBehavior
+TypeBasedAliasAnalysis::getModRefBehavior(const Function *F) {
+ return AliasAnalysis::getModRefBehavior(F);
+}
+
AliasAnalysis::ModRefResult
TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
const Location &Loc) {