From efe30ef790ecec920b48aeacfb98ea4fe5516f01 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 27 Jul 2004 02:20:26 +0000 Subject: [PATCH] Use context-sensitive alias analysis to avoid pessimization in clients of AliasSetTracker (dse and licm). This implements DeadStoreElimination/context-sensitive.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15254 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/AliasSetTracker.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 867e58adcc6..fedc2790744 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -138,20 +138,38 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size, return true; // Check the call sites list and invoke list... - if (!CallSites.empty()) - // FIXME: this is pessimistic! - return true; + if (!CallSites.empty()) { + if (AA.hasNoModRefInfoForCalls()) + return true; + + for (unsigned i = 0, e = CallSites.size(); i != e; ++i) + if (AA.getModRefInfo(CallSites[i], const_cast(Ptr), Size) + != AliasAnalysis::NoModRef) + return true; + } return false; } bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const { - // FIXME: Use mod/ref information to prune this better! if (Function *F = CS.getCalledFunction()) if (AA.doesNotAccessMemory(F)) return false; - return true; + if (AA.hasNoModRefInfoForCalls()) + return true; + + for (unsigned i = 0, e = CallSites.size(); i != e; ++i) + if (AA.getModRefInfo(CallSites[i], CS) != AliasAnalysis::NoModRef || + AA.getModRefInfo(CS, CallSites[i]) != AliasAnalysis::NoModRef) + return true; + + for (iterator I = begin(), E = end(); I != E; ++I) + if (AA.getModRefInfo(CS, I.getPointer(), I.getSize()) != + AliasAnalysis::NoModRef) + return true; + + return false; } -- 2.34.1