diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-08-01 18:47:28 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-08-01 18:47:28 +0000 |
| commit | 5f0e76dca64c24ac9b97536d75b8438b86a7b8db (patch) | |
| tree | a250c04f4138557a12185f8643460d9e6807b8b4 /llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp | |
| parent | ec133b3d205cb4a9a5704080e7ba52224fc2b208 (diff) | |
| download | bcm5719-llvm-5f0e76dca64c24ac9b97536d75b8438b86a7b8db.tar.gz bcm5719-llvm-5f0e76dca64c24ac9b97536d75b8438b86a7b8db.zip | |
[CFLAA] Remove modref queries from CFLAA.
As it turns out, modref queries are broken with CFLAA. Specifically,
the data source we were using for determining modref behaviors
explicitly ignores operations on non-pointer values. So, it wouldn't
note e.g. storing an i32 to an i32* (or loading an i64 from an i64*).
It also ignores external function calls, rather than acting
conservatively for them.
(N.B. These operations, where necessary, *are* tracked by CFLAA; we just
use a different mechanism to do so. Said mechanism is relatively
imprecise, so it's unlikely that we can provide reasonably good modref
answers with it as implemented.)
Patch by Jia Chen.
Differential Revision: https://reviews.llvm.org/D22978
llvm-svn: 277366
Diffstat (limited to 'llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp')
| -rw-r--r-- | llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp index f1fac43a5dc..fef397f3b25 100644 --- a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -341,88 +341,6 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA, return NoAlias; } -ModRefInfo CFLSteensAAResult::getArgModRefInfo(ImmutableCallSite CS, - unsigned ArgIdx) { - if (auto CalledFunc = CS.getCalledFunction()) { - if (!CalledFunc->hasExactDefinition()) - return MRI_ModRef; - - auto &MaybeInfo = ensureCached(const_cast<Function *>(CalledFunc)); - if (!MaybeInfo.hasValue()) - return MRI_ModRef; - auto &RetParamAttributes = MaybeInfo->getAliasSummary().RetParamAttributes; - auto &RetParamRelations = MaybeInfo->getAliasSummary().RetParamRelations; - - bool ArgAttributeIsWritten = - std::any_of(RetParamAttributes.begin(), RetParamAttributes.end(), - [ArgIdx](const ExternalAttribute &ExtAttr) { - return ExtAttr.IValue.Index == ArgIdx + 1; - }); - bool ArgIsAccessed = - std::any_of(RetParamRelations.begin(), RetParamRelations.end(), - [ArgIdx](const ExternalRelation &ExtRelation) { - return ExtRelation.To.Index == ArgIdx + 1 || - ExtRelation.From.Index == ArgIdx + 1; - }); - - return (!ArgIsAccessed && !ArgAttributeIsWritten) ? MRI_NoModRef - : MRI_ModRef; - } - - return MRI_ModRef; -} - -FunctionModRefBehavior -CFLSteensAAResult::getModRefBehavior(ImmutableCallSite CS) { - // If we know the callee, try analyzing it - if (auto CalledFunc = CS.getCalledFunction()) - return getModRefBehavior(CalledFunc); - - // Otherwise, be conservative - return FMRB_UnknownModRefBehavior; -} - -FunctionModRefBehavior CFLSteensAAResult::getModRefBehavior(const Function *F) { - assert(F != nullptr); - - // We cannot process external functions - if (!F->hasExactDefinition()) - return FMRB_UnknownModRefBehavior; - - // TODO: Remove the const_cast - auto &MaybeInfo = ensureCached(const_cast<Function *>(F)); - if (!MaybeInfo.hasValue()) - return FMRB_UnknownModRefBehavior; - auto &RetParamAttributes = MaybeInfo->getAliasSummary().RetParamAttributes; - auto &RetParamRelations = MaybeInfo->getAliasSummary().RetParamRelations; - - // First, if any argument is marked Escpaed, Unknown or Global, anything may - // happen to them and thus we can't draw any conclusion. - if (!RetParamAttributes.empty()) - return FMRB_UnknownModRefBehavior; - - // Currently we don't (and can't) distinguish reads from writes in - // RetParamRelations. All we can say is whether there may be memory access or - // not. - bool AccessNoMemory = - all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.From.DerefLevel == 0 && - ExtRelation.To.DerefLevel == 0; - }); - if (AccessNoMemory) - return FMRB_DoesNotAccessMemory; - - // Check if something beyond argmem gets touched. - bool AccessArgMemoryOnly = - all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.From.Index > 0 && ExtRelation.To.Index > 0 && - ExtRelation.From.DerefLevel <= 1 && - ExtRelation.To.DerefLevel <= 1; - }); - return AccessArgMemoryOnly ? FMRB_OnlyAccessesArgumentPointees - : FMRB_UnknownModRefBehavior; -} - char CFLSteensAA::PassID; CFLSteensAAResult CFLSteensAA::run(Function &F, AnalysisManager<Function> &AM) { |

