From b0cf0f89be387a1f325ec62321ad16abf07d4587 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 15 Mar 2004 04:08:36 +0000 Subject: [PATCH] Don't be COMPLETELY pessimistic in the face of function calls llvm-svn: 12413 --- lib/Analysis/AliasSetTracker.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 67cef76d579..d266c2a5a07 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -93,9 +93,21 @@ void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry, RefCount++; // Entry points to alias set... } -void AliasSet::addCallSite(CallSite CS) { +void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) { CallSites.push_back(CS); - AliasTy = MayAlias; // FIXME: Too conservative? + + if (Function *F = CS.getCalledFunction()) { + if (AA.doesNotAccessMemory(F)) + return; + else if (AA.onlyReadsMemory(F)) { + AliasTy = MayAlias; + AccessTy = Refs; + return; + } + } + + // FIXME: This should use mod/ref information to make this not suck so bad + AliasTy = MayAlias; AccessTy = ModRef; } @@ -129,7 +141,11 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size, } bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const { - // FIXME: Too conservative! + // FIXME: Use mod/ref information to prune this better! + if (Function *F = CS.getCalledFunction()) + if (AA.doesNotAccessMemory(F)) + return false; + return true; } @@ -213,7 +229,7 @@ void AliasSetTracker::add(CallSite CS) { AliasSets.push_back(AliasSet()); AS = &AliasSets.back(); } - AS->addCallSite(CS); + AS->addCallSite(CS, AA); } void AliasSetTracker::add(Instruction *I) {