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/CFLAndersAliasAnalysis.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/CFLAndersAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp index f5985c8ccc6..19cc515c537 100644 --- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -862,112 +862,6 @@ AliasResult CFLAndersAAResult::alias(const MemoryLocation &LocA, return QueryResult; } -ModRefInfo CFLAndersAAResult::getArgModRefInfo(ImmutableCallSite CS, - unsigned ArgIdx) { - if (auto CalledFunc = CS.getCalledFunction()) { - if (!CalledFunc->hasExactDefinition()) - return MRI_ModRef; - - auto &MaybeInfo = ensureCached(*CalledFunc); - if (!MaybeInfo.hasValue()) - return MRI_ModRef; - auto &RetParamAttributes = MaybeInfo->getAliasSummary().RetParamAttributes; - auto &RetParamRelations = MaybeInfo->getAliasSummary().RetParamRelations; - - bool ArgAttributeIsWritten = - any_of(RetParamAttributes, [ArgIdx](const ExternalAttribute &ExtAttr) { - return ExtAttr.IValue.Index == ArgIdx + 1; - }); - - // If the argument is unknown, escaped, or alias global, be conservative. - // FIXME: Do we really need to be conservative for AttrGlobal? - if (ArgAttributeIsWritten) - return MRI_ModRef; - - bool ArgIsRead = any_of(RetParamRelations, - [ArgIdx](const ExternalRelation &ExtRelation) { - return ExtRelation.From.Index == ArgIdx + 1; - }); - - bool ArgIsWritten = any_of(RetParamRelations, - [ArgIdx](const ExternalRelation &ExtRelation) { - return ExtRelation.To.Index == ArgIdx + 1; - }); - - if (ArgIsRead) - return ArgIsWritten ? MRI_ModRef : MRI_Ref; - return ArgIsWritten ? MRI_Mod : MRI_NoModRef; - } - - return MRI_ModRef; -} - -FunctionModRefBehavior -CFLAndersAAResult::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 CFLAndersAAResult::getModRefBehavior(const Function *F) { - assert(F != nullptr); - - // We cannot process external functions - if (!F->hasExactDefinition()) - return FMRB_UnknownModRefBehavior; - - auto &MaybeInfo = ensureCached(*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. - // FIXME: Do we really need to be conservative for AttrGlobal? - if (!RetParamAttributes.empty()) - return FMRB_UnknownModRefBehavior; - - // Check if memory gets touched. - bool MemIsRead = - any_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.From.DerefLevel > 0; - }); - bool MemIsWritten = - any_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.To.DerefLevel > 0; - }); - if (!MemIsRead && !MemIsWritten) - return FMRB_DoesNotAccessMemory; - - // Check if only argmem gets touched. - bool ArgMemIsAccessed = - all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.From.Index > 0 && ExtRelation.From.DerefLevel <= 1 && - ExtRelation.To.Index > 0 && ExtRelation.To.DerefLevel <= 1; - }); - if (ArgMemIsAccessed) - return FMRB_OnlyAccessesArgumentPointees; - - if (!MemIsWritten) { - // Check if something beyond argmem gets read. - bool ArgMemReadOnly = - all_of(RetParamRelations, [](const ExternalRelation &ExtRelation) { - return ExtRelation.From.Index > 0 && ExtRelation.From.DerefLevel <= 1; - }); - return ArgMemReadOnly ? FMRB_OnlyReadsArgumentPointees - : FMRB_OnlyReadsMemory; - } - - if (!MemIsRead) - return FMRB_DoesNotReadMemory; - - return FMRB_UnknownModRefBehavior; -} - char CFLAndersAA::PassID; CFLAndersAAResult CFLAndersAA::run(Function &F, AnalysisManager<Function> &AM) { |