[llvm-commits] [llvm] r118416 - /llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
Dan Gohman
gohman at apple.com
Mon Nov 8 09:10:22 PST 2010
Author: djg
Date: Mon Nov 8 11:10:22 2010
New Revision: 118416
URL: http://llvm.org/viewvc/llvm-project?rev=118416&view=rev
Log:
Implement getModRefBehavior for TypeBasedAliasAnalysis.
Modified:
llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
Modified: llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp?rev=118416&r1=118415&r2=118416&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp Mon Nov 8 11:10:22 2010
@@ -139,6 +139,8 @@
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 @@
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) {
More information about the llvm-commits
mailing list